Task: | Book writing |
Sender: | Game of Nolife |
Submission time: | 2017-05-27 11:22:38 +0300 |
Language: | C++ |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.04 s | details |
#2 | ACCEPTED | 0.07 s | details |
#3 | ACCEPTED | 0.04 s | details |
#4 | ACCEPTED | 0.06 s | details |
#5 | ACCEPTED | 0.06 s | details |
#6 | ACCEPTED | 0.04 s | details |
#7 | ACCEPTED | 0.04 s | details |
#8 | ACCEPTED | 0.05 s | details |
#9 | ACCEPTED | 0.03 s | details |
#10 | ACCEPTED | 0.03 s | details |
#11 | ACCEPTED | 0.04 s | details |
#12 | ACCEPTED | 0.06 s | details |
#13 | ACCEPTED | 0.04 s | details |
#14 | ACCEPTED | 0.05 s | details |
#15 | ACCEPTED | 0.04 s | details |
Code
#include <bits/stdc++.h> #define F first #define S second #define X real() #define Y imag() using namespace std; typedef long long ll; typedef long double ld; ll pot(ll a, ll e, ll mod) { ll ret=1; while (e>0) { if (e%2==1) { ret*=a; ret%=mod; } a*=a; a%=mod; e/=2; } return ret; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); ll n,m; cin>>n>>m; cout<<pot(3,n-1,m)%m<<"\n"; }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
1 1 |
correct output |
---|
0 |
user output |
---|
0 |
Test 2
Verdict: ACCEPTED
input |
---|
1 97 |
correct output |
---|
1 |
user output |
---|
1 |
Test 3
Verdict: ACCEPTED
input |
---|
2 97 |
correct output |
---|
3 |
user output |
---|
3 |
Test 4
Verdict: ACCEPTED
input |
---|
3 97 |
correct output |
---|
9 |
user output |
---|
9 |
Test 5
Verdict: ACCEPTED
input |
---|
1000000000 151663903 |
correct output |
---|
82561644 |
user output |
---|
82561644 |
Test 6
Verdict: ACCEPTED
input |
---|
143596027 174328522 |
correct output |
---|
28118869 |
user output |
---|
28118869 |
Test 7
Verdict: ACCEPTED
input |
---|
147975017 915750433 |
correct output |
---|
463121246 |
user output |
---|
463121246 |
Test 8
Verdict: ACCEPTED
input |
---|
135878271 839118400 |
correct output |
---|
539995449 |
user output |
---|
539995449 |
Test 9
Verdict: ACCEPTED
input |
---|
298512964 952360555 |
correct output |
---|
580557712 |
user output |
---|
580557712 |
Test 10
Verdict: ACCEPTED
input |
---|
529927635 923805382 |
correct output |
---|
726792503 |
user output |
---|
726792503 |
Test 11
Verdict: ACCEPTED
input |
---|
318335201 844538572 |
correct output |
---|
543761245 |
user output |
---|
543761245 |
Test 12
Verdict: ACCEPTED
input |
---|
424831430 113585403 |
correct output |
---|
11977911 |
user output |
---|
11977911 |
Test 13
Verdict: ACCEPTED
input |
---|
365364871 255159067 |
correct output |
---|
164163032 |
user output |
---|
164163032 |
Test 14
Verdict: ACCEPTED
input |
---|
953401405 641246153 |
correct output |
---|
32288812 |
user output |
---|
32288812 |
Test 15
Verdict: ACCEPTED
input |
---|
937783204 624285687 |
correct output |
---|
213518688 |
user output |
---|
213518688 |