結果
問題 |
No.636 硬貨の枚数2
|
ユーザー |
![]() |
提出日時 | 2017-05-17 16:42:55 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 527 bytes |
コンパイル時間 | 525 ms |
コンパイル使用メモリ | 61,940 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-19 10:23:41 |
合計ジャッジ時間 | 2,008 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 WA * 1 |
other | AC * 15 WA * 50 |
ソースコード
#include <iostream> #include <vector> #include <cmath> #include <assert.h> using namespace std; int count(long long x) { int ret = 0; while (x) { ret += x % 5; if (x % 10 >= 5) ret++; x /= 10; } return ret; } int solve_naive(long long n) { int ans = 1e9; for (int x = n; x <= min<int>(n+1e7, n * 3); x++) { int cand = count(x) + count(x-n); if (cand < ans) { ans = cand; } } return ans; } int main() { long long n; cin >> n; cout << solve_naive(n) << endl; return 0; }