結果

問題 No.634 硬貨の枚数1
ユーザー GrenacheGrenache
提出日時 2018-01-20 21:11:49
言語 Java21
(openjdk 21)
結果
AC  
実行時間 381 ms / 2,000 ms
コード長 1,003 bytes
コンパイル時間 3,660 ms
コンパイル使用メモリ 76,072 KB
実行使用メモリ 98,528 KB
最終ジャッジ日時 2023-08-26 19:33:11
合計ジャッジ時間 23,456 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 110 ms
55,860 KB
testcase_01 AC 114 ms
55,936 KB
testcase_02 AC 116 ms
55,536 KB
testcase_03 AC 117 ms
56,476 KB
testcase_04 AC 120 ms
55,772 KB
testcase_05 AC 115 ms
56,376 KB
testcase_06 AC 113 ms
55,556 KB
testcase_07 AC 112 ms
53,556 KB
testcase_08 AC 112 ms
55,892 KB
testcase_09 AC 116 ms
55,700 KB
testcase_10 AC 116 ms
56,008 KB
testcase_11 AC 112 ms
55,780 KB
testcase_12 AC 116 ms
55,544 KB
testcase_13 AC 115 ms
55,600 KB
testcase_14 AC 152 ms
60,032 KB
testcase_15 AC 325 ms
90,720 KB
testcase_16 AC 221 ms
73,344 KB
testcase_17 AC 238 ms
77,636 KB
testcase_18 AC 214 ms
73,828 KB
testcase_19 AC 300 ms
88,120 KB
testcase_20 AC 358 ms
93,720 KB
testcase_21 AC 355 ms
95,836 KB
testcase_22 AC 295 ms
91,532 KB
testcase_23 AC 204 ms
71,212 KB
testcase_24 AC 113 ms
55,844 KB
testcase_25 AC 113 ms
56,692 KB
testcase_26 AC 115 ms
55,760 KB
testcase_27 AC 116 ms
56,004 KB
testcase_28 AC 117 ms
55,836 KB
testcase_29 AC 121 ms
56,020 KB
testcase_30 AC 118 ms
56,172 KB
testcase_31 AC 121 ms
55,688 KB
testcase_32 AC 116 ms
56,400 KB
testcase_33 AC 119 ms
56,052 KB
testcase_34 AC 153 ms
58,224 KB
testcase_35 AC 188 ms
68,628 KB
testcase_36 AC 261 ms
81,452 KB
testcase_37 AC 212 ms
73,488 KB
testcase_38 AC 151 ms
60,224 KB
testcase_39 AC 309 ms
89,512 KB
testcase_40 AC 259 ms
78,920 KB
testcase_41 AC 246 ms
77,220 KB
testcase_42 AC 309 ms
87,392 KB
testcase_43 AC 205 ms
70,680 KB
testcase_44 AC 115 ms
55,628 KB
testcase_45 AC 136 ms
56,200 KB
testcase_46 AC 154 ms
59,576 KB
testcase_47 AC 367 ms
98,196 KB
testcase_48 AC 113 ms
55,808 KB
testcase_49 AC 156 ms
59,932 KB
testcase_50 AC 359 ms
98,528 KB
testcase_51 AC 154 ms
59,916 KB
testcase_52 AC 114 ms
56,164 KB
testcase_53 AC 114 ms
55,692 KB
testcase_54 AC 113 ms
56,184 KB
testcase_55 AC 377 ms
97,928 KB
testcase_56 AC 381 ms
97,844 KB
testcase_57 AC 361 ms
95,948 KB
testcase_58 AC 341 ms
95,292 KB
testcase_59 AC 362 ms
95,648 KB
testcase_60 AC 368 ms
96,224 KB
testcase_61 AC 371 ms
96,108 KB
testcase_62 AC 373 ms
95,336 KB
testcase_63 AC 381 ms
96,124 KB
testcase_64 AC 361 ms
95,732 KB
testcase_65 AC 349 ms
95,960 KB
testcase_66 AC 359 ms
97,800 KB
testcase_67 AC 379 ms
95,500 KB
testcase_68 AC 377 ms
95,908 KB
testcase_69 AC 372 ms
96,012 KB
testcase_70 AC 380 ms
95,668 KB
testcase_71 AC 354 ms
96,220 KB
testcase_72 AC 342 ms
95,808 KB
testcase_73 AC 356 ms
95,532 KB
testcase_74 AC 359 ms
96,032 KB
testcase_75 AC 372 ms
95,772 KB
testcase_76 AC 121 ms
55,976 KB
testcase_77 AC 168 ms
62,148 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();

		int[] tr = new int[n];
		Arrays.fill(tr, 3);

		List<Integer> trlist = new ArrayList<>();
		for (int i = 1; i * (i + 1) / 2 <= n; i++) {
			int tmp = i * (i + 1) / 2;
			tr[tmp - 1] = 1;
			trlist.add(tmp);
		}

//		pr.println(trlist.size());

		for (int i = 0, size = trlist.size(); i < size; i++) {
			for (int j = 0; j < size && trlist.get(i) + trlist.get(j) <= n; j++) {
				int tmp = trlist.get(i) + trlist.get(j);
				tr[tmp - 1] = Math.min(tr[tmp - 1], 2);
			}
		}

		pr.println(tr[n - 1]);
	}

	// ---------------------------------------------------
	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