結果
| 問題 |
No.1004 サイコロの実装 (2)
|
| コンテスト | |
| ユーザー |
キョウチク
|
| 提出日時 | 2022-05-20 10:23:23 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,073 bytes |
| コンパイル時間 | 3,905 ms |
| コンパイル使用メモリ | 79,936 KB |
| 実行使用メモリ | 57,264 KB |
| 最終ジャッジ日時 | 2024-09-19 17:43:49 |
| 合計ジャッジ時間 | 14,956 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 6 WA * 20 RE * 5 TLE * 1 -- * 6 |
ソースコード
import java.util.*;
public class Test11 {
final long a,b,m;
long x;
Test11(long a,long b,long x){
this.a=a;
this.b=b;
this.m=(long)Integer.MAX_VALUE+Integer.MAX_VALUE+2;
this.x=x%m;
}
int roll(){
x=(a*x+b)%m;
int tmp=(int)(x%6)+1;
return tmp;
}
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
String[] line;
line=sc.nextLine().split(" ");
Test11 dice;
{
long a=Long.parseLong(line[0]);
long b=Long.parseLong(line[1]);
long x=Long.parseLong(line[2]);
dice=new Test11(a,b,x);
}
int n=Integer.parseInt(line[3]);
int[] stayed=new int[2],black=new int[2],white=new int[2];
for(int i=0;i<2;i++) stayed[i]=black[i]=white[i]=0;
for(int i=0;i<n*2;i++){
int prayer=i%2;
int tmp=stayed[prayer]+dice.roll();
stayed[prayer]=tmp;
black[prayer]+=tmp%2;
white[prayer]+=(tmp+1)%2;
}
{
String result=(black[0]/2+white[0]/2)+" ";
result+=(black[1]/2+white[1]/2);
System.out.println(result);
}
}
}
キョウチク