結果

問題 No.1013 〇マス進む
ユーザー 37zigen
提出日時 2019-12-07 22:09:21
言語 Java
(openjdk 23)
結果
AC  
実行時間 1,348 ms / 2,000 ms
コード長 816 bytes
コンパイル時間 2,612 ms
コンパイル使用メモリ 77,212 KB
実行使用メモリ 138,928 KB
最終ジャッジ日時 2024-12-26 12:02:55
合計ジャッジ時間 49,430 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 62
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.math.*;
import java.io.*;

class Main
{
	public static void main(String[] args)
	{
		new Main().run();
	}
	
	void run(){
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		long K=sc.nextLong();
		int[] P=new int[N];
		long[][] add=new long[63][N];
		for(int i=0;i<N;++i){
			P[i]=sc.nextInt();
			add[0][i]=P[i];
		}
		for(int i=0;i+1<30;++i){
			for(int j=0;j<N;++j){
				add[i+1][j]=add[i][j]+add[i][(int)((j+add[i][j])%N)];
			}
		}
		PrintWriter pw=new PrintWriter(System.out);
		for(int i=0;i<N;++i){
			long res=K;
			long cur=i;
			for(int shift=0;shift<30;++shift){
				if((res>>shift)%2==1)
					cur=cur+add[shift][(int)(cur%N)];
			}
			pw.println(cur+1);
		}
		pw.close();
	}
	
	void tr(Object...objects){
		System.out.println(Arrays.deepToString(objects));
	}
}
0