結果
問題 |
No.825 賢いお買い物
|
ユーザー |
![]() |
提出日時 | 2019-05-04 01:12:19 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 548 bytes |
コンパイル時間 | 1,817 ms |
コンパイル使用メモリ | 160,484 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2025-01-02 16:28:58 |
合計ジャッジ時間 | 2,583 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
ソースコード
#include "bits/stdc++.h" using namespace std; void solve(void) { int a, b, c; cin >> a >> b >> c; int ans = 10000; for (int x = 0; x <= a; x++) for (int y = 0; y <= b; y++) for (int z = 1; z <= x+10*y; z++) { int turi = x + 10 * y - z; int na = a - x + turi % 10; int nb = b - y + turi / 10; if (na + nb == c) { ans = min(ans, z); } } if (ans < 10000) { cout << ans << endl; } else { cout << "Impossible" << endl; } } int main() { solve(); //cout << "yui(*-v・)yui" << endl; return 0; }