結果
問題 | No.321 (P,Q)-サンタと街の子供たち |
ユーザー |
|
提出日時 | 2023-03-09 22:19:54 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 27 ms / 2,000 ms |
コード長 | 685 bytes |
コンパイル時間 | 1,527 ms |
コンパイル使用メモリ | 167,640 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-18 03:05:12 |
合計ジャッジ時間 | 3,187 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 41 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; int main(){ ios::sync_with_stdio(false); cin.tie(0); int P, Q, N, g, ans = 0; cin >> P >> Q >> N; g = __gcd(P, Q); bool flag = false; if(g >= 1){ flag = (P / g % 2 == Q / g % 2); } for(int i = 0; i < N; i++){ int x, y; cin >> x >> y; if(g == 0){ ans += (x == 0 && y == 0); continue; } if(x % g == 0 && y % g == 0){ if(flag){ x /= g, y /= g; ans += (x + y) % 2 == 0; }else{ ans++; } } } cout << ans << '\n'; }