結果

問題 No.78 クジ付きアイスバー
コンテスト
ユーザー holeguma
提出日時 2015-08-14 12:14:37
言語 Java
(openjdk 26.0.2.1 + ACL)
コンパイル:
javac -J-Duser.language=en -encoding UTF8 -cp /opt/aclib/ac_library.jar _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true -cp .:/opt/aclib/ac_library.jar _class_
結果
WA  
実行時間 -
コード長 756 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,576 ms
コンパイル使用メモリ 86,276 KB
実行使用メモリ 41,088 KB
最終ジャッジ日時 2026-09-11 05:28:25
合計ジャッジ時間 54,522 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 4
other AC * 1 WA * 34
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import java.io.*;
import java.util.StringTokenizer;

class Main{

static final PrintWriter out=new PrintWriter(System.out);

public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
StringTokenizer st= new StringTokenizer(line);
int n=Integer.parseInt(st.nextToken());
int k=Integer.parseInt(st.nextToken());
int ans=0;
int[] ice=new int[n];
line=br.readLine();
for(int i=0;i<n;i++) ice[i]=line.charAt(i)-'0';
int eat=0;
while(true){
ans++;
eat+=1+ice[remainder(ans,n)-1];
if(eat>=k) break;
}
out.println(ans);
out.flush();
}
}

private static int remainder(int a,int b){
if(a%b==0) return b;
else return a%b;
}
}
0