Maruf_Hasan

13083

Aug 20th, 2020
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1.  
  2. //In the Name of Allah Most Gracious, Most Merciful//
  3. /*If you want something you've never had, you have to do something you never did.*/
  4.  
  5. #include<bits/stdc++.h>
  6. using namespace std;
  7.  
  8.  
  9. #define pb push_back
  10. #define ll long long
  11. #define pii pair<int,int>
  12. #define pll pair<ll,ll>
  13.  
  14. #define INF 1e9
  15. #define INFL 1e18
  16. #define PI acos(-1)
  17. #define mp make_pair
  18. #define fast_in_out ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  19. //const int fx[]= {+1,-1,+0,+0};
  20. //const int fy[]= {+0,+0,+1,-1};
  21. //const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1}; // Kings Move
  22. //const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1}; // Kings Move
  23. //const int fx[]={-2, -2, -1, -1, 1, 1, 2, 2}; // Knights Move
  24. //const int fy[]={-1, 1, -2, 2, -2, 2, -1, 1}; // Knights Move
  25.  
  26. #define M 10000009
  27.  
  28.  
  29. vector<ll>prime;
  30. bool mark[M];
  31.  
  32. vector<pair<ll,ll> >v;
  33.  
  34. void sieve()
  35. {
  36. int i,j;
  37. prime.push_back(2);
  38. for(i=3;i*i<=M;i+=2)
  39. {
  40. if(mark[i]==false)
  41. {
  42. for(j=i*i;j<=M;j+=2*i)
  43. mark[j]=true;
  44. }
  45. }
  46. for(i=3;i<=M;i+=2)
  47. {
  48. if(mark[i]==false)
  49. prime.push_back(i);
  50. }
  51.  
  52. }
  53.  
  54. void primefac(long long n)
  55. {
  56. long long i,j;
  57. for(i=0;prime[i]*prime[i]<=n;i++)
  58. {
  59. if(n%prime[i]==0)
  60. {
  61. ll cnt=0;
  62. while(n%prime[i]==0)
  63. {
  64. n/=prime[i];
  65. cnt++;
  66. }
  67. v.pb(mp(prime[i],cnt));
  68. }
  69. }
  70. if(n>1){
  71. v.pb(mp(n,1LL));
  72.  
  73. }
  74.  
  75. }
  76.  
  77. ll myfunc(ll x,ll y)
  78. {
  79. ll ret=1;
  80. while(y>0)
  81. {
  82. ret=ret*x;
  83. y--;
  84. }
  85. return ret;
  86. }
  87. int main()
  88. {
  89. // fast_in_out;
  90. // #ifndef ONLINE_JUDGE
  91. // freopen("input.txt","r",stdin);
  92. // freopen("output.txt","w",stdout);
  93. // #endif
  94. sieve();
  95. int t,kase=0;
  96. cin>>t;
  97. while(t--)
  98. {
  99.  
  100. ll n;
  101. cin>>n;
  102. primefac(n);
  103. ll ans=1LL;
  104. for(int i=0;i<v.size();i++)
  105. {
  106. ll x=v[i].first;
  107. ll y=v[i].second;
  108. ll sum=0;
  109. for(int j=y;j>=0;j--)
  110. {
  111. ll z=(2*j+1)*myfunc(x,y-j)*1LL;
  112. sum+=z;
  113. //cout<<z<<endl;
  114. }
  115. ans=ans*sum;
  116. }
  117. cout<<"Case "<<kase+1<<": "<<ans<<endl;
  118. kase++;
  119. v.clear();
  120. }
  121.  
  122. return 0;
  123. }
  124.  
  125.  
Advertisement
Add Comment
Please, Sign In to add comment