結果
問題 | No.634 硬貨の枚数1 |
ユーザー |
![]() |
提出日時 | 2019-07-20 07:26:32 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 12 ms / 2,000 ms |
コード長 | 491 bytes |
コンパイル時間 | 1,727 ms |
コンパイル使用メモリ | 166,468 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-29 13:26:44 |
合計ジャッジ時間 | 4,014 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 75 |
ソースコード
#include <bits/stdc++.h> using namespace std; int f(int n) { return n * (n + 1) / 2; } int main() { int n; cin >> n; int ans = 3; for (int i = 1; f(i) <= n; i++) { if (f(i) == n) { ans = 1; break; } int t = n - f(i); for (int j = i; f(j) <= t; j++) { if (f(j) == t) { ans = min(ans, 2); break; } } } cout << ans << endl; return 0; }