Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- ifstream in("moka.in");
- ofstream out("moka.out");
- unsigned long long puterel(unsigned long long a, unsigned long long b)
- {
- unsigned long long z[1001],p=a,i,c=0;
- while(b)
- {
- z[++c]=b%2;
- if(b%2==1)
- b--;
- else
- b/=2;
- }
- for(i=c-1;i>=1;i--)
- {
- if(z[i]==1)
- p=(p%1999999973*a%1999999973)%1999999973;
- else
- p=(p%1999999973)*(p%1999999973)%1999999973;
- }
- return p;
- }
- int main()
- {
- unsigned long long x,y,c;
- in>>x>>y;
- c=puterel(x,y);
- out<<c;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement