CSES - HIIT Open 2017 - Results
Submission details
Task:Book writing
Sender:oispa opiskelupaikka tefyllä ;...;
Submission time:2017-05-27 14:24:49 +0300
Language:C++
Status:READY
Result:
Test results
testverdicttime
#1ACCEPTED0.04 sdetails
#2ACCEPTED0.03 sdetails
#3ACCEPTED0.06 sdetails
#4ACCEPTED0.07 sdetails
#50.05 sdetails
#60.06 sdetails
#70.05 sdetails
#80.04 sdetails
#90.04 sdetails
#100.04 sdetails
#110.05 sdetails
#120.05 sdetails
#130.05 sdetails
#140.05 sdetails
#150.05 sdetails

Code

#include <bits/stdc++.h>

using namespace std;
long long n, m;

long long powasdas(long long b, long long e){
    if(e == 0)
        return 1;
    //cout << "taalla fak" << endl;
    long long lol = pow(b, e/2);
    lol = (lol*lol)%m;
    if(e%2 == 1){
        lol*=b;
        lol%=m;
    }
    //cout << b << " ^ " << e <<  " = " << lol << endl;
    return lol;
}

long long wtf(long long j){
    long long ans = 1;
    for(long long i = 0; i < j; ++i){
        ans+=2*wtf(i);
    }
    return ans;
}
int main(){
    
    cin >> n >> m;
    cout << powasdas(3, n-1)%m << endl;
    //cout << wtf(n) << endl;
    return 0;
}

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:

input
1000000000 151663903

correct output
82561644

user output
0

Test 6

Verdict:

input
143596027 174328522

correct output
28118869

user output
0

Test 7

Verdict:

input
147975017 915750433

correct output
463121246

user output
0

Test 8

Verdict:

input
135878271 839118400

correct output
539995449

user output
0

Test 9

Verdict:

input
298512964 952360555

correct output
580557712

user output
0

Test 10

Verdict:

input
529927635 923805382

correct output
726792503

user output
0

Test 11

Verdict:

input
318335201 844538572

correct output
543761245

user output
0

Test 12

Verdict:

input
424831430 113585403

correct output
11977911

user output
0

Test 13

Verdict:

input
365364871 255159067

correct output
164163032

user output
0

Test 14

Verdict:

input
953401405 641246153

correct output
32288812

user output
0

Test 15

Verdict:

input
937783204 624285687

correct output
213518688

user output
0