結果
| 問題 | No.825 賢いお買い物 |
| コンテスト | |
| ユーザー |
tenten
|
| 提出日時 | 2021-02-10 08:59:08 |
| 言語 | Java (openjdk 27 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 101 ms / 2,000 ms |
| + 87µs | |
| コード長 | 1,049 bytes |
| 記録 | |
| コンパイル時間 | 3,096 ms |
| コンパイル使用メモリ | 85,024 KB |
| 実行使用メモリ | 46,544 KB |
| 最終ジャッジ日時 | 2026-10-13 11:50:55 |
| 合計ジャッジ時間 | 6,343 ms |
|
ジャッジサーバーID (参考情報) |
judge5_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
int ans = Integer.MAX_VALUE / 2;
for (int i = 1; i <= a + b * 10; i++) {
for (int j = 0; j <= a; j++) {
for (int k = 0; k <= b; k++) {
int value = j + 10 * k;
if (value == 0) {
continue;
}
if (getCount(value - i) + a - j + b - k == c) {
ans = Math.min(ans, i);
}
}
}
}
if (ans >= Integer.MAX_VALUE / 2) {
System.out.println("Impossible");
} else {
System.out.println(ans);
}
}
static int getCount(int x) {
if (x < 0) {
return Integer.MAX_VALUE / 2;
} else {
return x % 10 + x / 10;
}
}
}
tenten