結果
問題 |
No.321 (P,Q)-サンタと街の子供たち
|
ユーザー |
|
提出日時 | 2017-10-18 17:50:43 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 863 bytes |
コンパイル時間 | 1,430 ms |
コンパイル使用メモリ | 167,300 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-18 14:48:57 |
合計ジャッジ時間 | 5,702 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 13 WA * 26 RE * 2 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i)) #define all(x) (x).begin(),(x).end() #define pb push_back #define fi first #define se second #define dbg(x) cout<<#x" = "<<((x))<<endl template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;} template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;} int solve(ll p, ll q, ll x, ll y) { ll a = p+q, b = p-q; ll g = __gcd(a,b); ll c = abs(x+y); return (c%g==0); } int main() { ll p,q; cin >>p >>q; if(p<q) swap(p,q); int n; cin >>n; int ans = 0; while(n--) { ll x,y; cin >>x >>y; ans += solve(p,q,x,y); } cout << ans << endl; return 0; }