結果
問題 | No.1097 Remainder Operation |
ユーザー |
![]() |
提出日時 | 2020-06-27 17:09:02 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 404 ms / 2,000 ms |
コード長 | 572 bytes |
コンパイル時間 | 153 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 29,544 KB |
最終ジャッジ日時 | 2024-07-05 17:55:08 |
合計ジャッジ時間 | 6,448 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 21 |
ソースコード
import sysinput=lambda: sys.stdin.readline().rstrip()n=int(input())A=[int(i) for i in input().split()]x=0C=[False]*nC[0]=Trueimport collectionsD=collections.defaultdict(int)Ans=[]ct=1while True:Ans.append(x)if D[x%n]!=0:st=D[x%n]ed=ctAns.append(x+A[x%n])breakelse:D[x%n]=ctct+=1x+=A[x%n]q=int(input())for _ in range(q):k=int(input())if k<=ed:print(Ans[k])else:ans=Ans[st]loop=(k-st)//(ed-st)ans+=loop*(Ans[ed]-Ans[st])rem=(k-st)%(ed-st)ans+=Ans[st+rem]-Ans[st]print(ans)