Cod sursa(job #2905393)
Utilizator | Data | 21 mai 2022 12:19:16 | |
---|---|---|---|
Problema | Interclasari | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.63 kb |
#include <fstream>
using namespace std;
ifstream fin("modulo.in");
ofstream fout("modulo.out");
long long a,b;
unsigned long long p;
int c;
int main()
{
fin>>a>>b>>c;
if(a%c==0)
{
fout<<0;
}
else
{
if(b%2==0)
{
p=1;
while(b!=0)
{
p=p*a*a;
b-=2;
}
}
else if(b%2==1)
{
p=a;
b--;
while(b!=0)
{
p=p*a*a;
b-=2;
}
}
fout<<p%c;
}
return 0;
}