From 1aee25876ea237b60f6084e0a75e804107572674 Mon Sep 17 00:00:00 2001 From: ryouji Date: Mon, 30 Jun 2025 16:46:51 +0900 Subject: [PATCH 01/11] =?UTF-8?q?paiza=E3=81=AEC144:=E3=81=98=E3=82=83?= =?UTF-8?q?=E3=82=93=E3=81=91=E3=82=93=E3=81=AE=E7=B5=90=E6=9E=9C=E5=95=8F?= =?UTF-8?q?=E9=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rsuzuki/README.md | 2 + rsuzuki/src/.gitkeep | 0 rsuzuki/src/C069_Festival.java | 82 +++++++++++++++++++++++++++++ rsuzuki/src/win.java | 28 ++++++++++ rsuzuki/test/.gitkeep | 0 rsuzuki/test/C069_FestivalTest.java | 26 +++++++++ 6 files changed, 138 insertions(+) create mode 100644 rsuzuki/README.md create mode 100644 rsuzuki/src/.gitkeep create mode 100644 rsuzuki/src/C069_Festival.java create mode 100644 rsuzuki/src/win.java create mode 100644 rsuzuki/test/.gitkeep create mode 100644 rsuzuki/test/C069_FestivalTest.java diff --git a/rsuzuki/README.md b/rsuzuki/README.md new file mode 100644 index 0000000..796c95d --- /dev/null +++ b/rsuzuki/README.md @@ -0,0 +1,2 @@ +# Paiza +knoda用 diff --git a/rsuzuki/src/.gitkeep b/rsuzuki/src/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/rsuzuki/src/C069_Festival.java b/rsuzuki/src/C069_Festival.java new file mode 100644 index 0000000..b64383c --- /dev/null +++ b/rsuzuki/src/C069_Festival.java @@ -0,0 +1,82 @@ +package hellojunit; + +import java.util.Scanner; + +public class C069_Festival { + + public static void main(String[] args) { + Scanner scan = new Scanner(System.in); + final int year = scan.nextInt(); + final int month = scan.nextInt(); + final int day = scan.nextInt(); + final int festivalMonth = scan.nextInt(); + final int festivalDay = scan.nextInt(); + + Festival festival = new Festival(year, month, day, festivalMonth, festivalDay); + System.out.println(festival.getDayUntilFestival()); + + scan.close(); + } +} + + +class Festival { + private int year; + private int month; + private int day; + private final int festivalMonth; + private final int festivalDay; + private static final int ODD_NUMBER_MONTH_DAY = 13; // 奇数月の日数 + private static final int EVEN_NUMBER_MONTH_DAY = 15; // 偶数月の日数 + + public Festival(final int year, final int month, final int day, final int festivalMonth, final int festivalDay) { + this.year = year; + this.month = month; + this.day = day; + this.festivalMonth = festivalMonth; + this.festivalDay = festivalDay; + } + + // ある月の日数を取得するメソッド + private int getDaysOfMonth(final int month) { + if (month % 2 == 0) { + return EVEN_NUMBER_MONTH_DAY; + } + return ODD_NUMBER_MONTH_DAY; + } + + // 祭りが開催される年であるかを判定するメソッド + private boolean isFestivalYear(final int year) { + return year % 4 == 1; + } + + // 年と月をカウントアップするメソッド + private void countUpMonth() { + month++; + if (month > 13) { + month = 1; + year++; + } + } + + // 祭り開催までの残り日数を取得するメソッド + public int getDayUntilFestival() { + int tempYear = year + 1; + int dayUntilFestival = 0; + while (!isFestivalYear(tempYear)) { + tempYear++; + } + + final int festivalYear = tempYear; + + dayUntilFestival += getDaysOfMonth(month) - day; + countUpMonth(); + + while ((year != festivalYear) || (month != festivalMonth)) { + dayUntilFestival += getDaysOfMonth(month); + countUpMonth(); + } + dayUntilFestival += festivalDay; + return dayUntilFestival; + } +} diff --git a/rsuzuki/src/win.java b/rsuzuki/src/win.java new file mode 100644 index 0000000..2de39e0 --- /dev/null +++ b/rsuzuki/src/win.java @@ -0,0 +1,28 @@ +package paiza_c; + +import java.util.Scanner; + +public class win { + + public static void main(String[] args) { + // 自分の得意な言語で + // Let's チャレンジ!! + Scanner sc = new Scanner(System.in); + int N = sc.nextInt(); + String line = sc.nextLine(); + int count = 0; + for (int i = 0; i < N; i++) { + String A_N = sc.next(); + String B_N = sc.next(); + if(A_N.equals("G") && B_N.equals("C")) { + count += 1; + }else if (A_N.equals("P") && B_N.equals("G")) { + count += 1; + }else if (A_N.equals("C") && B_N.equals("P")) { + count += 1; + } + } + System.out.println(count); + } + +} diff --git a/rsuzuki/test/.gitkeep b/rsuzuki/test/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/rsuzuki/test/C069_FestivalTest.java b/rsuzuki/test/C069_FestivalTest.java new file mode 100644 index 0000000..cf883eb --- /dev/null +++ b/rsuzuki/test/C069_FestivalTest.java @@ -0,0 +1,26 @@ +package hellojunit; + +import static org.hamcrest.CoreMatchers.*; +import static org.junit.Assert.*; + +import org.junit.Test; + +public class C069_FestivalTest { + + @Test + public void 日数を取得するテスト1() { + Festival sut = new Festival(2000, 12, 10, 1, 10); + int expected = 28; + int actual = sut.getDayUntilFestival(); + assertThat(actual, is(expected)); + } + + @Test + public void 日数を取得するテスト2() { + Festival sut = new Festival(1994, 4, 8, 7, 13); + int expected = 591; + int actual = sut.getDayUntilFestival(); + assertThat(actual, is(expected)); + } + +} -- GitLab From 869bd443ea427cf5076cd72be5a4a21ea0387ca1 Mon Sep 17 00:00:00 2001 From: ryouji Date: Tue, 1 Jul 2025 11:36:31 +0900 Subject: [PATCH 02/11] =?UTF-8?q?C144=20=E3=81=98=E3=82=83=E3=82=93?= =?UTF-8?q?=E3=81=91=E3=82=93=E3=81=AE=E7=B5=90=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rsuzuki/src/.gitkeep | 0 rsuzuki/src/C069_Festival.java | 82 ------------------------- rsuzuki/src/{win.java => C144_win.java} | 3 +- rsuzuki/test/.gitkeep | 0 rsuzuki/test/C069_FestivalTest.java | 26 -------- 5 files changed, 2 insertions(+), 109 deletions(-) delete mode 100644 rsuzuki/src/.gitkeep delete mode 100644 rsuzuki/src/C069_Festival.java rename rsuzuki/src/{win.java => C144_win.java} (96%) delete mode 100644 rsuzuki/test/.gitkeep delete mode 100644 rsuzuki/test/C069_FestivalTest.java diff --git a/rsuzuki/src/.gitkeep b/rsuzuki/src/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/rsuzuki/src/C069_Festival.java b/rsuzuki/src/C069_Festival.java deleted file mode 100644 index b64383c..0000000 --- a/rsuzuki/src/C069_Festival.java +++ /dev/null @@ -1,82 +0,0 @@ -package hellojunit; - -import java.util.Scanner; - -public class C069_Festival { - - public static void main(String[] args) { - Scanner scan = new Scanner(System.in); - final int year = scan.nextInt(); - final int month = scan.nextInt(); - final int day = scan.nextInt(); - final int festivalMonth = scan.nextInt(); - final int festivalDay = scan.nextInt(); - - Festival festival = new Festival(year, month, day, festivalMonth, festivalDay); - System.out.println(festival.getDayUntilFestival()); - - scan.close(); - } -} - - -class Festival { - private int year; - private int month; - private int day; - private final int festivalMonth; - private final int festivalDay; - private static final int ODD_NUMBER_MONTH_DAY = 13; // 奇数月の日数 - private static final int EVEN_NUMBER_MONTH_DAY = 15; // 偶数月の日数 - - public Festival(final int year, final int month, final int day, final int festivalMonth, final int festivalDay) { - this.year = year; - this.month = month; - this.day = day; - this.festivalMonth = festivalMonth; - this.festivalDay = festivalDay; - } - - // ある月の日数を取得するメソッド - private int getDaysOfMonth(final int month) { - if (month % 2 == 0) { - return EVEN_NUMBER_MONTH_DAY; - } - return ODD_NUMBER_MONTH_DAY; - } - - // 祭りが開催される年であるかを判定するメソッド - private boolean isFestivalYear(final int year) { - return year % 4 == 1; - } - - // 年と月をカウントアップするメソッド - private void countUpMonth() { - month++; - if (month > 13) { - month = 1; - year++; - } - } - - // 祭り開催までの残り日数を取得するメソッド - public int getDayUntilFestival() { - int tempYear = year + 1; - int dayUntilFestival = 0; - while (!isFestivalYear(tempYear)) { - tempYear++; - } - - final int festivalYear = tempYear; - - dayUntilFestival += getDaysOfMonth(month) - day; - countUpMonth(); - - while ((year != festivalYear) || (month != festivalMonth)) { - dayUntilFestival += getDaysOfMonth(month); - countUpMonth(); - } - dayUntilFestival += festivalDay; - return dayUntilFestival; - } -} diff --git a/rsuzuki/src/win.java b/rsuzuki/src/C144_win.java similarity index 96% rename from rsuzuki/src/win.java rename to rsuzuki/src/C144_win.java index 2de39e0..315c4de 100644 --- a/rsuzuki/src/win.java +++ b/rsuzuki/src/C144_win.java @@ -2,7 +2,7 @@ package paiza_c; import java.util.Scanner; -public class win { +public class C144_win { public static void main(String[] args) { // 自分の得意な言語で @@ -25,4 +25,5 @@ public class win { System.out.println(count); } + } diff --git a/rsuzuki/test/.gitkeep b/rsuzuki/test/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/rsuzuki/test/C069_FestivalTest.java b/rsuzuki/test/C069_FestivalTest.java deleted file mode 100644 index cf883eb..0000000 --- a/rsuzuki/test/C069_FestivalTest.java +++ /dev/null @@ -1,26 +0,0 @@ -package hellojunit; - -import static org.hamcrest.CoreMatchers.*; -import static org.junit.Assert.*; - -import org.junit.Test; - -public class C069_FestivalTest { - - @Test - public void 日数を取得するテスト1() { - Festival sut = new Festival(2000, 12, 10, 1, 10); - int expected = 28; - int actual = sut.getDayUntilFestival(); - assertThat(actual, is(expected)); - } - - @Test - public void 日数を取得するテスト2() { - Festival sut = new Festival(1994, 4, 8, 7, 13); - int expected = 591; - int actual = sut.getDayUntilFestival(); - assertThat(actual, is(expected)); - } - -} -- GitLab From a4af80ddb3df7dad15c06237f9fd54042fdcafcc Mon Sep 17 00:00:00 2001 From: ryouji Date: Tue, 1 Jul 2025 17:08:52 +0900 Subject: [PATCH 03/11] =?UTF-8?q?paiza=E3=81=AE=E5=95=8F=E9=A1=8CC144=20?= =?UTF-8?q?=E3=81=98=E3=82=83=E3=82=93=E3=81=91=E3=82=93=E3=81=AE=E7=B5=90?= =?UTF-8?q?=E6=9E=9C=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rsuzuki/src/C144_win.java | 109 +++++++++++++++++++++++++++++++------- 1 file changed, 89 insertions(+), 20 deletions(-) diff --git a/rsuzuki/src/C144_win.java b/rsuzuki/src/C144_win.java index 315c4de..01397b6 100644 --- a/rsuzuki/src/C144_win.java +++ b/rsuzuki/src/C144_win.java @@ -2,28 +2,97 @@ package paiza_c; import java.util.Scanner; +enum RockPaperScissorsType { + Rock("G"), Paper("P"), Scissors("C"); + + private final String caption; + + private RockPaperScissorsType(final String caption) { + this.caption = caption; + } + + public static RockPaperScissorsType fromCaption(final String string) { + for (final RockPaperScissorsType type : values()) { + if (type.caption.equals(string)) { + return type; + } + } + return null; + } +} + +// 入力を受け取るクラス +final class Input { + private final Scanner scanner; + + public Input(final Scanner scanner) { + this.scanner = scanner; + } + + public int readGameCount() { + final int count = scanner.nextInt(); + scanner.nextLine(); + return count; + } + + public RockPaperScissorsType readHand() { + return RockPaperScissorsType.fromCaption(scanner.next()); + } +} + +// じゃんけんのロジックのクラス +final class Logic { + + public boolean Win(final RockPaperScissorsType handA, final RockPaperScissorsType handB) { + if (handA == RockPaperScissorsType.Rock && handB == RockPaperScissorsType.Scissors) { + return true; + } else if (handA == RockPaperScissorsType.Paper && handB == RockPaperScissorsType.Rock) { + return true; + } else if (handA == RockPaperScissorsType.Scissors && handB == RockPaperScissorsType.Paper) { + return true; + } + return false; + } +} + +// 結果に集計するクラス +final class Result { + private int winCount; + + public Result() { + this.winCount = 0; + } + + // 勝利数をインクリメントする + public void incrementresult() { + this.winCount++; + } + + // 現在の勝利数を取得する + public int getresult() { + return winCount; + } +} + public class C144_win { + public static void main(String[] args) { + final Scanner sc = new Scanner(System.in); + final Input input = new Input(sc); + final Logic logic = new Logic(); + final Result result = new Result(); + + final int N = input.readGameCount(); + + for (int i = 0; i < N; i++) { + final RockPaperScissorsType playerAHand = input.readHand(); + final RockPaperScissorsType playerBHand = input.readHand(); - public static void main(String[] args) { - // 自分の得意な言語で - // Let's チャレンジ!! - Scanner sc = new Scanner(System.in); - int N = sc.nextInt(); - String line = sc.nextLine(); - int count = 0; - for (int i = 0; i < N; i++) { - String A_N = sc.next(); - String B_N = sc.next(); - if(A_N.equals("G") && B_N.equals("C")) { - count += 1; - }else if (A_N.equals("P") && B_N.equals("G")) { - count += 1; - }else if (A_N.equals("C") && B_N.equals("P")) { - count += 1; - } - } - System.out.println(count); - } + if (logic.Win(playerAHand, playerBHand)) { + result.incrementresult(); + } + } + System.out.println(result.getresult()); + } } -- GitLab From 30354c4a78207f77fce2a907ba55f3feab970ceb Mon Sep 17 00:00:00 2001 From: ryouji Date: Wed, 2 Jul 2025 11:44:09 +0900 Subject: [PATCH 04/11] =?UTF-8?q?paiza=E3=81=AEC158:=E8=8A=B1=E3=81=AE?= =?UTF-8?q?=E3=83=96=E3=83=BC=E3=82=B1=E5=95=8F=E9=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rsuzuki/src/C144_win.java | 98 ------------------------------------ rsuzuki/src/C157_flower.java | 46 +++++++++++++++++ 2 files changed, 46 insertions(+), 98 deletions(-) delete mode 100644 rsuzuki/src/C144_win.java create mode 100644 rsuzuki/src/C157_flower.java diff --git a/rsuzuki/src/C144_win.java b/rsuzuki/src/C144_win.java deleted file mode 100644 index 01397b6..0000000 --- a/rsuzuki/src/C144_win.java +++ /dev/null @@ -1,98 +0,0 @@ -package paiza_c; - -import java.util.Scanner; - -enum RockPaperScissorsType { - Rock("G"), Paper("P"), Scissors("C"); - - private final String caption; - - private RockPaperScissorsType(final String caption) { - this.caption = caption; - } - - public static RockPaperScissorsType fromCaption(final String string) { - for (final RockPaperScissorsType type : values()) { - if (type.caption.equals(string)) { - return type; - } - } - return null; - } -} - -// 入力を受け取るクラス -final class Input { - private final Scanner scanner; - - public Input(final Scanner scanner) { - this.scanner = scanner; - } - - public int readGameCount() { - final int count = scanner.nextInt(); - scanner.nextLine(); - return count; - } - - public RockPaperScissorsType readHand() { - return RockPaperScissorsType.fromCaption(scanner.next()); - } -} - -// じゃんけんのロジックのクラス -final class Logic { - - public boolean Win(final RockPaperScissorsType handA, final RockPaperScissorsType handB) { - if (handA == RockPaperScissorsType.Rock && handB == RockPaperScissorsType.Scissors) { - return true; - } else if (handA == RockPaperScissorsType.Paper && handB == RockPaperScissorsType.Rock) { - return true; - } else if (handA == RockPaperScissorsType.Scissors && handB == RockPaperScissorsType.Paper) { - return true; - } - return false; - } -} - -// 結果に集計するクラス -final class Result { - private int winCount; - - public Result() { - this.winCount = 0; - } - - // 勝利数をインクリメントする - public void incrementresult() { - this.winCount++; - } - - // 現在の勝利数を取得する - public int getresult() { - return winCount; - } -} - -public class C144_win { - public static void main(String[] args) { - final Scanner sc = new Scanner(System.in); - final Input input = new Input(sc); - final Logic logic = new Logic(); - final Result result = new Result(); - - final int N = input.readGameCount(); - - for (int i = 0; i < N; i++) { - final RockPaperScissorsType playerAHand = input.readHand(); - final RockPaperScissorsType playerBHand = input.readHand(); - - if (logic.Win(playerAHand, playerBHand)) { - result.incrementresult(); - } - } - - System.out.println(result.getresult()); - - } -} diff --git a/rsuzuki/src/C157_flower.java b/rsuzuki/src/C157_flower.java new file mode 100644 index 0000000..62482fa --- /dev/null +++ b/rsuzuki/src/C157_flower.java @@ -0,0 +1,46 @@ +package paiza_c; + +import java.util.ArrayList; +import java.util.Scanner; + +/** 入力を受け取るクラス */ +final class Input { + private final Scanner scanner; + + public Input(final Scanner scanner) { + this.scanner = scanner; + } + + public int readGameCount() { + final int count = scanner.nextInt(); + scanner.nextLine(); + return count; + } + + public RockPaperScissorsType readHand() { + return RockPaperScissorsType.fromCaption(scanner.next()); + } +} + +public class C157_flower { + public static void main(String[] args) { + final Scanner sc = new Scanner(System.in); + final Input input = new Input(sc); + + final int N = input.readGameCount(); + + ArrayList flowers = new ArrayList<>(); + /** 花を格納する配列 */ + + for (int i = 0; i < N; i++) { + String a_i = sc.next(); + + if (!flowers.contains(a_i)) { + flowers.add(a_i); + } + } + + System.out.println(flowers.size()); + } + +} -- GitLab From a7557f9c7cffcd76323275e62aa99e5d8f805aa4 Mon Sep 17 00:00:00 2001 From: ryouji Date: Wed, 2 Jul 2025 14:17:30 +0900 Subject: [PATCH 05/11] =?UTF-8?q?paiza=E3=81=AEC158:=E8=8A=B1=E3=81=AE?= =?UTF-8?q?=E3=83=96=E3=83=BC=E3=82=B1=E5=95=8F=E9=A1=8Cwo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rsuzuki/src/C157_flower.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/rsuzuki/src/C157_flower.java b/rsuzuki/src/C157_flower.java index 62482fa..c390b3b 100644 --- a/rsuzuki/src/C157_flower.java +++ b/rsuzuki/src/C157_flower.java @@ -4,30 +4,26 @@ import java.util.ArrayList; import java.util.Scanner; /** 入力を受け取るクラス */ -final class Input { +final class FlowerInput { private final Scanner scanner; - public Input(final Scanner scanner) { + public FlowerInput(final Scanner scanner) { this.scanner = scanner; } - public int readGameCount() { + public int readFlowerCount() { final int count = scanner.nextInt(); scanner.nextLine(); return count; } - - public RockPaperScissorsType readHand() { - return RockPaperScissorsType.fromCaption(scanner.next()); - } } public class C157_flower { public static void main(String[] args) { final Scanner sc = new Scanner(System.in); - final Input input = new Input(sc); + final FlowerInput input = new FlowerInput(sc); - final int N = input.readGameCount(); + final int N = input.readFlowerCount(); ArrayList flowers = new ArrayList<>(); /** 花を格納する配列 */ -- GitLab From 3765802e02026129cc3f183048a861e94ad2e5be Mon Sep 17 00:00:00 2001 From: ryouji Date: Wed, 2 Jul 2025 17:27:38 +0900 Subject: [PATCH 06/11] =?UTF-8?q?paiza=E3=81=AEC158:=E8=8A=B1=E3=81=AE?= =?UTF-8?q?=E3=83=96=E3=83=BC=E3=82=B1=E5=95=8F=E9=A1=8C=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rsuzuki/src/C157_flower.java | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/rsuzuki/src/C157_flower.java b/rsuzuki/src/C157_flower.java index c390b3b..28420f1 100644 --- a/rsuzuki/src/C157_flower.java +++ b/rsuzuki/src/C157_flower.java @@ -1,6 +1,7 @@ package paiza_c; import java.util.ArrayList; +import java.util.List; import java.util.Scanner; /** 入力を受け取るクラス */ @@ -20,23 +21,27 @@ final class FlowerInput { public class C157_flower { public static void main(String[] args) { - final Scanner sc = new Scanner(System.in); - final FlowerInput input = new FlowerInput(sc); + try (final Scanner sc = new Scanner(System.in)) { - final int N = input.readFlowerCount(); + final FlowerInput input = new FlowerInput(sc); - ArrayList flowers = new ArrayList<>(); - /** 花を格納する配列 */ + /** すべての花の本数 */ + final int Flower_count = input.readFlowerCount(); - for (int i = 0; i < N; i++) { - String a_i = sc.next(); + /** 花を格納する配列 */ + List flowers = new ArrayList<>(); - if (!flowers.contains(a_i)) { - flowers.add(a_i); + for (int i = 0; i < Flower_count; i++) { + /** 花の種類 */ + String flower_type = sc.next(); + + if (!flowers.contains(flower_type)) { + flowers.add(flower_type); + } } - } - System.out.println(flowers.size()); + System.out.println(flowers.size()); + } } } -- GitLab From d0b622944b780afd6a92f3dc99edc1740acc58d4 Mon Sep 17 00:00:00 2001 From: ryouji Date: Thu, 3 Jul 2025 09:04:52 +0900 Subject: [PATCH 07/11] =?UTF-8?q?paiza=E3=81=AEC158:=E8=8A=B1=E3=81=AE?= =?UTF-8?q?=E3=83=96=E3=83=BC=E3=82=B1=E5=95=8F=E9=A1=8C=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A32?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rsuzuki/src/C157_flower.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/rsuzuki/src/C157_flower.java b/rsuzuki/src/C157_flower.java index 28420f1..319f859 100644 --- a/rsuzuki/src/C157_flower.java +++ b/rsuzuki/src/C157_flower.java @@ -5,10 +5,10 @@ import java.util.List; import java.util.Scanner; /** 入力を受け取るクラス */ -final class FlowerInput { +final class flowerInput { private final Scanner scanner; - public FlowerInput(final Scanner scanner) { + public flowerInput(final Scanner scanner) { this.scanner = scanner; } @@ -23,20 +23,20 @@ public class C157_flower { public static void main(String[] args) { try (final Scanner sc = new Scanner(System.in)) { - final FlowerInput input = new FlowerInput(sc); + final flowerInput input = new flowerInput(sc); /** すべての花の本数 */ - final int Flower_count = input.readFlowerCount(); + final int flowerCount = input.readFlowerCount(); /** 花を格納する配列 */ List flowers = new ArrayList<>(); - for (int i = 0; i < Flower_count; i++) { + for (int i = 0; i < flowerCount; i++) { /** 花の種類 */ - String flower_type = sc.next(); + String flowerType = sc.next(); - if (!flowers.contains(flower_type)) { - flowers.add(flower_type); + if (!flowers.contains(flowerType)) { + flowers.add(flowerType); } } -- GitLab From 48e9aee44669209bb17a24858bebab593a8ad470 Mon Sep 17 00:00:00 2001 From: ryouji Date: Thu, 3 Jul 2025 13:07:28 +0900 Subject: [PATCH 08/11] =?UTF-8?q?paiza=E3=81=AEC014:=E3=83=9C=E3=83=BC?= =?UTF-8?q?=E3=83=AB=E3=81=8C=E5=85=A5=E3=82=8B=E7=AE=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rsuzuki/src/C014_ball.java | 99 ++++++++++++++++++++++++++++++++++++ rsuzuki/src/C157_flower.java | 47 ----------------- 2 files changed, 99 insertions(+), 47 deletions(-) create mode 100644 rsuzuki/src/C014_ball.java delete mode 100644 rsuzuki/src/C157_flower.java diff --git a/rsuzuki/src/C014_ball.java b/rsuzuki/src/C014_ball.java new file mode 100644 index 0000000..ea7f169 --- /dev/null +++ b/rsuzuki/src/C014_ball.java @@ -0,0 +1,99 @@ +package paiza_c; + +import java.util.ArrayList; +import java.util.List; +import java.util.Scanner; + +/** 入力を受け取るクラス */ +final class BoxInput { + private final int number; + /** 箱の数 */ + private final int radius; + /** ボール半径 */ + private final int[][] boxDimensions; + + /** [箱のインデックス][高さ、幅、奥行き] */ + + public BoxInput() { + Scanner scanner = new Scanner(System.in); + this.number = scanner.nextInt(); + this.radius = scanner.nextInt(); + + this.boxDimensions = new int[number][3]; + /** 箱の大きさを格納する配列 */ + + for (int i = 0; i < number; i++) { + this.boxDimensions[i][0] = scanner.nextInt(); // 高さ + this.boxDimensions[i][1] = scanner.nextInt(); // 幅 + this.boxDimensions[i][2] = scanner.nextInt(); // 奥行き + } + } + + public int getNumber() { + return number; + } + + public int getradius() { + return radius; + } + + public int[][] getBoxDimensions() { + return boxDimensions; + } +} + +/** ロジック */ +final class BallLogic { + private int ballDimensions; + /** ボールの直径 */ + private List fitBoxnumber; + + /** ボールが入る箱を格納する配列 */ + + public BallLogic(int radius) { + this.ballDimensions = 2 * radius; + this.fitBoxnumber = new ArrayList<>(); + } + + /** 辺の中で一番小さい値とボールの直径を比較 */ + public void comparison(int number, int h, int w, int d) { + int min = Math.min(h, Math.min(w, d)); + + if (min >= ballDimensions) { + fitBoxnumber.add(number); + } + } + + /** 出力 */ + public void printNumber() { + for (int i = 0; i < fitBoxnumber.size(); i++) { + System.out.println(fitBoxnumber.get(i)); + } + } +} + +public class C014_ball { + + public static void main(String[] args) { + BoxInput input = new BoxInput(); + + final int number = input.getNumber(); + final int radius = input.getradius(); + final int[][] boxDimensions = input.getBoxDimensions(); + + final BallLogic logic = new BallLogic(radius); + + for (int i = 0; i < number; i++) { + int boxnumber = i + 1; + int h = boxDimensions[i][0]; + int w = boxDimensions[i][1]; + int d = boxDimensions[i][2]; + + logic.comparison(boxnumber, h, w, d); + } + + logic.printNumber(); + + } + +} diff --git a/rsuzuki/src/C157_flower.java b/rsuzuki/src/C157_flower.java deleted file mode 100644 index 319f859..0000000 --- a/rsuzuki/src/C157_flower.java +++ /dev/null @@ -1,47 +0,0 @@ -package paiza_c; - -import java.util.ArrayList; -import java.util.List; -import java.util.Scanner; - -/** 入力を受け取るクラス */ -final class flowerInput { - private final Scanner scanner; - - public flowerInput(final Scanner scanner) { - this.scanner = scanner; - } - - public int readFlowerCount() { - final int count = scanner.nextInt(); - scanner.nextLine(); - return count; - } -} - -public class C157_flower { - public static void main(String[] args) { - try (final Scanner sc = new Scanner(System.in)) { - - final flowerInput input = new flowerInput(sc); - - /** すべての花の本数 */ - final int flowerCount = input.readFlowerCount(); - - /** 花を格納する配列 */ - List flowers = new ArrayList<>(); - - for (int i = 0; i < flowerCount; i++) { - /** 花の種類 */ - String flowerType = sc.next(); - - if (!flowers.contains(flowerType)) { - flowers.add(flowerType); - } - } - - System.out.println(flowers.size()); - } - } - -} -- GitLab From e8247a0d3a8bae3d18942d915c7dd38f0262f679 Mon Sep 17 00:00:00 2001 From: ryouji Date: Thu, 3 Jul 2025 15:22:55 +0900 Subject: [PATCH 09/11] =?UTF-8?q?paiza=E3=81=AEC021:=E6=9A=B4=E9=A2=A8?= =?UTF-8?q?=E5=9F=9F=E3=81=AE=E4=B8=AD=E3=81=AB=E3=81=84=E3=81=BE=E3=81=99?= =?UTF-8?q?=E3=81=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rsuzuki/src/C014_ball.java | 99 ----------------------------- rsuzuki/src/C021_storm.java | 120 ++++++++++++++++++++++++++++++++++++ 2 files changed, 120 insertions(+), 99 deletions(-) delete mode 100644 rsuzuki/src/C014_ball.java create mode 100644 rsuzuki/src/C021_storm.java diff --git a/rsuzuki/src/C014_ball.java b/rsuzuki/src/C014_ball.java deleted file mode 100644 index ea7f169..0000000 --- a/rsuzuki/src/C014_ball.java +++ /dev/null @@ -1,99 +0,0 @@ -package paiza_c; - -import java.util.ArrayList; -import java.util.List; -import java.util.Scanner; - -/** 入力を受け取るクラス */ -final class BoxInput { - private final int number; - /** 箱の数 */ - private final int radius; - /** ボール半径 */ - private final int[][] boxDimensions; - - /** [箱のインデックス][高さ、幅、奥行き] */ - - public BoxInput() { - Scanner scanner = new Scanner(System.in); - this.number = scanner.nextInt(); - this.radius = scanner.nextInt(); - - this.boxDimensions = new int[number][3]; - /** 箱の大きさを格納する配列 */ - - for (int i = 0; i < number; i++) { - this.boxDimensions[i][0] = scanner.nextInt(); // 高さ - this.boxDimensions[i][1] = scanner.nextInt(); // 幅 - this.boxDimensions[i][2] = scanner.nextInt(); // 奥行き - } - } - - public int getNumber() { - return number; - } - - public int getradius() { - return radius; - } - - public int[][] getBoxDimensions() { - return boxDimensions; - } -} - -/** ロジック */ -final class BallLogic { - private int ballDimensions; - /** ボールの直径 */ - private List fitBoxnumber; - - /** ボールが入る箱を格納する配列 */ - - public BallLogic(int radius) { - this.ballDimensions = 2 * radius; - this.fitBoxnumber = new ArrayList<>(); - } - - /** 辺の中で一番小さい値とボールの直径を比較 */ - public void comparison(int number, int h, int w, int d) { - int min = Math.min(h, Math.min(w, d)); - - if (min >= ballDimensions) { - fitBoxnumber.add(number); - } - } - - /** 出力 */ - public void printNumber() { - for (int i = 0; i < fitBoxnumber.size(); i++) { - System.out.println(fitBoxnumber.get(i)); - } - } -} - -public class C014_ball { - - public static void main(String[] args) { - BoxInput input = new BoxInput(); - - final int number = input.getNumber(); - final int radius = input.getradius(); - final int[][] boxDimensions = input.getBoxDimensions(); - - final BallLogic logic = new BallLogic(radius); - - for (int i = 0; i < number; i++) { - int boxnumber = i + 1; - int h = boxDimensions[i][0]; - int w = boxDimensions[i][1]; - int d = boxDimensions[i][2]; - - logic.comparison(boxnumber, h, w, d); - } - - logic.printNumber(); - - } - -} diff --git a/rsuzuki/src/C021_storm.java b/rsuzuki/src/C021_storm.java new file mode 100644 index 0000000..333f292 --- /dev/null +++ b/rsuzuki/src/C021_storm.java @@ -0,0 +1,120 @@ +package paiza_c; + +import java.util.ArrayList; +import java.util.List; +import java.util.Scanner; + +/** 入力を受け取るクラス */ +final class stormInput { + /** 円の中心座標(xc,yc) */ + private final int xc; + private final int yc; + /** 半径 */ + private final int r_1; + private final int r_2; + /** 人の数 */ + private final int N; + + /** 複数のx座標,y座標を格納する */ + private final List x_N; + private final List y_N; + + public stormInput() { + Scanner scanner = new Scanner(System.in); + + this.xc = scanner.nextInt(); + this.yc = scanner.nextInt(); + this.r_1 = scanner.nextInt(); + this.r_2 = scanner.nextInt(); + this.N = scanner.nextInt(); + this.x_N = new ArrayList<>(); + this.y_N = new ArrayList<>(); + + /** N番目の人の座標を格納 */ + for (int i = 0; i < N; i++) { + this.x_N.add(scanner.nextInt()); + this.y_N.add(scanner.nextInt()); + } + } + + public int getXC() { + return xc; + } + + public int getYC() { + return yc; + } + + public int getR_1() { + return r_1; + } + + public int getR_2() { + return r_2; + } + + public int getN() { + return N; + } + + public List getX_N() { + return x_N; + } + + public List getY_N() { + return y_N; + } + +} + +/** ロジック */ +final class stormLogic { + /** 暴風域の中心から人物までの距離の2乗 */ + private int distanceStorm; + /** 半径の2乗 */ + private int radius_1; + private int radius_2; + + public stormLogic(int xc, int yc, int r_1, int r_2, int X_N, int Y_N) { + this.distanceStorm = (X_N - xc) * (X_N - xc) + (Y_N - yc) * (Y_N - yc); + this.radius_1 = r_1 * r_1; + this.radius_2 = r_2 * r_2; + } + + /** 台風の暴風域にいるかどうか */ + public boolean range() { + if (radius_1 <= distanceStorm && distanceStorm <= radius_2) { + return true; + } + return false; + } + +} + +public class C021_storm { + public static void main(String[] args) { + stormInput input = new stormInput(); + + final int xc = input.getXC(); + final int yc = input.getYC(); + final int r_1 = input.getR_1(); + final int r_2 = input.getR_2(); + final int N = input.getN(); + final List x_N = input.getX_N(); + final List y_N = input.getY_N(); + + for (int i = 0; i < N; i++) { + int X_N = x_N.get(i); + int Y_N = y_N.get(i); + + stormLogic logic = new stormLogic(xc, yc, r_1, r_2, X_N, Y_N); + + if (logic.range()) { + System.out.println("yes"); + } else { + System.out.println("no"); + } + } + + } +} -- GitLab From 39499f00978645f67dbc96c697b5a8245f847701 Mon Sep 17 00:00:00 2001 From: ryouji Date: Thu, 3 Jul 2025 15:24:19 +0900 Subject: [PATCH 10/11] =?UTF-8?q?paiza=E3=81=AEC014:=E3=83=9C=E3=83=BC?= =?UTF-8?q?=E3=83=AB=E3=81=8C=E5=85=A5=E3=82=8B=E7=AE=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rsuzuki/src/C014_ball.java | 99 +++++++++++++++++++++++++++++ rsuzuki/src/C021_storm.java | 120 ------------------------------------ 2 files changed, 99 insertions(+), 120 deletions(-) create mode 100644 rsuzuki/src/C014_ball.java delete mode 100644 rsuzuki/src/C021_storm.java diff --git a/rsuzuki/src/C014_ball.java b/rsuzuki/src/C014_ball.java new file mode 100644 index 0000000..ea7f169 --- /dev/null +++ b/rsuzuki/src/C014_ball.java @@ -0,0 +1,99 @@ +package paiza_c; + +import java.util.ArrayList; +import java.util.List; +import java.util.Scanner; + +/** 入力を受け取るクラス */ +final class BoxInput { + private final int number; + /** 箱の数 */ + private final int radius; + /** ボール半径 */ + private final int[][] boxDimensions; + + /** [箱のインデックス][高さ、幅、奥行き] */ + + public BoxInput() { + Scanner scanner = new Scanner(System.in); + this.number = scanner.nextInt(); + this.radius = scanner.nextInt(); + + this.boxDimensions = new int[number][3]; + /** 箱の大きさを格納する配列 */ + + for (int i = 0; i < number; i++) { + this.boxDimensions[i][0] = scanner.nextInt(); // 高さ + this.boxDimensions[i][1] = scanner.nextInt(); // 幅 + this.boxDimensions[i][2] = scanner.nextInt(); // 奥行き + } + } + + public int getNumber() { + return number; + } + + public int getradius() { + return radius; + } + + public int[][] getBoxDimensions() { + return boxDimensions; + } +} + +/** ロジック */ +final class BallLogic { + private int ballDimensions; + /** ボールの直径 */ + private List fitBoxnumber; + + /** ボールが入る箱を格納する配列 */ + + public BallLogic(int radius) { + this.ballDimensions = 2 * radius; + this.fitBoxnumber = new ArrayList<>(); + } + + /** 辺の中で一番小さい値とボールの直径を比較 */ + public void comparison(int number, int h, int w, int d) { + int min = Math.min(h, Math.min(w, d)); + + if (min >= ballDimensions) { + fitBoxnumber.add(number); + } + } + + /** 出力 */ + public void printNumber() { + for (int i = 0; i < fitBoxnumber.size(); i++) { + System.out.println(fitBoxnumber.get(i)); + } + } +} + +public class C014_ball { + + public static void main(String[] args) { + BoxInput input = new BoxInput(); + + final int number = input.getNumber(); + final int radius = input.getradius(); + final int[][] boxDimensions = input.getBoxDimensions(); + + final BallLogic logic = new BallLogic(radius); + + for (int i = 0; i < number; i++) { + int boxnumber = i + 1; + int h = boxDimensions[i][0]; + int w = boxDimensions[i][1]; + int d = boxDimensions[i][2]; + + logic.comparison(boxnumber, h, w, d); + } + + logic.printNumber(); + + } + +} diff --git a/rsuzuki/src/C021_storm.java b/rsuzuki/src/C021_storm.java deleted file mode 100644 index 333f292..0000000 --- a/rsuzuki/src/C021_storm.java +++ /dev/null @@ -1,120 +0,0 @@ -package paiza_c; - -import java.util.ArrayList; -import java.util.List; -import java.util.Scanner; - -/** 入力を受け取るクラス */ -final class stormInput { - /** 円の中心座標(xc,yc) */ - private final int xc; - private final int yc; - /** 半径 */ - private final int r_1; - private final int r_2; - /** 人の数 */ - private final int N; - - /** 複数のx座標,y座標を格納する */ - private final List x_N; - private final List y_N; - - public stormInput() { - Scanner scanner = new Scanner(System.in); - - this.xc = scanner.nextInt(); - this.yc = scanner.nextInt(); - this.r_1 = scanner.nextInt(); - this.r_2 = scanner.nextInt(); - this.N = scanner.nextInt(); - this.x_N = new ArrayList<>(); - this.y_N = new ArrayList<>(); - - /** N番目の人の座標を格納 */ - for (int i = 0; i < N; i++) { - this.x_N.add(scanner.nextInt()); - this.y_N.add(scanner.nextInt()); - } - } - - public int getXC() { - return xc; - } - - public int getYC() { - return yc; - } - - public int getR_1() { - return r_1; - } - - public int getR_2() { - return r_2; - } - - public int getN() { - return N; - } - - public List getX_N() { - return x_N; - } - - public List getY_N() { - return y_N; - } - -} - -/** ロジック */ -final class stormLogic { - /** 暴風域の中心から人物までの距離の2乗 */ - private int distanceStorm; - /** 半径の2乗 */ - private int radius_1; - private int radius_2; - - public stormLogic(int xc, int yc, int r_1, int r_2, int X_N, int Y_N) { - this.distanceStorm = (X_N - xc) * (X_N - xc) + (Y_N - yc) * (Y_N - yc); - this.radius_1 = r_1 * r_1; - this.radius_2 = r_2 * r_2; - } - - /** 台風の暴風域にいるかどうか */ - public boolean range() { - if (radius_1 <= distanceStorm && distanceStorm <= radius_2) { - return true; - } - return false; - } - -} - -public class C021_storm { - public static void main(String[] args) { - stormInput input = new stormInput(); - - final int xc = input.getXC(); - final int yc = input.getYC(); - final int r_1 = input.getR_1(); - final int r_2 = input.getR_2(); - final int N = input.getN(); - final List x_N = input.getX_N(); - final List y_N = input.getY_N(); - - for (int i = 0; i < N; i++) { - int X_N = x_N.get(i); - int Y_N = y_N.get(i); - - stormLogic logic = new stormLogic(xc, yc, r_1, r_2, X_N, Y_N); - - if (logic.range()) { - System.out.println("yes"); - } else { - System.out.println("no"); - } - } - - } -} -- GitLab From 31cf35e7a8738bd5625d174e0a400736a3c8674c Mon Sep 17 00:00:00 2001 From: ryouji Date: Thu, 3 Jul 2025 17:50:31 +0900 Subject: [PATCH 11/11] =?UTF-8?q?paiza=E3=81=AEC014:=E3=83=9C=E3=83=BC?= =?UTF-8?q?=E3=83=AB=E3=81=8C=E5=85=A5=E3=82=8B=E7=AE=B1=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rsuzuki/src/C014_ball.java | 76 +++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/rsuzuki/src/C014_ball.java b/rsuzuki/src/C014_ball.java index ea7f169..1da654b 100644 --- a/rsuzuki/src/C014_ball.java +++ b/rsuzuki/src/C014_ball.java @@ -4,37 +4,27 @@ import java.util.ArrayList; import java.util.List; import java.util.Scanner; -/** 入力を受け取るクラス */ -final class BoxInput { - private final int number; +/** 箱とボールのデータを保持するクラス */ +final class BoxData { /** 箱の数 */ - private final int radius; + private final int boxNumber; /** ボール半径 */ - private final int[][] boxDimensions; - + private final int ballRadius; /** [箱のインデックス][高さ、幅、奥行き] */ + private final int[][] boxDimensions; - public BoxInput() { - Scanner scanner = new Scanner(System.in); - this.number = scanner.nextInt(); - this.radius = scanner.nextInt(); - - this.boxDimensions = new int[number][3]; - /** 箱の大きさを格納する配列 */ - - for (int i = 0; i < number; i++) { - this.boxDimensions[i][0] = scanner.nextInt(); // 高さ - this.boxDimensions[i][1] = scanner.nextInt(); // 幅 - this.boxDimensions[i][2] = scanner.nextInt(); // 奥行き - } + public BoxData(int boxNumber, int ballRadius, int[][] boxDimensions) { + this.boxNumber = boxNumber; + this.ballRadius = ballRadius; + this.boxDimensions = boxDimensions; } - public int getNumber() { - return number; + public int getBoxNumber() { + return boxNumber; } - public int getradius() { - return radius; + public int getBallRadius() { + return ballRadius; } public int[][] getBoxDimensions() { @@ -44,11 +34,10 @@ final class BoxInput { /** ロジック */ final class BallLogic { - private int ballDimensions; /** ボールの直径 */ - private List fitBoxnumber; - + private int ballDimensions; /** ボールが入る箱を格納する配列 */ + private List fitBoxnumber; public BallLogic(int radius) { this.ballDimensions = 2 * radius; @@ -56,8 +45,8 @@ final class BallLogic { } /** 辺の中で一番小さい値とボールの直径を比較 */ - public void comparison(int number, int h, int w, int d) { - int min = Math.min(h, Math.min(w, d)); + public void compare(int number, int height, int width, int depth) { + int min = Math.min(height, Math.min(width, depth)); if (min >= ballDimensions) { fitBoxnumber.add(number); @@ -75,21 +64,32 @@ final class BallLogic { public class C014_ball { public static void main(String[] args) { - BoxInput input = new BoxInput(); + Scanner scanner = new Scanner(System.in); + + int boxNumber = scanner.nextInt(); + int ballRadius = scanner.nextInt(); + + int[][] boxDimensions = new int[boxNumber][3]; + + for (int i = 0; i < boxNumber; i++) { + boxDimensions[i][0] = scanner.nextInt(); // 高さ + boxDimensions[i][1] = scanner.nextInt(); // 幅 + boxDimensions[i][2] = scanner.nextInt(); // 奥行き + } + scanner.close(); - final int number = input.getNumber(); - final int radius = input.getradius(); - final int[][] boxDimensions = input.getBoxDimensions(); + /** データを保持するクラスにセット */ + BoxData boxData = new BoxData(boxNumber, ballRadius, boxDimensions); - final BallLogic logic = new BallLogic(radius); + final BallLogic logic = new BallLogic(ballRadius); - for (int i = 0; i < number; i++) { + for (int i = 0; i < boxData.getBoxNumber(); i++) { int boxnumber = i + 1; - int h = boxDimensions[i][0]; - int w = boxDimensions[i][1]; - int d = boxDimensions[i][2]; + int height = boxDimensions[i][0]; + int width = boxDimensions[i][1]; + int depth = boxDimensions[i][2]; - logic.comparison(boxnumber, h, w, d); + logic.compare(boxnumber, height, width, depth); } logic.printNumber(); -- GitLab