比赛 |
EYOI与SBOI开学欢乐赛12th |
评测结果 |
AAAAAAAAAA |
题目名称 |
数字的游戏 |
最终得分 |
100 |
用户昵称 |
该账号已注销 |
运行时间 |
0.853 s |
代码语言 |
C++ |
内存使用 |
7.64 MiB |
提交时间 |
2022-10-17 20:36:14 |
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
int t, n;
bool k[1000100][2];
int main() {
freopen("cdgame.in", "r", stdin);
freopen("cdgame.out", "w", stdout);
cin >> t;
k[0][1] = 0;
k[0][2] = 0;
for (int i = 1; i <= 9; i++) {
k[i][1] = 1;
k[i][2] = 1;
}
for (int i = 10; i <= 1000000; i++) {
int minn = 0x3f3f3f3f, maxn = -1;
int p = i;
while (p > 0) {
int k = p % 10;
p /= 10;
if (k != 0) {
minn = min(minn, k);
maxn = max(maxn, k);
}
}
if (minn != 0x3f3f3f3f && i - minn >= 0) {
if (k[i - minn][2] == 0) {
k[i][1] = 1;
}
if (k[i - minn][1] == 0) {
k[i][2] = 1;
}
}
if (maxn != -1 && i - maxn >= 0) {
if (k[i - maxn][2] == 0) {
k[i][1] = 1;
}
if (k[i - maxn][1] == 0) {
k[i][2] = 1;
}
}
}
for (int tt = 1; tt <= t; tt++) {
cin >> n;
if (k[n][1] == 1) {
cout << "YES" << endl;
continue;
} else {
cout << "NO" << endl;
continue;
}
}
return 0;
}