結果

問題 No.1097 Remainder Operation
ユーザー uni_pythonuni_python
提出日時 2020-06-26 22:39:03
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,017 bytes
コンパイル時間 961 ms
コンパイル使用メモリ 87,364 KB
実行使用メモリ 127,532 KB
最終ジャッジ日時 2023-09-18 06:12:51
合計ジャッジ時間 8,372 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,140 KB
testcase_01 AC 69 ms
71,400 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 341 ms
127,532 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    A=LI()
    Q=I()
    L=[0]*N#L[i]はX=iからの操作後の値
    
    for i in range(N):
        X=i
        L[i]=(X + A[X%N])
       
    M=45
    dub=[[0]*N for _ in range(M)]
    
    for j in range(N):
        dub[0][j]=j
        dub[1][j]=L[j]
        
    for i in range(2,M):
        for j in range(N):
            a=dub[i-1][j]#一つ上
            b=a%N
            jj=a%N
            diff=dub[i-1][jj]-jj
            dub[i][j]=a+diff
            
    # for i in range(3):
    #     print(dub[i])
            
    p=[1,1]
    for i in range(M+1):
        p.append(p[-1]*2)
 
    
    for _ in range(Q):
        K=I()
        ans=0
        for i in range(M-1,-1,-1):
            if p[i] <= K:
                ans+=dub[i][ans%N]
                K-=p[i]
        print(ans)
                
        


main()
0