結果
| 問題 |
No.849 yuki国の分割統治
|
| コンテスト | |
| ユーザー |
risujiroh
|
| 提出日時 | 2019-07-05 23:17:44 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 72 ms / 2,000 ms |
| コード長 | 669 bytes |
| コンパイル時間 | 2,696 ms |
| コンパイル使用メモリ | 172,372 KB |
| 実行使用メモリ | 8,704 KB |
| 最終ジャッジ日時 | 2024-10-06 23:04:17 |
| 合計ジャッジ時間 | 4,403 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 26 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
int main() {
cin.tie(nullptr); ios::sync_with_stdio(false);
lint a, b, c, d; cin >> a >> b >> c >> d;
while (a) {
lint q = c / a;
swap(c -= q * a, a);
swap(d -= q * b, b);
}
b = abs(b);
int n; cin >> n;
set< pair<lint, lint> > se;
while (n--) {
lint x, y; cin >> x >> y;
if (!c) {
se.emplace(x, y % __gcd(b, d));
continue;
}
lint q = x / c;
x -= q * c;
y -= q * d;
se.emplace(x, b ? (y % b + b) % b : y);
}
cout << se.size() << '\n';
}
risujiroh