Advertisement
erfanul007

LA 2953

Jan 21st, 2019
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long int ll;
  5. typedef unsigned long long int ull;
  6. typedef vector<int> vi;
  7. typedef vector<ll> vll;
  8. typedef vector<vi> vvi;
  9. typedef pair<int,int > pii;
  10. typedef vector< pii > vpii;
  11. typedef set<int> sti;
  12.  
  13. #define sc scanf
  14. #define pf printf
  15. #define sci(n) scanf("%d",&n)
  16. #define scl(n) scanf("%lld",&n)
  17. #define scf(n) scanf("%lf",&n)
  18. #define pfi(n) printf("%d",n)
  19. #define pfl(n) printf("%I64d",n)
  20. #define pff(n) cout<<n
  21. #define line printf("\n")
  22. #define spc printf(" ")
  23. #define loop(i,x,y) for(int i=int(x); i<=int(y); i++)
  24. #define rloop(i,y,x) for(int i=int(y); i>=int(x); i--)
  25. #define cspf(i) printf("Case %d: ", i)
  26. #define pb push_back
  27. #define mp make_pair
  28. #define ff first
  29. #define ss second
  30. #define all(v) v.begin(),v.end()
  31. #define rall(v) v.rbegin(),v.rend()
  32. #define read() freopen("input.txt", "r", stdin)
  33. #define write() freopen("output.txt", "w", stdout)
  34. /// Constants
  35. #define eps 1e-9
  36. #define PI acos(-1.0) // 3.1415926535897932
  37.  
  38.  
  39. int main()
  40. {
  41. ll fac[25],x,i,j,k;
  42. fac[0] = 1;
  43. loop(i,1,20){
  44. fac[i]=fac[i-1]*i;
  45. }
  46. while(1){
  47. scl(x);
  48. if(x<0) break;
  49. if(x==0){
  50. pf("NO\n");
  51. continue;
  52. }
  53. j=20;
  54. k=0;
  55. while(j>=0){
  56. if(fac[j]<=x)
  57. x-=fac[j];
  58. j--;
  59. }
  60. if(x==0) pf("YES\n");
  61. else pf("NO\n");
  62. }
  63. return 0;
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement