結果
問題 |
No.634 硬貨の枚数1
|
ユーザー |
![]() |
提出日時 | 2018-01-19 22:11:27 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 592 bytes |
コンパイル時間 | 3,391 ms |
コンパイル使用メモリ | 167,892 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-25 19:04:11 |
合計ジャッジ時間 | 4,264 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 9 WA * 66 |
ソースコード
#include <bits/stdc++.h> using namespace std; vector<int> init (int n) { vector<int> r; int a = 0; int k = 1; while (a <= n) { a = k * (k + 1) / 2; r.emplace_back(a); k += 1; } return r; } int main() { cin.tie(0); ios::sync_with_stdio(false); int N; int ans = 0; cin >> N; vector<int> v = init(N); int p = v.size() - 1; while (N > 0) { if (N >= v[p]) { ans += N / v[p]; N %= v[p]; } p -= 1; } cout << ans << endl; return 0; }