Task: | Bit Strings |
Sender: | Piltit |
Submission time: | 2019-05-25 12:01:23 +0300 |
Language: | C++ |
Status: | READY |
Result: | WRONG ANSWER |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.01 s | details |
#2 | ACCEPTED | 0.02 s | details |
#3 | ACCEPTED | 0.02 s | details |
#4 | ACCEPTED | 0.02 s | details |
#5 | ACCEPTED | 0.03 s | details |
#6 | ACCEPTED | 0.01 s | details |
#7 | ACCEPTED | 0.02 s | details |
#8 | ACCEPTED | 0.02 s | details |
#9 | ACCEPTED | 0.01 s | details |
#10 | ACCEPTED | 0.02 s | details |
#11 | WRONG ANSWER | 0.04 s | details |
#12 | ACCEPTED | 0.04 s | details |
#13 | WRONG ANSWER | 0.04 s | details |
#14 | WRONG ANSWER | 0.04 s | details |
#15 | WRONG ANSWER | 0.04 s | details |
#16 | WRONG ANSWER | 0.04 s | details |
#17 | WRONG ANSWER | 0.03 s | details |
#18 | WRONG ANSWER | 0.04 s | details |
Code
#include <iostream> using namespace std; int d[1010101]; const int P = (1e9)+7; int main() { d[0] = 1; int n, k; cin >> n >> k; for (int i = 1; i <= n; i++) { if (i < k) d[i] = (1<<i)%P; else if (i == k) d[i] = ((1<<i)-1)%P; else d[i] = (d[i-1]*2 % P - d[i-k-1] % P) % P; } cout << d[n] << endl; }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
1 1 |
correct output |
---|
1 |
user output |
---|
1 |
Test 2
Verdict: ACCEPTED
input |
---|
2 1 |
correct output |
---|
1 |
user output |
---|
1 |
Test 3
Verdict: ACCEPTED
input |
---|
2 2 |
correct output |
---|
3 |
user output |
---|
3 |
Test 4
Verdict: ACCEPTED
input |
---|
3 1 |
correct output |
---|
1 |
user output |
---|
1 |
Test 5
Verdict: ACCEPTED
input |
---|
3 2 |
correct output |
---|
5 |
user output |
---|
5 |
Test 6
Verdict: ACCEPTED
input |
---|
3 3 |
correct output |
---|
7 |
user output |
---|
7 |
Test 7
Verdict: ACCEPTED
input |
---|
4 1 |
correct output |
---|
1 |
user output |
---|
1 |
Test 8
Verdict: ACCEPTED
input |
---|
4 2 |
correct output |
---|
8 |
user output |
---|
8 |
Test 9
Verdict: ACCEPTED
input |
---|
4 3 |
correct output |
---|
13 |
user output |
---|
13 |
Test 10
Verdict: ACCEPTED
input |
---|
4 4 |
correct output |
---|
15 |
user output |
---|
15 |
Test 11
Verdict: WRONG ANSWER
input |
---|
654321 123456 |
correct output |
---|
796245691 |
user output |
---|
-923594276 |
Test 12
Verdict: ACCEPTED
input |
---|
1000000 1 |
correct output |
---|
1 |
user output |
---|
1 |
Test 13
Verdict: WRONG ANSWER
input |
---|
1000000 10 |
correct output |
---|
256933600 |
user output |
---|
-743066407 |
Test 14
Verdict: WRONG ANSWER
input |
---|
1000000 100 |
correct output |
---|
142013415 |
user output |
---|
289521623 |
Test 15
Verdict: WRONG ANSWER
input |
---|
1000000 1000 |
correct output |
---|
899626120 |
user output |
---|
-597734616 |
Test 16
Verdict: WRONG ANSWER
input |
---|
1000000 10000 |
correct output |
---|
374265948 |
user output |
---|
-472654440 |
Test 17
Verdict: WRONG ANSWER
input |
---|
1000000 100000 |
correct output |
---|
388134512 |
user output |
---|
259195923 |
Test 18
Verdict: WRONG ANSWER
input |
---|
1000000 1000000 |
correct output |
---|
235042058 |
user output |
---|
0 |