-
Notifications
You must be signed in to change notification settings - Fork 95
Expand file tree
/
Copy path2.3.cpp
More file actions
36 lines (32 loc) · 783 Bytes
/
2.3.cpp
File metadata and controls
36 lines (32 loc) · 783 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
* 题目名称:Old Bill
* 题目来源:上海交通大学复试上机题
* 题目链接:http://t.cn/E9jqijR
* 代码作者:杨泽邦(炉灰)
*/
#include <iostream>
#include <cstdio>
using namespace std;
bool Function(int n, int x, int y, int z) {
for (int i = 9; i >= 1; --i) {
for (int j = 9; j >= 0; --j) {
int price = i * 1e4 + x * 1e3 + y * 1e2 + z * 1e1 + j;
if (price % n == 0) {
printf("%d %d %d", i, j, price / n);
return true;
}
}
}
return false;
}
int main() {
int n;
while (scanf("%d", &n) != EOF) {
int x, y, z;
scanf("%d%d%d", &x, &y, &z);
if (!Function(n, x, y, z)) {
printf("0\n");
}
}
return 0;
}