From 70364ac2a7bc1e8c24208ca38b7d67e28834092d Mon Sep 17 00:00:00 2001 From: kurisu Date: Mon, 30 Jun 2025 17:09:15 +0900 Subject: [PATCH 1/4] =?UTF-8?q?paiza=E3=81=A7C166=E3=82=92=E8=A7=A3?= =?UTF-8?q?=E3=81=8D=E3=81=BE=E3=81=97=E3=81=9F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kurisu/src/C166_JustPay.java | 49 ++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 kurisu/src/C166_JustPay.java diff --git a/kurisu/src/C166_JustPay.java b/kurisu/src/C166_JustPay.java new file mode 100644 index 0000000..c880641 --- /dev/null +++ b/kurisu/src/C166_JustPay.java @@ -0,0 +1,49 @@ +import java.util.Scanner; + +public class C166_JustPay { + + static int coinCounting(int remaining) { + int total_coin = 0; + while (remaining != 0) { + if (remaining >= 500) { + remaining = calcRemaining(remaining, 500); + } else if (remaining >= 100) { + remaining = calcRemaining(remaining, 100); + } else if (remaining >= 50) { + remaining = calcRemaining(remaining, 50); + } else if (remaining >= 10) { + remaining = calcRemaining(remaining, 10); + } else if (remaining >= 5) { + remaining = calcRemaining(remaining, 5); + } else { + total_coin += remaining; + remaining = 0; + break; + } + total_coin++; + } + return total_coin; + } + + static int calcRemaining(int money, int prise) { + // 数えた硬貨の値段に応じて残金を減らす + return money = money - prise; + } + + public static void main(String[] args) { + // 自分の得意な言語で + // Let's チャレンジ!! + Scanner sc = new Scanner(System.in); + String line = sc.nextLine(); + + // String型をint型に変換 + int money = Integer.parseInt(line); + + // 合計硬貨数を計算 + int total_coin = coinCounting(money); + + System.out.println(total_coin); + + sc.close(); + } +} \ No newline at end of file -- GitLab From a168fb765776252416789631ce77ac4bd3ebdd27 Mon Sep 17 00:00:00 2001 From: kurisu Date: Tue, 1 Jul 2025 15:11:08 +0900 Subject: [PATCH 2/4] =?UTF-8?q?paiza=E3=81=A7C166=E3=82=92=E8=A7=A3?= =?UTF-8?q?=E3=81=8D=E3=81=BE=E3=81=97=E3=81=9F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kurisu/src/C166_JustPay.java | 66 +++++++++++++++++------------------- 1 file changed, 31 insertions(+), 35 deletions(-) diff --git a/kurisu/src/C166_JustPay.java b/kurisu/src/C166_JustPay.java index c880641..0a9b9f5 100644 --- a/kurisu/src/C166_JustPay.java +++ b/kurisu/src/C166_JustPay.java @@ -1,49 +1,45 @@ import java.util.Scanner; -public class C166_JustPay { - - static int coinCounting(int remaining) { - int total_coin = 0; - while (remaining != 0) { - if (remaining >= 500) { - remaining = calcRemaining(remaining, 500); - } else if (remaining >= 100) { - remaining = calcRemaining(remaining, 100); - } else if (remaining >= 50) { - remaining = calcRemaining(remaining, 50); - } else if (remaining >= 10) { - remaining = calcRemaining(remaining, 10); - } else if (remaining >= 5) { - remaining = calcRemaining(remaining, 5); - } else { - total_coin += remaining; - remaining = 0; - break; - } - total_coin++; - } - return total_coin; +enum Coin { + COIN_500(500), + COIN_100(100), + COIN_50(50), + COIN_10(10), + COIN_5(5), + COIN_1(1); + + private int money; + + Coin(int money){ + this.money = money; } - - static int calcRemaining(int money, int prise) { - // 数えた硬貨の値段に応じて残金を減らす - return money = money - prise; + + public int getValue() { + return money; } +} + +class countCoin{ + private int total_coin = 0; + countCoin(int remainingamount){ + for (Coin coin : Coin.values()) { + total_coin += remainingamount / coin.getValue(); + remainingamount %= coin.getValue(); + } + System.out.println(total_coin); + } +} +public class C166_JustPay { public static void main(String[] args) { - // 自分の得意な言語で - // Let's チャレンジ!! Scanner sc = new Scanner(System.in); String line = sc.nextLine(); // String型をint型に変換 - int money = Integer.parseInt(line); - - // 合計硬貨数を計算 - int total_coin = coinCounting(money); - - System.out.println(total_coin); + final int money = Integer.parseInt(line); + new countCoin(money); + sc.close(); } } \ No newline at end of file -- GitLab From 252be59a2162ac7cf56de1af804102788f929569 Mon Sep 17 00:00:00 2001 From: kurisu Date: Tue, 1 Jul 2025 15:29:41 +0900 Subject: [PATCH 3/4] =?UTF-8?q?Revert=20"paiza=E3=81=A7C166=E3=82=92?= =?UTF-8?q?=E8=A7=A3=E3=81=8D=E3=81=BE=E3=81=97=E3=81=9F=E3=80=82"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit a168fb765776252416789631ce77ac4bd3ebdd27. --- kurisu/src/C166_JustPay.java | 66 +++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 31 deletions(-) diff --git a/kurisu/src/C166_JustPay.java b/kurisu/src/C166_JustPay.java index 0a9b9f5..c880641 100644 --- a/kurisu/src/C166_JustPay.java +++ b/kurisu/src/C166_JustPay.java @@ -1,45 +1,49 @@ import java.util.Scanner; -enum Coin { - COIN_500(500), - COIN_100(100), - COIN_50(50), - COIN_10(10), - COIN_5(5), - COIN_1(1); - - private int money; - - Coin(int money){ - this.money = money; - } - - public int getValue() { - return money; - } -} - -class countCoin{ - private int total_coin = 0; - countCoin(int remainingamount){ - for (Coin coin : Coin.values()) { - total_coin += remainingamount / coin.getValue(); - remainingamount %= coin.getValue(); +public class C166_JustPay { + + static int coinCounting(int remaining) { + int total_coin = 0; + while (remaining != 0) { + if (remaining >= 500) { + remaining = calcRemaining(remaining, 500); + } else if (remaining >= 100) { + remaining = calcRemaining(remaining, 100); + } else if (remaining >= 50) { + remaining = calcRemaining(remaining, 50); + } else if (remaining >= 10) { + remaining = calcRemaining(remaining, 10); + } else if (remaining >= 5) { + remaining = calcRemaining(remaining, 5); + } else { + total_coin += remaining; + remaining = 0; + break; + } + total_coin++; } - System.out.println(total_coin); + return total_coin; + } + + static int calcRemaining(int money, int prise) { + // 数えた硬貨の値段に応じて残金を減らす + return money = money - prise; } -} -public class C166_JustPay { public static void main(String[] args) { + // 自分の得意な言語で + // Let's チャレンジ!! Scanner sc = new Scanner(System.in); String line = sc.nextLine(); // String型をint型に変換 - final int money = Integer.parseInt(line); + int money = Integer.parseInt(line); + + // 合計硬貨数を計算 + int total_coin = coinCounting(money); + + System.out.println(total_coin); - new countCoin(money); - sc.close(); } } \ No newline at end of file -- GitLab From 9b80ee1467a4223cd1cf24661deb62d7beee7efd Mon Sep 17 00:00:00 2001 From: kurisu Date: Wed, 2 Jul 2025 14:35:43 +0900 Subject: [PATCH 4/4] =?UTF-8?q?paiza=E3=81=AEC166=E3=81=AE=E4=BF=AE?= =?UTF-8?q?=E6=AD=A32=E5=9B=9E=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kurisu/src/C116.java | 49 +++++++++++++++++++++++++ kurisu/src/C166_JustPay.java | 71 +++++++++++++++++++----------------- 2 files changed, 86 insertions(+), 34 deletions(-) create mode 100644 kurisu/src/C116.java diff --git a/kurisu/src/C116.java b/kurisu/src/C116.java new file mode 100644 index 0000000..2bfd2a2 --- /dev/null +++ b/kurisu/src/C116.java @@ -0,0 +1,49 @@ +import java.util.Scanner; + +class Check_stick { + private int consective_mark = 0; + private boolean wrong_flag = false; + + Check_stick() {} + + //外れ棒の連続回数が指定回数より上回ればフラグをtrue、それ以外はfalseを返す + boolean inspectionStick(int stick, int wrong_rod, Scanner sc) { + for(int i = 0; i < stick; i++){ + int stick_result = sc.nextInt(); + + if(consective_mark < wrong_rod) { + if(stick_result == 0){//外れが連続すればカウントしていく + consective_mark++; + }else if(stick_result != 0) {//連続が途切れた場合カウントを最初からやり直す + consective_mark = 0; + } + } + if(consective_mark >= wrong_rod) { + wrong_flag = true; + } + } + return wrong_flag; + } +} + +class Show_result { + Show_result(boolean inspect_result) { + if(inspect_result == true) { + System.out.println("NG"); + }else { + System.out.println("OK"); + } + } +} + +public class C116 { + public static void main(String[] args ) throws Exception { + Scanner sc = new Scanner(System.in); + final int ice_stick = sc.nextInt(); + final int wrong_rod = sc.nextInt(); + Check_stick result_flag = new Check_stick(); + final boolean inspect_result = result_flag.inspectionStick(ice_stick, wrong_rod, sc); + new Show_result(inspect_result); + sc.close(); + } +} \ No newline at end of file diff --git a/kurisu/src/C166_JustPay.java b/kurisu/src/C166_JustPay.java index c880641..1d8ac4f 100644 --- a/kurisu/src/C166_JustPay.java +++ b/kurisu/src/C166_JustPay.java @@ -1,49 +1,52 @@ import java.util.Scanner; -public class C166_JustPay { +enum Coin { + COIN_500(500), + COIN_100(100), + COIN_50(50), + COIN_10(10), + COIN_5(5), + COIN_1(1); + + private final int money; + + Coin(int money) { + this.money = money; + } - static int coinCounting(int remaining) { - int total_coin = 0; - while (remaining != 0) { - if (remaining >= 500) { - remaining = calcRemaining(remaining, 500); - } else if (remaining >= 100) { - remaining = calcRemaining(remaining, 100); - } else if (remaining >= 50) { - remaining = calcRemaining(remaining, 50); - } else if (remaining >= 10) { - remaining = calcRemaining(remaining, 10); - } else if (remaining >= 5) { - remaining = calcRemaining(remaining, 5); - } else { - total_coin += remaining; - remaining = 0; - break; - } - total_coin++; - } - return total_coin; + public int getMoney() { + return money; } +} + + +class CoinCounter { + private int totalcoin = 0; - static int calcRemaining(int money, int prise) { - // 数えた硬貨の値段に応じて残金を減らす - return money = money - prise; + CoinCounter() {} + + final int countCoin(int remainingamount) { + for (Coin coin : Coin.values()) { + totalcoin += remainingamount / coin.getMoney(); + remainingamount %= coin.getMoney(); + } + return totalcoin; } +} + +public class C166_JustPay { public static void main(String[] args) { - // 自分の得意な言語で - // Let's チャレンジ!! - Scanner sc = new Scanner(System.in); - String line = sc.nextLine(); + final Scanner sc = new Scanner(System.in); + final String line = sc.nextLine(); // String型をint型に変換 - int money = Integer.parseInt(line); + final int money = Integer.parseInt(line); - // 合計硬貨数を計算 - int total_coin = coinCounting(money); + final CoinCounter coinCounter = new CoinCounter(); - System.out.println(total_coin); + System.out.print(coinCounter.countCoin(money)); sc.close(); } -} \ No newline at end of file +} -- GitLab