結果

問題 No.1004 サイコロの実装 (2)
ユーザー CaptainCaptain
提出日時 2020-03-06 21:58:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,452 bytes
コンパイル時間 1,828 ms
コンパイル使用メモリ 165,124 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-04-22 07:34:03
合計ジャッジ時間 5,581 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,320 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 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 2 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 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 TLE -
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;
using ll = long long;
using Graph = vector<vector<int>>;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

template<class T> T pow(T a, T b) {
	if (b == 0)return 1;
	if (b % 2) {
		T ret = pow(a, (b - 1) / 2);
		return ret * ret * a;
	}
	else {
		T ret = pow(a, b / 2);
		return ret * ret;
	}
}
int main() {
	init();

	ll a, b, x, N; cin >> a >> b >> x >> N;
	ll m = pow(2LL, 32);
	vector<pair<ll, ll>>vec(2, { 0,0 });
	ll tk = 0, ao = 0;
	rep(i, N){
		x = (a * x + b) % m;
		if (i % 2 == 0) {
			tk = x % 6 + 1;
			if (tk % 2 == 0)vec[0].first++;
			else vec[0].second++;
		}
		else {
			ao = x % 6 + 1;
			if (ao % 2 == 0)vec[1].first++;
			else vec[1].second++;
		}
	}
	cout << min(vec[0].first, vec[0].second) << " " << min(vec[1].first, vec[1].second) << "\n";


		
	return 0;
}
0