結果
| 問題 | No.634 硬貨の枚数1 |
| コンテスト | |
| ユーザー |
bal4u
|
| 提出日時 | 2019-05-01 15:12:09 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 614 bytes |
| 記録 | |
| コンパイル時間 | 241 ms |
| コンパイル使用メモリ | 29,312 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-12-31 12:30:51 |
| 合計ジャッジ時間 | 2,378 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 75 |
ソースコード
// yukicoder: No.634 硬貨の枚数1
// 2019.5.1 bal4u
#include <stdio.h>
#define KMAX 4471 // 4471*4472/2 = 9997156
int t[KMAX+5], sz;
int bsch(int x)
{
int m, l = 0, r = sz;
while (l < r) {
m = (l + r) >> 1;
if (t[m] == x) return 1;
if (t[m] < x) l = m + 1; else r = m;
}
return 0;
}
int main()
{
int a, k, N;
scanf("%d", &N);
sz = 0; for (k = 1; ; k++) {
a = k*(k+1) >> 1;
if (a == N) { puts("1"); return 0; }
if (a > N) break;
t[sz++] = a;
}
a = N >> 1;
for (k = 0; t[k] <= a; k++) {
if (bsch(N-t[k])) { puts("2"); return 0; }
}
puts("3");
return 0;
}
bal4u