Advertisement
Farjana_akter

Untitled

Dec 26th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. typedef long long int ll;
  4. ll arr[10000007];
  5. int main()
  6. {
  7. ll n,i,j,k,sz=1,carry,sum=0,b,c,d,a;
  8. while(cin>>n)
  9. {
  10. cout<<n<<"! --"<<endl;
  11. carry=0,sz=1,arr[0]=1,sum=0;
  12. ll one=0,two=0,three=0,four=0,five=0,six=0,seven=0,eight=0,nine=0,zero=0;
  13. for(i=1;i<=n;i++)
  14. {
  15. for(j=0;j<sz;j++)
  16. {
  17. a=arr[j]*i+carry;
  18. arr[j]=a%10;
  19. // sum+=arr[j];
  20. carry=a/10;
  21. }
  22. while(carry>0)
  23. {
  24. arr[sz]=carry%10;
  25. // sum+=arr[sz];
  26. carry/=10;
  27. sz++;
  28. }
  29. }
  30. for(i=sz-1;i>=0;i--)
  31. {
  32. if(arr[i]==0)
  33. zero++;
  34. else if(arr[i]==1)
  35. one++;
  36. else if(arr[i]==2)
  37. two++;
  38. else if(arr[i]==3)
  39. three++;
  40. else if(arr[i]==4)
  41. four++;
  42. else if(arr[i]==5)
  43. five++;
  44. else if(arr[i]==6)
  45. six++;
  46. else if(arr[i]==7)
  47. seven++;
  48. else if(arr[i]==8)
  49. eight++;
  50. else if(arr[i]==9)
  51. nine++;
  52. }
  53. printf(" (0) %lld (1) %lld (2) %lld (3) %lld (4) %lld\n",zero,one,two,three,four);
  54. printf(" (5) %lld (6) %lld (7) %lld (8) %lld (9) %lld\n",five,six,seven,eight,nine);
  55. }
  56. return 0;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement