結果
問題 | No.321 (P,Q)-サンタと街の子供たち |
ユーザー |
|
提出日時 | 2015-12-14 07:00:23 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 26 ms / 2,000 ms |
コード長 | 1,022 bytes |
コンパイル時間 | 1,285 ms |
コンパイル使用メモリ | 157,952 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-06 21:59:04 |
合計ジャッジ時間 | 2,777 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 41 |
コンパイルメッセージ
main.cpp: In function ‘void RI(int&, T& ...) [with T = {}]’: main.cpp:15:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 15 | scanf("%d",&head); | ~~~~~^~~~~~~~~~~~ main.cpp: In function ‘void RI(int&, T& ...) [with T = {int}]’: main.cpp:15:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
ソースコード
#include<bits/stdc++.h> #define REP(x,y,z) for(int x=y;x<=z;x++) #define FORD(x,y,z) for(int x=y;x>=z;x--) #define MSET(x,y) memset(x,y,sizeof(x)) #define FOR(x,y) for(__typeof(y.begin()) x=y.begin();x!=y.end();x++) #define F first #define S second #define MP make_pair #define PB push_back #define SZ size() #define M void RI(){} template<typename... T> void RI( int& head, T&... tail ) { scanf("%d",&head); RI(tail...); } using namespace std; typedef long long LL; bool check(int p,int q,int div,int x,int y) { if(x==0 && y==0) return true; if(div==0) return false; if(x%div || y%div) return false; p /= div; q /= div; x /= div; y /= div; if(p%2==0 || q%2==0) return true; if(x%2 != y%2) return false; return true; } int main() { int p,q,gcd; int n,x,y; int ans; while(~scanf("%d %d",&p,&q)) { ans=0; p=abs(p); q=abs(q); gcd = __gcd(p,q); RI(n); while(n--) { RI(x,y); x = abs(x); y = abs(y); if(check(p,q,gcd,x,y)) ans++; } printf("%d\n",ans); } return 0; }