結果
| 問題 |
No.825 賢いお買い物
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-05-03 21:57:04 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 7 ms / 2,000 ms |
| コード長 | 799 bytes |
| コンパイル時間 | 2,082 ms |
| コンパイル使用メモリ | 192,696 KB |
| 最終ジャッジ日時 | 2025-01-07 03:23:30 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 19 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)
bool check(int a, int b, int c, int aa, int bb,int x) {
int y = aa+10*bb;
if(y==0|y<x)
return false;
int aaa =(y-x)%10;
int bbb = (y-x)/10;
return (a-aa+aaa)+(b-bb+bbb)==c;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cout<<setprecision(std::numeric_limits<float>::max_digits10);
int a,b,c;
cin>>a>>b>>c;
int ans = 1e9;
rep(aa,a+1) {
rep(bb,b+1) {
repeat(x,1,10000) {
if(check(a,b,c,aa,bb,x)) {
ans = min(ans,x);
}
}
}
}
if(ans==1e9)
cout << "Impossible" << endl;
else
cout << ans << endl;
return 0;
}