結果

問題 No.634 硬貨の枚数1
ユーザー aaaa3215aaaa3215
提出日時 2018-05-10 23:48:26
言語 C
(gcc 12.3.0)
結果
RE  
実行時間 -
コード長 611 bytes
コンパイル時間 175 ms
コンパイル使用メモリ 28,244 KB
実行使用メモリ 4,568 KB
最終ジャッジ日時 2023-09-10 12:12:22
合計ジャッジ時間 3,944 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 AC 1 ms
4,380 KB
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 0 ms
4,376 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 AC 0 ms
4,376 KB
testcase_12 RE -
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 18 ms
4,376 KB
testcase_15 AC 21 ms
4,380 KB
testcase_16 AC 22 ms
4,376 KB
testcase_17 AC 21 ms
4,376 KB
testcase_18 AC 22 ms
4,376 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 22 ms
4,380 KB
testcase_22 AC 22 ms
4,376 KB
testcase_23 AC 22 ms
4,380 KB
testcase_24 AC 0 ms
4,376 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 0 ms
4,376 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 0 ms
4,380 KB
testcase_31 AC 0 ms
4,376 KB
testcase_32 AC 0 ms
4,380 KB
testcase_33 AC 0 ms
4,376 KB
testcase_34 AC 1 ms
4,376 KB
testcase_35 AC 22 ms
4,376 KB
testcase_36 AC 22 ms
4,376 KB
testcase_37 AC 22 ms
4,380 KB
testcase_38 AC 17 ms
4,380 KB
testcase_39 AC 22 ms
4,380 KB
testcase_40 AC 22 ms
4,376 KB
testcase_41 AC 21 ms
4,376 KB
testcase_42 AC 22 ms
4,376 KB
testcase_43 AC 22 ms
4,376 KB
testcase_44 RE -
testcase_45 AC 1 ms
4,376 KB
testcase_46 RE -
testcase_47 WA -
testcase_48 RE -
testcase_49 RE -
testcase_50 AC 22 ms
4,376 KB
testcase_51 AC 1 ms
4,380 KB
testcase_52 RE -
testcase_53 AC 1 ms
4,376 KB
testcase_54 AC 1 ms
4,376 KB
testcase_55 AC 22 ms
4,376 KB
testcase_56 AC 22 ms
4,380 KB
testcase_57 AC 23 ms
4,380 KB
testcase_58 AC 22 ms
4,376 KB
testcase_59 AC 22 ms
4,376 KB
testcase_60 AC 22 ms
4,376 KB
testcase_61 AC 22 ms
4,380 KB
testcase_62 AC 22 ms
4,376 KB
testcase_63 AC 21 ms
4,380 KB
testcase_64 AC 22 ms
4,376 KB
testcase_65 AC 21 ms
4,380 KB
testcase_66 AC 22 ms
4,380 KB
testcase_67 AC 21 ms
4,376 KB
testcase_68 AC 21 ms
4,376 KB
testcase_69 AC 21 ms
4,376 KB
testcase_70 AC 22 ms
4,380 KB
testcase_71 AC 22 ms
4,380 KB
testcase_72 AC 22 ms
4,376 KB
testcase_73 AC 22 ms
4,376 KB
testcase_74 AC 22 ms
4,380 KB
testcase_75 AC 23 ms
4,380 KB
testcase_76 AC 1 ms
4,380 KB
testcase_77 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>

int sankaku(int k) {
	int num = k * (k + 1) / 2;
	return num;
}

int main(void) {
	int N;
	int tri[10000];
	int tri1, tri2;
	int k = 0;
	int m = 0;

	scanf("%d", &N);

	tri[0] = 0;
	for (int j = 1; tri[j-1] < 1000000; j++) {
		tri[j] = sankaku(j);
	}

	//1つか2つの三角数のどちらであるかを判定
	do{
		k++;
		tri1 = tri[k];
		if (N == tri1) {
			printf("1\n");
			return 1;
		}

		m = k - 1;
		do{
			m++;
			tri2 = tri[k] + tri[m];
			if (N == tri2) {
				printf("2\n");
				return 2;
			}

		} while (N > tri2);
				
	} while (N > tri1);

	printf("3\n");

	return 0;

}
0