Advertisement
Farjana_akter

Untitled

Dec 26th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 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. for(i=1;i<=n;i++)
  13. {
  14. for(j=0;j<sz;j++)
  15. {
  16. a=arr[j]*i+carry;
  17. arr[j]=a%10;
  18. // sum+=arr[j];
  19. carry=a/10;
  20. }
  21. while(carry>0)
  22. {
  23. arr[sz]=carry%10;
  24. // sum+=arr[sz];
  25. carry/=10;
  26. sz++;
  27. }
  28. }
  29. for(i=sz-1;i>=0;i--)
  30. sum+=arr[i];
  31. // cout<<endl;
  32. cout<<sum<<endl;
  33. }
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement