結果
| 問題 | No.825 賢いお買い物 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2024-03-28 17:30:04 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 52 ms / 2,000 ms | 
| コード長 | 767 bytes | 
| コンパイル時間 | 4,656 ms | 
| コンパイル使用メモリ | 250,372 KB | 
| 最終ジャッジ日時 | 2025-02-20 14:15:07 | 
| ジャッジサーバーID (参考情報) | judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 19 | 
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
int main() {
  int a, b, c; cin >> a >> b >> c;
  int ans = 1e9;
  for (int i = 0; i <= a; i++) {
    for (int j = 0; j <= b; j++) {
      if (i == 0 && j == 0) continue;
      for (int k = 1; k <= a + 10 * b; k++) {
        int x = i + 10 * j - k;
        if (x < 0) continue;
        int n = x % 10;
        int m = x / 10;
        if (a - i + b - j + n + m == c) {
          //cout << i << ' ' << j << ' ' << k << ' ' << x << ' ' << n << ' ' << m << ' ' << i + 10 * j << endl;
          ans = min(ans, k);
        }
      }
    }
  }
  if (ans == 1e9) cout << "Impossible" << endl;
  else cout << ans << endl;
  return 0;
}
            
            
            
        