Advertisement
atrahman2012

Untitled

Mar 21st, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define MOD 1000000007
  3. using namespace std;
  4. long long int big_mode(long long int base,long long int po)
  5. {
  6. if(po==0)
  7. return 1;
  8. else if(po%2==0)
  9. {
  10. long long int temp=big_mode(base,po/2);
  11. return ((temp%MOD)*(temp%MOD))%MOD;
  12. }
  13. else
  14. {
  15. return ((base%MOD)*big_mode(base,po-1))%MOD;
  16. }
  17. }
  18. int main()
  19. {
  20. long long int t,tc=0,po,base,p,sum;
  21. scanf("%lld",&t);
  22. while(tc<t)
  23. {
  24. sum=0;
  25. scanf("%lld%lld",&base,&po);
  26.  
  27. p=big_mode(base,po);
  28. //p=pow(base,po);
  29. // cout<<p<<endl;
  30. for(long long int i=1;i<=sqrt(p);i++)
  31. {
  32. if(i==sqrt(p))
  33. sum+=i;
  34. else if(p%i==0)
  35. {
  36. sum+=i;
  37. sum+=p/i;
  38. // cout<<i<<" "<<p/i<<endl;
  39. }
  40. }
  41. printf("Case %lld: %lld\n",++tc,sum%MOD);
  42. }
  43. return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement