結果

問題 No.634 硬貨の枚数1
コンテスト
ユーザー aaaa3215
提出日時 2018-05-10 23:43:12
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
WA  
実行時間 -
コード長 610 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 189 ms
コンパイル使用メモリ 37,604 KB
最終ジャッジ日時 2026-02-22 01:07:43
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1 RE * 2
other WA * 4 RE * 7 OLE * 1 -- * 63
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<stdio.h>

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

int main(void) {
	int N;
	int tri[10000];
	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++;
		if (N == tri[k]) {
			printf("1\n");
			return 1;
		}

		m = k;
		do{
			m++;
			if (N == tri[k] + tri[m]) {
				printf("2\n");
				return 2;
			}
			printf("%d,%d\n", tri[k], tri[m]);

		} while (N > tri[k] + tri[m]);
				
	} while (N > tri[k]);

	printf("3\n");

	return 0;

}
0