結果

問題 No.849 yuki国の分割統治
ユーザー square1001square1001
提出日時 2019-07-05 21:46:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,122 bytes
コンパイル時間 867 ms
コンパイル使用メモリ 83,592 KB
実行使用メモリ 10,240 KB
最終ジャッジ日時 2024-04-16 07:11:58
合計ジャッジ時間 3,991 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 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 RE -
testcase_07 RE -
testcase_08 AC 56 ms
7,040 KB
testcase_09 AC 50 ms
6,400 KB
testcase_10 AC 47 ms
5,504 KB
testcase_11 AC 46 ms
6,144 KB
testcase_12 AC 43 ms
5,376 KB
testcase_13 AC 58 ms
6,528 KB
testcase_14 AC 51 ms
6,016 KB
testcase_15 AC 50 ms
6,656 KB
testcase_16 AC 75 ms
8,832 KB
testcase_17 AC 40 ms
5,376 KB
testcase_18 AC 76 ms
9,216 KB
testcase_19 AC 49 ms
5,760 KB
testcase_20 AC 65 ms
7,680 KB
testcase_21 AC 32 ms
5,376 KB
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 AC 94 ms
10,240 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 RE -
testcase_29 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <set>
#include <cmath>
#include <vector>
#include <cassert>
#include <iostream>
using namespace std;
long long gcd(long long x, long long y) {
	if (y == 0) return x;
	return gcd(y, x % y);
}
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	long long A, B, C, D; int N;
	cin >> A >> B >> C >> D >> N;
	vector<long long> X(N), Y(N);
	for (int i = 0; i < N; ++i) {
		cin >> X[i] >> Y[i];
	}
	if (B * C - A * D != 0) {
		set<pair<long long, long long> > d;
		for (int i = 0; i < N; ++i) {
			long long xc = B * X[i] - A * Y[i];
			long long yc = D * X[i] - C * Y[i];
			bool xt = false, yt = false;
			if (xc < 0) xt = true, xc *= -1;
			xc %= abs(B * C - A * D);
			if (xt && xc != 0) xc = abs(B * C - A * D) - xc;
			if (yc < 0) yt = true, yc *= -1;
			yc %= abs(D * A - C * B);
			if (yt && yc != 0) yc = abs(D * A - C * B) - yc;
			d.insert(make_pair(xc, yc));
		}
		cout << d.size() << endl;
	}
	else {
		assert(false);
		long long gx = gcd(A, C), gy = gcd(B, D);
		set<long long> d;
		for (int i = 0; i < N; ++i) {
			d.insert(gy * X[i] - gx * Y[i]);
		}
		cout << d.size() << endl;
	}
	return 0;
}
0