結果
問題 |
No.825 賢いお買い物
|
ユーザー |
|
提出日時 | 2019-05-03 22:30:39 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 717 bytes |
コンパイル時間 | 1,697 ms |
コンパイル使用メモリ | 167,556 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-31 18:12:50 |
合計ジャッジ時間 | 2,356 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h> using namespace std; int change(int a, int b, int p){ int ch = (a + 10 * b - p); return (ch / 10) + (ch % 10); } int main(){ cin.tie(0); ios::sync_with_stdio(false); int A,B,C; cin >> A >> B >> C; int min_p = 1000; for (int a = 0; a <= A; ++a){ for (int b = 0; b <= B; ++b){ for (int p = 1; p <= a + 10*b; ++p){ if (a == 0 and b == 0) continue; if (A - a + B - b + change(a, b, p) == C){ min_p = min(min_p, p); } } } } if (min_p == 1000){ cout << "Impossible" << endl; }else{ cout << min_p << endl; } return 0; }