結果

問題 No.1004 サイコロの実装 (2)
ユーザー Hasegawa_frogHasegawa_frog
提出日時 2020-03-06 21:34:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 931 bytes
コンパイル時間 1,685 ms
コンパイル使用メモリ 166,820 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-04-22 05:15:15
合計ジャッジ時間 5,648 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
10,752 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 WA -
testcase_07 AC 2 ms
5,376 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 1 ms
5,376 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 TLE -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
権限があれば一括ダウンロードができます

ソースコード

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