Guest User

Untitled

a guest
Oct 21st, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. #include <vector>
  2. #include <list>
  3. #include <map>
  4. #include <set>
  5. #include <queue>
  6. #include <deque>
  7. #include <stack>
  8. #include <bitset>
  9. #include <algorithm>
  10. #include <functional>
  11. #include <numeric>
  12. #include <utility>
  13. #include <sstream>
  14. #include <iostream>
  15. #include <iomanip>
  16. #include <cstdio>
  17. #include <cmath>
  18. #include <cstdlib>
  19. #include <ctime>
  20. #include <string>
  21. #include <string.h>
  22. #define pb push_back
  23.  
  24. #define SS(a,b) scanf("%d%d",&a,&b);
  25. #define S(a) scanf("%d",&a);
  26. #define SSL(a,b) scanf("%lld%lld",&a,&b);
  27. #define SL(a) scanf("%lld",&a);
  28. #define SSS(a,b,c) scanf("%d %d %d",&a,&b,&c);
  29. #define GI ({int t;scanf("%d",&t);t;})
  30. #define GL ({ll t;scanf("%lld",&t);t;})
  31. #define MAXN 500000
  32. #define FOR(i,n) for(int i=0;i<n;i++)
  33. #define disvec(v) { for(int vec_index=0;vec_index<v.size();vec_index++) cout<<v[vec_index]<<" "; cout<<endl;}
  34. #define TESTIN freopen("input.txt","r",stdin);
  35. #define TESTOUT freopen("output.txt","w",stdout);
  36.  
  37. #define WRITETEST freopen("input.txt","w",stdout);
  38.  
  39. using namespace std;
  40. typedef long long LL;
  41. typedef long long ll;
  42. typedef pair<LL,LL> PLL;
  43. LL mod=9901LL;
  44. long long modular(long long a,long long b,long long c){
  45. //Calculate a power b mod c
  46. long long x=1,y=a;
  47. while(b>0){
  48. if(b&1) x=(x*y)%c;
  49. y=(y*y)%c;
  50. b>>=1;
  51. }
  52. return (x%c);
  53. }
  54. //PLL -- > primefactor,power
  55. // Sum of Divisors of a number when number is represented as prime factors
  56. // N=p1^a * p2^ b *p3^c
  57. // =(p1^(a+1))/(p1-1) *(p2^(b+1))/(p2-1)....
  58. vector<PLL > factorize(LL a){
  59. vector<PLL >temp;
  60. for(ll x=2;a>=2;x++){
  61. if(a<2)break;
  62. if(a%x==0){
  63. LL c=0;
  64. while(a%x==0) c++,a/=x;
  65. temp.pb(make_pair(x,c));
  66. }
  67. }
  68. return temp;
  69. }
  70. int main(){
  71. LL a,b;
  72. cin>>a>>b;
  73. vector<PLL > temp=factorize(a);
  74. /*for(int i=0;i<temp.size();i++)
  75. cout<<temp[i].first<<" "<<temp[i].second<<endl;*/
  76. LL ans=1;
  77. for(int i=0;i<temp.size();i++){
  78. LL num=temp[i].first;
  79. LL cnt=temp[i].second;
  80. LL totalpower=cnt*b;
  81. LL first=modular(num,totalpower+1,mod);
  82. first--;
  83. // Division by (num-1) and mod is prime
  84. // now Let a=(num-1)
  85. // then multiply by a^(mod-2)%mod
  86. LL inverse=modular(num-1,mod-2,mod);
  87. ans*=(first*inverse)%mod;
  88. ans%=mod;
  89. if(ans<0)ans+=mod;
  90. }
  91. cout<<ans<<endl;
  92. GI;
  93. return 0;
  94. }
Add Comment
Please, Sign In to add comment