結果

問題 No.1004 サイコロの実装 (2)
ユーザー キョウチクキョウチク
提出日時 2022-05-20 10:23:23
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,073 bytes
コンパイル時間 3,837 ms
コンパイル使用メモリ 79,768 KB
実行使用メモリ 58,696 KB
最終ジャッジ日時 2023-10-19 21:43:42
合計ジャッジ時間 15,409 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 177 ms
58,600 KB
testcase_01 AC 176 ms
58,428 KB
testcase_02 AC 177 ms
58,444 KB
testcase_03 AC 178 ms
58,324 KB
testcase_04 AC 178 ms
58,624 KB
testcase_05 AC 177 ms
58,356 KB
testcase_06 WA -
testcase_07 AC 181 ms
58,420 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 179 ms
58,348 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 WA -
testcase_30 RE -
testcase_31 WA -
testcase_32 RE -
testcase_33 TLE -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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);
    }
  }
}
0