CSES - HIIT Open 2017 - Results
Submission details
Task:Grid
Sender:Ace of Spades
Submission time:2017-05-27 11:29:26 +0300
Language:C++
Status:READY
Result:
Test results
testverdicttime
#10.04 sdetails
#20.05 sdetails
#30.05 sdetails
#40.04 sdetails
#50.04 sdetails
#60.06 sdetails
#70.04 sdetails
#80.05 sdetails
#90.06 sdetails
#100.05 sdetails
#110.06 sdetails
#120.04 sdetails
#130.06 sdetails
#140.04 sdetails
#150.04 sdetails
#160.07 sdetails
#170.06 sdetails
#180.04 sdetails
#190.05 sdetails
#200.05 sdetails
#210.05 sdetails
#220.04 sdetails
#230.05 sdetails
#240.04 sdetails
#250.04 sdetails
#260.04 sdetails
#270.03 sdetails

Code

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll n,m;
    cin>>n>>m;
    ll ans = 1;
    --n;
    ll q = 3;
    for(;n; n/=2) {
	if(n&1) {
	    ans = ans*q%m;
	}
	q = q*q%m;
    }
    cout<<ans<<'\n';
}

Test details

Test 1

Verdict:

input
10 20
11111111111111111111
11111111111111111111
11111111111111111111
11111111111111111111
...

correct output
8379

user output
3

Test 2

Verdict:

input
20 10
1111111111
1101111111
1111111111
1111111111
...

correct output
7880

user output
7

Test 3

Verdict:

input
10 20
11111111010111111101
11111110011011111111
11111100011111111111
11101111111111111111
...

correct output
5106

user output
3

Test 4

Verdict:

input
20 10
1111100111
1111111111
1011111110
1111111111
...

correct output
4563

user output
7

Test 5

Verdict:

input
10 20
11011011011111111110
11111010110110110001
11010010111101111010
01111111111110101111
...

correct output
3099

user output
3

Test 6

Verdict:

input
20 10
1110111111
1111111111
1101101110
0111110011
...

correct output
2973

user output
7

Test 7

Verdict:

input
10 20
01101101111101110101
10011111111111110111
01111101011010110011
10110101110110101011
...

correct output
2581

user output
3

Test 8

Verdict:

input
20 10
1110111001
0111001001
1111011011
1111111010
...

correct output
1660

user output
7

Test 9

Verdict:

input
10 20
11000000001100011111
11100111101100110110
11001110011110110101
10100001111011001111
...

correct output
1015

user output
3

Test 10

Verdict:

input
20 10
1000011001
1101111110
1000111111
1101101010
...

correct output
1135

user output
7

Test 11

Verdict:

input
10 20
10000101101101000110
00100010110011011011
11110111110101101011
11101100011101001011
...

correct output
708

user output
3

Test 12

Verdict:

input
20 10
1000011111
0001001100
0101110110
1111110001
...

correct output
394

user output
7

Test 13

Verdict:

input
10 20
00010111101111010011
11010001011010010110
10011001011010100011
01100011001000001100
...

correct output
294

user output
3

Test 14

Verdict:

input
20 10
0011001110
0000001111
1011100000
0000001001
...

correct output
166

user output
7

Test 15

Verdict:

input
10 20
10011010001011000110
00100000100000000000
00000110001000110001
01000000101100110101
...

correct output
87

user output
3

Test 16

Verdict:

input
20 10
0000110101
1000000001
0101100110
0100001010
...

correct output
134

user output
7

Test 17

Verdict:

input
10 20
00000001100001000100
00000100000010000001
00000100000010000010
10000010000000100000
...

correct output
5

user output
3

Test 18

Verdict:

input
20 10
0100001000
0100000000
0000010001
0000101000
...

correct output
4

user output
7

Test 19

Verdict:

input
10 20
00100010000100000000
00000000000000000000
00100000000000000000
00000001000000000010
...

correct output
0

user output
3

Test 20

Verdict:

input
20 10
0000010000
0000000000
1000000000
0000000000
...

correct output
0

user output
7

Test 21

Verdict:

input
10 20
00000000000000000000
00000000000000000000
00000000000000000000
00000000000000000000
...

correct output
0

user output
3

Test 22

Verdict:

input
20 10
0000000000
0000000000
0000000000
0000000000
...

correct output
0

user output
7

Test 23

Verdict:

input
3000 3000
111111111111111111111111111111...

correct output
19444691141193

user output
2667

Test 24

Verdict:

input
3000 3000
001011111110111101100001111011...

correct output
6150476374242

user output
2667

Test 25

Verdict:

input
3000 3000
001011000111011110110111111110...

correct output
1213493895016

user output
2667

Test 26

Verdict:

input
3000 3000
000000001001000010110001000001...

correct output
75998707871

user output
2667

Test 27

Verdict:

input
3000 3000
000000000000000000000000000000...

correct output
0

user output
2667