diff --git a/.classpath b/.classpath new file mode 100644 index 0000000000000000000000000000000000000000..35d3fa42f80f0d40a28bdc980987136314a57e7e --- /dev/null +++ b/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..ae3c1726048cd06b9a143e0376ed46dd9b9a8d53 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/.project b/.project new file mode 100644 index 0000000000000000000000000000000000000000..9d211bd2dcf57dd36015a47a551e29f7356cc51c --- /dev/null +++ b/.project @@ -0,0 +1,17 @@ + + + paiza + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/htabuchi/.classpath b/htabuchi/.classpath new file mode 100644 index 0000000000000000000000000000000000000000..ac37fb2e4bca5ec7510383d7e55ea7b6b759e05a --- /dev/null +++ b/htabuchi/.classpath @@ -0,0 +1,5 @@ + + + + + diff --git a/htabuchi/.project b/htabuchi/.project new file mode 100644 index 0000000000000000000000000000000000000000..c36ea14b5a36b62d321420fd82e7284e222278d7 --- /dev/null +++ b/htabuchi/.project @@ -0,0 +1,17 @@ + + + htabuchi + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/htabuchi/src/C166_htabuchi.java b/htabuchi/src/C166_htabuchi.java new file mode 100644 index 0000000000000000000000000000000000000000..ccec5a6c1e89a0fe397628f57f6a2a929f5cb210 --- /dev/null +++ b/htabuchi/src/C166_htabuchi.java @@ -0,0 +1,44 @@ +/** + * Paiza問題C166:ちょうどの支払い
+ * 修正2025/07/01 13:40 + * + * @author 田渕日奈子 + * @version 1.1 + */ + +import java.util.Scanner; + +public class C166_htabuchi { + public static int countCoin(int price) { + /** それぞれのコインの値から枚数を算出 */ + + int[] coinData = {/** コインの種類 */ + 500, 100, 50, 10, 5, 1 + }; + int sumCoin = 0; + + for (int coin : coinData) { + sumCoin += countCoinNum(price, coin); + price = calcRestOfPrice(price, coin); + } + return sumCoin; + } + + public static int countCoinNum(int sum, int coin) { + return sum / coin; + } + + public static int calcRestOfPrice(int sum, int coin) { + return sum % coin; + } + + public static void main(String[] args) { + /** 金額から必要なコインの枚数の最小値を表示 */ + Scanner sc = new Scanner(System.in); + int price = sc.nextInt(); + + System.out.println(countCoin(price)); + + sc.close(); + } +}