結果
問題 | No.321 (P,Q)-サンタと街の子供たち |
ユーザー |
|
提出日時 | 2023-03-09 22:18:28 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 685 bytes |
コンパイル時間 | 1,500 ms |
コンパイル使用メモリ | 167,464 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-18 03:05:09 |
合計ジャッジ時間 | 3,240 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 36 WA * 5 |
ソースコード
#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 >= 2){ 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'; }