結果

問題 No.849 yuki国の分割統治
ユーザー ahe100ahe100
提出日時 2019-07-06 13:29:45
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 813 bytes
コンパイル時間 1,796 ms
コンパイル使用メモリ 170,060 KB
実行使用メモリ 9,856 KB
最終ジャッジ日時 2024-04-16 08:32:29
合計ジャッジ時間 5,359 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 WA -
testcase_07 AC 101 ms
6,940 KB
testcase_08 AC 110 ms
6,940 KB
testcase_09 AC 108 ms
6,940 KB
testcase_10 AC 105 ms
6,944 KB
testcase_11 AC 99 ms
6,940 KB
testcase_12 AC 99 ms
6,940 KB
testcase_13 AC 117 ms
6,940 KB
testcase_14 AC 110 ms
6,944 KB
testcase_15 AC 104 ms
6,940 KB
testcase_16 AC 140 ms
7,552 KB
testcase_17 AC 95 ms
6,940 KB
testcase_18 AC 145 ms
7,808 KB
testcase_19 AC 109 ms
6,940 KB
testcase_20 AC 130 ms
6,944 KB
testcase_21 AC 88 ms
6,944 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 145 ms
8,832 KB
testcase_26 AC 2 ms
6,944 KB
testcase_27 AC 2 ms
6,944 KB
testcase_28 AC 2 ms
6,940 KB
testcase_29 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;

/*
同値類に分ける
*/

ll a,b,c,d,n;
set<pair<ll,ll>> s;

long long gcd(long long a,long long b){
	if(b==0)return a;
	return gcd(b,a%b);
}

void init(){
	cin>>a>>b>>c>>d>>n;
	ll det=abs(a*d-b*c);
	ll g1=gcd(a,c);
	ll g2=gcd(b,d);
	rep(i,n){
		ll x,y;
		cin>>x>>y;
		if(det>0){
			s.insert({((d*x - c*y)%det + det)%det, ((-b*x + a*y)%det + det)%det});
		}else if(g1!=0){
			s.insert({(x%g1+g1)%g1, y});
		}else{
			s.insert({x, (y%g2+g2)%g2});
		}
	}
}

int main(void){
	init();
	cout<<s.size()<<endl;
	return 0;
}
0