Saleh127

Live archive 2953

Jul 26th, 2020
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define test int t; cin>>t; while (t--)
  4. #define ll long long int
  5. #define fellow_junior ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  6. int main()
  7. {
  8. fellow_junior
  9.  
  10. ll fact[20];
  11. ll a,c,d,e,f,i,j,k,l;
  12. fact[0]=1;
  13. fact[1]=1;
  14. for(i=2;i<10;i++)
  15. {
  16. fact[i]=fact[i-1]*i;
  17. }
  18. while(cin>>a && a>=0)
  19. {
  20. if(a==0)
  21. {
  22. cout<<"NO"<<endl;
  23. continue;
  24. }
  25. for(i=9;i>=0;i--)
  26. {
  27. if(a>=fact[i])
  28. {
  29. a-=fact[i];
  30. }
  31. }
  32. if(a==0) cout<<"YES"<<endl;
  33. else cout<<"NO"<<endl;
  34. }
  35. return 0;
  36. }
  37.  
Advertisement
Add Comment
Please, Sign In to add comment