結果
問題 | No.634 硬貨の枚数1 |
ユーザー |
![]() |
提出日時 | 2019-05-11 10:43:38 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 657 bytes |
コンパイル時間 | 1,519 ms |
コンパイル使用メモリ | 165,836 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-02 01:08:56 |
合計ジャッジ時間 | 3,838 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 WA * 65 |
ソースコード
#include <bits/stdc++.h> using namespace std; using LL = long long; const LL LIMIT = 3250; int main() { // 1. 入力情報取得. LL N; cin >> N; // 2. 硬貨準備. LL coins[LIMIT]; for(int i = 0; i < LIMIT; i++) coins[i] = (i + 1) * (i + 2) / 2; // 3. 支払う硬貨をカウント. LL ans = 0; for(int i = LIMIT - 1; i >= 0; i--){ if(N == 0) break; if(N >= coins[i]){ while(1){ if(N >= coins[i]) N -= coins[i], ans++; else break; } } } // 4. 出力. cout << ans << endl; return 0; }