NYOJ 91 阶乘之和
1 #include<iostream>
2 #include<queue>
3 #include<memory.h>
4 using namespace std;
5 int a[]={1,2,6,24,120,720,5040,40320,362880};
6 int main()
7 {
8 int n,t,i,s;
9 cin>>t;
10 while(t--)
11 {
12 cin>>n;
13 s = 0;
14 for(i=8; i>=0; --i)
15 if(s+a[i]<=n) s+=a[i];
16 if(s == n)
17 cout<<"Yes\n";
18 else
19 cout<<"No\n";
20 }
21 return 0;
22 }
2 #include<queue>
3 #include<memory.h>
4 using namespace std;
5 int a[]={1,2,6,24,120,720,5040,40320,362880};
6 int main()
7 {
8 int n,t,i,s;
9 cin>>t;
10 while(t--)
11 {
12 cin>>n;
13 s = 0;
14 for(i=8; i>=0; --i)
15 if(s+a[i]<=n) s+=a[i];
16 if(s == n)
17 cout<<"Yes\n";
18 else
19 cout<<"No\n";
20 }
21 return 0;
22 }