Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <vector>
- #include <list>
- #include <map>
- #include <set>
- #include <queue>
- #include <deque>
- #include <stack>
- #include <bitset>
- #include <algorithm>
- #include <functional>
- #include <numeric>
- #include <utility>
- #include <sstream>
- #include <iostream>
- #include <iomanip>
- #include <cstdio>
- #include <cmath>
- #include <cstdlib>
- #include <ctime>
- #include <string>
- #include <string.h>
- #define pb push_back
- #define SS(a,b) scanf("%d%d",&a,&b);
- #define S(a) scanf("%d",&a);
- #define SSL(a,b) scanf("%lld%lld",&a,&b);
- #define SL(a) scanf("%lld",&a);
- #define SSS(a,b,c) scanf("%d %d %d",&a,&b,&c);
- #define GI ({int t;scanf("%d",&t);t;})
- #define GL ({ll t;scanf("%lld",&t);t;})
- #define MAXN 500000
- #define FOR(i,n) for(int i=0;i<n;i++)
- #define disvec(v) { for(int vec_index=0;vec_index<v.size();vec_index++) cout<<v[vec_index]<<" "; cout<<endl;}
- #define TESTIN freopen("input.txt","r",stdin);
- #define TESTOUT freopen("output.txt","w",stdout);
- #define WRITETEST freopen("input.txt","w",stdout);
- using namespace std;
- typedef long long LL;
- typedef long long ll;
- typedef pair<LL,LL> PLL;
- LL mod=9901LL;
- long long modular(long long a,long long b,long long c){
- //Calculate a power b mod c
- long long x=1,y=a;
- while(b>0){
- if(b&1) x=(x*y)%c;
- y=(y*y)%c;
- b>>=1;
- }
- return (x%c);
- }
- //PLL -- > primefactor,power
- // Sum of Divisors of a number when number is represented as prime factors
- // N=p1^a * p2^ b *p3^c
- // =(p1^(a+1))/(p1-1) *(p2^(b+1))/(p2-1)....
- vector<PLL > factorize(LL a){
- vector<PLL >temp;
- for(ll x=2;a>=2;x++){
- if(a<2)break;
- if(a%x==0){
- LL c=0;
- while(a%x==0) c++,a/=x;
- temp.pb(make_pair(x,c));
- }
- }
- return temp;
- }
- int main(){
- LL a,b;
- cin>>a>>b;
- vector<PLL > temp=factorize(a);
- /*for(int i=0;i<temp.size();i++)
- cout<<temp[i].first<<" "<<temp[i].second<<endl;*/
- LL ans=1;
- for(int i=0;i<temp.size();i++){
- LL num=temp[i].first;
- LL cnt=temp[i].second;
- LL totalpower=cnt*b;
- LL first=modular(num,totalpower+1,mod);
- first--;
- // Division by (num-1) and mod is prime
- // now Let a=(num-1)
- // then multiply by a^(mod-2)%mod
- LL inverse=modular(num-1,mod-2,mod);
- ans*=(first*inverse)%mod;
- ans%=mod;
- if(ans<0)ans+=mod;
- }
- cout<<ans<<endl;
- GI;
- return 0;
- }
Add Comment
Please, Sign In to add comment