Submission #3608650
Source Code Expand
N, K = map(int, input().split()) MOD = 10 ** 9 + 7 i = 1 M = N div = [] while i * i <= N: if N % i == 0: div.append(i) if N // i != i: div.append(N // i) i += 1 div = sorted(div) N1 = len(div) num = [0] * (N1 + 1) ans = 0 for i in range(N1): num[i] = pow(K, (div[i] + 1) // 2, MOD) for j in range(i): if div[i] % div[j] == 0: num[i] = num[i] - num[j] + MOD num[i] %= MOD if div[i] % 2 == 0: ans += div[i] * num[i] // 2 ans %= MOD else: ans += div[i] * num[i] ans %= MOD print(ans)
Submission Info
Submission Time | |
---|---|
Task | F - Rotated Palindromes |
User | ys5678910 |
Language | PyPy3 (2.4.0) |
Score | 1000 |
Code Size | 631 Byte |
Status | AC |
Exec Time | 219 ms |
Memory | 41580 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 1000 / 1000 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt |
All | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt, 1_24.txt, 1_25.txt, 1_26.txt, 1_27.txt, 1_28.txt, 1_29.txt, 1_30.txt, 1_31.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00.txt | AC | 166 ms | 38256 KB |
0_01.txt | AC | 164 ms | 38256 KB |
0_02.txt | AC | 166 ms | 38256 KB |
0_03.txt | AC | 174 ms | 39024 KB |
1_00.txt | AC | 168 ms | 38256 KB |
1_01.txt | AC | 167 ms | 38256 KB |
1_02.txt | AC | 180 ms | 39024 KB |
1_03.txt | AC | 176 ms | 39024 KB |
1_04.txt | AC | 165 ms | 38256 KB |
1_05.txt | AC | 167 ms | 38256 KB |
1_06.txt | AC | 166 ms | 38256 KB |
1_07.txt | AC | 166 ms | 38256 KB |
1_08.txt | AC | 174 ms | 39024 KB |
1_09.txt | AC | 174 ms | 39024 KB |
1_10.txt | AC | 175 ms | 39024 KB |
1_11.txt | AC | 178 ms | 39024 KB |
1_12.txt | AC | 169 ms | 38512 KB |
1_13.txt | AC | 171 ms | 38512 KB |
1_14.txt | AC | 170 ms | 38512 KB |
1_15.txt | AC | 169 ms | 38512 KB |
1_16.txt | AC | 210 ms | 41580 KB |
1_17.txt | AC | 215 ms | 41580 KB |
1_18.txt | AC | 213 ms | 41580 KB |
1_19.txt | AC | 212 ms | 41580 KB |
1_20.txt | AC | 210 ms | 40048 KB |
1_21.txt | AC | 203 ms | 40048 KB |
1_22.txt | AC | 203 ms | 40048 KB |
1_23.txt | AC | 219 ms | 40048 KB |
1_24.txt | AC | 172 ms | 38512 KB |
1_25.txt | AC | 177 ms | 38512 KB |
1_26.txt | AC | 170 ms | 38512 KB |
1_27.txt | AC | 172 ms | 38512 KB |
1_28.txt | AC | 172 ms | 38512 KB |
1_29.txt | AC | 169 ms | 38512 KB |
1_30.txt | AC | 169 ms | 38512 KB |
1_31.txt | AC | 168 ms | 38512 KB |