結果

問題 No.1004 サイコロの実装 (2)
ユーザー Hasegawa_frogHasegawa_frog
提出日時 2020-03-06 21:34:40
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 931 bytes
コンパイル時間 1,411 ms
コンパイル使用メモリ 168,216 KB
実行使用メモリ 10,496 KB
最終ジャッジ日時 2024-10-14 04:25:59
合計ジャッジ時間 5,205 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 6 WA * 18 TLE * 1 -- * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
 
#define mod 1000000007
#define inf 1000000000
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
 
int main(){
  ll a, b, x, n;
  cin >> a >> b >> x >> n;

  ll m = pow(2, 32);

  ll prex = x, xi;
  vector<ll> ans1(2,0), ans2(2,0);
  for(ll i = 0; i < n; i++){
    xi = (a * prex + b) % m;
    ll deme = xi % 6 + 1;
    if(deme % 2 == 0) ans1[0]++;
    else ans1[1]++;
    prex = xi;
    //cout << xi << endl;
    xi = (a * prex + b) % m;
    deme = xi % 6 + 1;
    if(deme % 2 == 0) ans2[0]++;
    else ans2[1]++;
    prex = xi;
    //cout << xi << endl;
  }

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