| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
优雅的暴力。。。。二进制用二进制外加暴力做的 94ms...
没有其他那些暴力代码的那么多循环
但是WA了两次 为什么捏
第一次是while(cin>>n&&n=-1) 鄙视题目
第二次是while(cin>>n&&n<0) 没有本地运行就提交 我擦..鄙视自己
#include<iostream>
using namespace std;
bool s[1000001];
void work()
{
memset(s,false,sizeof(s));
int i,j,t,temp[10],sum;
temp[0]=1;
for(i=1;i<=9;i++)
temp[i]=i*temp[i-1];
for(i=1;i<1024;i++)
{
sum=0;
t=i;
for(j=0;j<10;j++)
{
sum+=temp[9-j]*(t%2);
t=t/2;
}
s[sum]=true;
}
}
int main()
{
int n;
work();
while(cin>>n&&n>=0)
{
if(s[n])
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator