Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //In the Name of Allah Most Gracious, Most Merciful//
- /*If you want something you've never had, you have to do something you never did.*/
- #include<bits/stdc++.h>
- using namespace std;
- #define pb push_back
- #define ll long long
- #define pii pair<int,int>
- #define pll pair<ll,ll>
- #define INF 1e9
- #define INFL 1e18
- #define PI acos(-1)
- #define mp make_pair
- #define fast_in_out ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
- //const int fx[]= {+1,-1,+0,+0};
- //const int fy[]= {+0,+0,+1,-1};
- //const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1}; // Kings Move
- //const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1}; // Kings Move
- //const int fx[]={-2, -2, -1, -1, 1, 1, 2, 2}; // Knights Move
- //const int fy[]={-1, 1, -2, 2, -2, 2, -1, 1}; // Knights Move
- #define M 10000009
- vector<ll>prime;
- bool mark[M];
- vector<pair<ll,ll> >v;
- void sieve()
- {
- int i,j;
- prime.push_back(2);
- for(i=3;i*i<=M;i+=2)
- {
- if(mark[i]==false)
- {
- for(j=i*i;j<=M;j+=2*i)
- mark[j]=true;
- }
- }
- for(i=3;i<=M;i+=2)
- {
- if(mark[i]==false)
- prime.push_back(i);
- }
- }
- void primefac(long long n)
- {
- long long i,j;
- for(i=0;prime[i]*prime[i]<=n;i++)
- {
- if(n%prime[i]==0)
- {
- ll cnt=0;
- while(n%prime[i]==0)
- {
- n/=prime[i];
- cnt++;
- }
- v.pb(mp(prime[i],cnt));
- }
- }
- if(n>1){
- v.pb(mp(n,1LL));
- }
- }
- ll myfunc(ll x,ll y)
- {
- ll ret=1;
- while(y>0)
- {
- ret=ret*x;
- y--;
- }
- return ret;
- }
- int main()
- {
- // fast_in_out;
- // #ifndef ONLINE_JUDGE
- // freopen("input.txt","r",stdin);
- // freopen("output.txt","w",stdout);
- // #endif
- sieve();
- int t,kase=0;
- cin>>t;
- while(t--)
- {
- ll n;
- cin>>n;
- primefac(n);
- ll ans=1LL;
- for(int i=0;i<v.size();i++)
- {
- ll x=v[i].first;
- ll y=v[i].second;
- ll sum=0;
- for(int j=y;j>=0;j--)
- {
- ll z=(2*j+1)*myfunc(x,y-j)*1LL;
- sum+=z;
- //cout<<z<<endl;
- }
- ans=ans*sum;
- }
- cout<<"Case "<<kase+1<<": "<<ans<<endl;
- kase++;
- v.clear();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment