結果

問題 No.1004 サイコロの実装 (2)
ユーザー beet
提出日時 2020-03-06 22:12:58
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 628 bytes
コンパイル時間 2,577 ms
コンパイル使用メモリ 191,372 KB
最終ジャッジ日時 2025-01-09 05:15:54
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 6 WA * 19 TLE * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  using uint = unsigned long long int;
  uint a,b,x;
  long long n;
  cin>>a>>b>>x>>n;

  uint cs[2][2]={};
  uint ps[2]={};
  for(long long i=0;i<n;i++){
    x=a*x+b;
    x%=(1LL<<32);
    ps[i&1]=(ps[i&1]+x+1)&1;
    cs[i&1][ps[i&1]]++;
  }

  cout<<min(cs[0][0],cs[0][1])<<" "<<min(cs[1][0],cs[1][1])<<endl;
  return 0;
}
0