結果

問題 No.849 yuki国の分割統治
ユーザー chocoruskchocorusk
提出日時 2019-03-16 20:33:24
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,095 bytes
コンパイル時間 1,228 ms
コンパイル使用メモリ 103,724 KB
実行使用メモリ 60,416 KB
最終ジャッジ日時 2024-04-16 06:56:46
合計ジャッジ時間 5,079 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 TLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
ll gcd(ll a, ll b){
	if(b==0) return a;
	return gcd(b, a%b);
}
void extgcd(ll &a, ll &b, ll &c, ll &d){
    if(b==0) return;
    ll q=d/b;
    d-=q*b, c-=q*a;
    swap(a, c); swap(b, d);
    extgcd(a, b, c, d);
}
random_device rnd;
mt19937_64 mt(rnd());
uniform_int_distribution<ll> rndn(0, 1e9);
int main()
{
	ll a, b, c, d;
	cin>>a>>b>>c>>d;
    extgcd(a, b, c, d);
    if(a<0) a=-a;
    int n=a*d;
	cout<<n<<endl;
	int ct=0;
    set<P> st;
    while(ct<n){
        ll x=rndn(mt), y=rndn(mt);
        ll r=y%d;
        ll q=(y-r)/d;
        ll s=((x-c*q)%a+a)%a;
        if(st.find(P(s, r))!=st.end()) continue;
        st.insert(P(s, r));
        ct++;
        cout<<x<<" "<<y<<endl;
    }
	return 0;
}
0