結果

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

テストケース

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

ソースコード

diff #

#include<stdio.h>

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

int main(void) {
	int N;
	int tri1,tri2;
	int k = 1;
	int m = 1;

	scanf("%d", &N);

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

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

			m++;

		} while (N > tri1 + tri2);

		k++;
		
	} while (N > tri1);

	printf("3\n");

	return 0;

}
0