結果

問題 No.634 硬貨の枚数1
ユーザー GrenacheGrenache
提出日時 2018-01-20 21:16:04
言語 Java21
(openjdk 21)
結果
AC  
実行時間 144 ms / 2,000 ms
コード長 809 bytes
コンパイル時間 5,484 ms
コンパイル使用メモリ 73,216 KB
実行使用メモリ 58,224 KB
最終ジャッジ日時 2023-08-26 19:28:22
合計ジャッジ時間 16,200 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
55,856 KB
testcase_01 AC 112 ms
55,456 KB
testcase_02 AC 116 ms
55,812 KB
testcase_03 AC 112 ms
56,508 KB
testcase_04 AC 113 ms
55,760 KB
testcase_05 AC 115 ms
56,280 KB
testcase_06 AC 111 ms
55,732 KB
testcase_07 AC 111 ms
56,016 KB
testcase_08 AC 114 ms
56,008 KB
testcase_09 AC 113 ms
55,720 KB
testcase_10 AC 114 ms
55,900 KB
testcase_11 AC 119 ms
55,868 KB
testcase_12 AC 117 ms
55,660 KB
testcase_13 AC 117 ms
56,112 KB
testcase_14 AC 119 ms
55,632 KB
testcase_15 AC 142 ms
55,608 KB
testcase_16 AC 119 ms
56,032 KB
testcase_17 AC 117 ms
56,124 KB
testcase_18 AC 116 ms
55,708 KB
testcase_19 AC 141 ms
54,248 KB
testcase_20 AC 135 ms
56,032 KB
testcase_21 AC 136 ms
55,764 KB
testcase_22 AC 138 ms
55,808 KB
testcase_23 AC 118 ms
55,836 KB
testcase_24 AC 111 ms
56,348 KB
testcase_25 AC 112 ms
58,224 KB
testcase_26 AC 113 ms
55,848 KB
testcase_27 AC 114 ms
55,876 KB
testcase_28 AC 113 ms
56,392 KB
testcase_29 AC 115 ms
56,284 KB
testcase_30 AC 115 ms
55,932 KB
testcase_31 AC 118 ms
56,216 KB
testcase_32 AC 112 ms
56,304 KB
testcase_33 AC 112 ms
55,352 KB
testcase_34 AC 113 ms
55,680 KB
testcase_35 AC 117 ms
56,148 KB
testcase_36 AC 125 ms
56,352 KB
testcase_37 AC 124 ms
57,636 KB
testcase_38 AC 116 ms
56,080 KB
testcase_39 AC 143 ms
56,100 KB
testcase_40 AC 116 ms
55,764 KB
testcase_41 AC 113 ms
55,848 KB
testcase_42 AC 128 ms
56,208 KB
testcase_43 AC 127 ms
55,652 KB
testcase_44 AC 123 ms
56,268 KB
testcase_45 AC 127 ms
55,764 KB
testcase_46 AC 116 ms
56,056 KB
testcase_47 AC 136 ms
55,972 KB
testcase_48 AC 110 ms
56,148 KB
testcase_49 AC 119 ms
55,936 KB
testcase_50 AC 133 ms
55,860 KB
testcase_51 AC 118 ms
55,708 KB
testcase_52 AC 113 ms
55,816 KB
testcase_53 AC 117 ms
55,896 KB
testcase_54 AC 112 ms
56,124 KB
testcase_55 AC 143 ms
56,164 KB
testcase_56 AC 140 ms
56,148 KB
testcase_57 AC 139 ms
56,076 KB
testcase_58 AC 138 ms
55,608 KB
testcase_59 AC 136 ms
55,892 KB
testcase_60 AC 130 ms
55,612 KB
testcase_61 AC 142 ms
55,608 KB
testcase_62 AC 143 ms
56,124 KB
testcase_63 AC 140 ms
55,964 KB
testcase_64 AC 141 ms
55,940 KB
testcase_65 AC 144 ms
56,152 KB
testcase_66 AC 142 ms
55,816 KB
testcase_67 AC 141 ms
55,668 KB
testcase_68 AC 144 ms
56,052 KB
testcase_69 AC 129 ms
56,104 KB
testcase_70 AC 133 ms
57,480 KB
testcase_71 AC 141 ms
56,376 KB
testcase_72 AC 144 ms
56,216 KB
testcase_73 AC 137 ms
56,036 KB
testcase_74 AC 141 ms
56,320 KB
testcase_75 AC 135 ms
56,296 KB
testcase_76 AC 117 ms
56,220 KB
testcase_77 AC 116 ms
53,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;


public class Main_yukicoder634 {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();

		Set<Integer> tr = new HashSet<>();
		for (int i = 1; i * (i + 1) / 2 <= n; i++) {
			int tmp = i * (i + 1) / 2;
			tr.add(tmp);
		}

		if (tr.contains(n)) {
			pr.println(1);
		} else {
			for (int e : tr) {
				if (tr.contains(n - e)) {
					pr.println(2);
					return;
				}
			}
			pr.println(3);
		}

	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}
0