結果
問題 |
No.1097 Remainder Operation
|
ユーザー |
![]() |
提出日時 | 2020-06-26 22:53:16 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 628 bytes |
コンパイル時間 | 120 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 27,244 KB |
最終ジャッジ日時 | 2024-07-04 23:04:43 |
合計ジャッジ時間 | 10,859 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 19 WA * 2 |
ソースコード
N=int(input()) A=list(map(int,input().split())) E=[(A[i]+i)%N for i in range(N)] NOW=0 USED=[0]*N ANS=[] while USED[NOW]==0: USED[NOW]=1 ANS.append(NOW) NOW=E[NOW] USED=[0]*N NOW=ANS[-1] ANS.pop() LOOP=0 Begin=len(ANS)-1 while USED[NOW]==0: USED[NOW]=1 LOOP+=1 ANS.append(NOW) NOW=E[NOW] SUM=[0] for a in ANS: SUM.append(SUM[-1]+A[a]) LSUM=SUM[Begin+LOOP]-SUM[Begin] Q=int(input()) for tests in range(Q): K=int(input()) if K<len(ANS): print(SUM[K]) else: rest=K-(len(ANS)-1) LL=(rest+LOOP-1)//LOOP print(SUM[K-LL*LOOP]+LL*LSUM)