結果
| 問題 |
No.634 硬貨の枚数1
|
| コンテスト | |
| ユーザー |
square1001
|
| 提出日時 | 2018-01-21 15:19:10 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 25 ms / 2,000 ms |
| コード長 | 438 bytes |
| コンパイル時間 | 806 ms |
| コンパイル使用メモリ | 82,912 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-25 21:09:37 |
| 合計ジャッジ時間 | 3,774 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 75 |
ソースコード
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int n;
int main() {
cin >> n;
int ret = 3;
for (int i = 1; i * (i + 1) / 2 <= n; i++) {
if (i * (i + 1) / 2 == n) ret = 1;
for (int j = 1; j * (j + 1) / 2 <= n; j++) {
if (i * (i + 1) / 2 + j * (j + 1) / 2 == n) ret = min(ret, 2);
}
}
cout << ret << endl;
return 0;
}
square1001