結果
問題 | No.825 賢いお買い物 |
ユーザー |
![]() |
提出日時 | 2019-06-25 01:10:00 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 616 bytes |
コンパイル時間 | 1,334 ms |
コンパイル使用メモリ | 166,424 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-22 23:30:55 |
合計ジャッジ時間 | 2,073 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; int A, B, C; int ans = 100000; void solve(int v, int a, int b) { int r = a + 10 * b - v; int k = r / 10 + r % 10; if (A + B - (a + b) + k == C) { ans = min(ans, v); } } int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> A >> B >> C; int v = A + 10 * B; for (int a = 0; a <= A; a++) { for (int b = 0; b <= B; b++) { for (int v = 1; v <= a + 10 * b; v++) { solve(v, a, b); } } } if (ans == 100000) { cout << "Impossible\n"; } else { cout << ans << "\n"; } return 0; }