結果
問題 | No.1410 A lot of Bit Operations |
ユーザー |
|
提出日時 | 2021-02-26 22:34:02 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,041 bytes |
コンパイル時間 | 259 ms |
コンパイル使用メモリ | 82,028 KB |
実行使用メモリ | 54,340 KB |
最終ジャッジ日時 | 2024-10-02 15:17:15 |
合計ジャッジ時間 | 3,318 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 42 WA * 2 |
ソースコード
def popcount(x):x = x - ((x >> 1) & 0x55555555)x = (x & 0x33333333) + ((x >> 2) & 0x33333333)x = (x + (x >> 4)) & 0x0f0f0f0fx = x + (x >> 8)x = x + (x >> 16)return x & 0x0000007fN = int(input())K = input()mod = 10**9+7def solve(S,N):if N==0:s_l = S & 1s15_l = (15-S) & 1return abs(s15_l-s_l) + 1res = 0for l in range(4):s_l = S>>l & 1s15_l = (15-S)>>l & 1if N==1:res += abs(s15_l-s_l)+1continuep = popcount(S)A = s_l * pow(2,3*N-3,mod) + p * pow(2,2*N-4,mod) * (pow(2,N-1,mod)-1)A %= modq = popcount(15-S)B = s15_l * pow(2,3*N-3,mod) + q * pow(2,2*N-4,mod) * (pow(2,N-1,mod)-1)if s_l > s15_l:res += A-B+pow(2,2*N-2,mod)res %= modelse:res += B-A+pow(2,2*N-2,mod)res %= modreturn resres = 0for i in range(8):if K[i]=="o":res += solve(i,N)res %= modprint(res)