比赛 |
20120416 |
评测结果 |
AAAAAAAAAA |
题目名称 |
数字的游戏 |
最终得分 |
100 |
用户昵称 |
Citron酱 |
运行时间 |
0.000 s |
代码语言 |
C++ |
内存使用 |
0.00 MiB |
提交时间 |
2012-04-16 09:46:07 |
显示代码纯文本
#include <cstdio>
#include <string.h>
#define I_F "cdgame.in"
#define O_F "cdgame.out"
const short Maxg=100;
const long Maxn=1000000;
short g;
long s[Maxg];
bool f[Maxn]={false};
void Input();
short Maxnum(const long&);
short Minnum(const long&);
void Search();
void Output();
int main()
{
Input();
Search();
Output();
return 0;
}
void Input()
{
freopen(I_F,"r",stdin);
scanf("%hd",&g);
for (short i=0; i<g; scanf("%ld",&s[i++]));
}
short Maxnum(const long &x)
{
char s[10];
sprintf(s,"%ld",x);
char t='0';
for (short i=0; i<strlen(s); i++)
t=(s[i]>t)?s[i]:t;
return (t-'0');
}
short Minnum(const long &x)
{
char s[10];
sprintf(s,"%ld",x);
char t='9';
for (short i=0; i<strlen(s); i++)
t=(s[i]<t && s[i]!='0')?s[i]:t;
return (t-'0');
}
void Search()
{
long m=0;
for (short i=0; i<g; i++)
m=(s[i]>m)?s[i]:m;
for (long i=1; i<=m; i++)
f[i]=!(f[i-Maxnum(i)] && f[i-Minnum(i)]);
}
void Output()
{
freopen(O_F,"w",stdout);
for (short i=0; i<g; i++)
if (f[s[i]])
printf("YES\n");
else
printf("NO\n");
}