結果
問題 | No.321 (P,Q)-サンタと街の子供たち |
ユーザー |
![]() |
提出日時 | 2015-12-15 00:24:57 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 24 ms / 2,000 ms |
コード長 | 1,875 bytes |
コンパイル時間 | 503 ms |
コンパイル使用メモリ | 79,188 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-06 22:01:19 |
合計ジャッジ時間 | 2,189 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 41 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:51:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 51 | scanf("%d%d%d",&p,&q,&n); | ~~~~~^~~~~~~~~~~~~~~~~~~ main.cpp:56:12: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 56 | scanf("%d%d",&x,&y); | ~~~~~^~~~~~~~~~~~~~ main.cpp:67:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 67 | scanf("%d%d",&x,&y); | ~~~~~^~~~~~~~~~~~~~
ソースコード
#include <cstdio> #include <algorithm> #include <stack> #include <queue> #include <deque> #include <vector> #include <string> #include <string.h> #include <cstdlib> #include <ctime> #include <cmath> #include <map> #include <set> #include <iostream> #include <sstream> #include <numeric> #include <cctype> #define fi first #define se second #define rep(i,n) for(int i = 0; i < n; ++i) #define rrep(i,n) for(int i = 1; i <= n; ++i) #define drep(i,n) for(int i = n-1; i >= 0; --i) #define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next) #define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++) #define rng(a) a.begin(),a.end() #define maxs(x,y) x = max(x,y) #define mins(x,y) x = min(x,y) #define pb push_back #define sz(x) (int)(x).size() #define pcnt __builtin_popcount #define snuke srand((unsigned)clock()+(unsigned)time(NULL)); #define df(x) int x = in() using namespace std; typedef long long int ll; typedef pair<int,int> P; typedef vector<int> vi; typedef vector<vi> vvi; inline int in() { int x; scanf("%d",&x); return x;} inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');} const int MX = 100005, INF = 1000010000; const ll LINF = 1000000000000000000ll; const double eps = 1e-10; ll gcd(ll x,ll y) { return y?gcd(y,x%y):x;} ll lcm(ll x, ll y) { return x/gcd(x,y)*y;} int main() { int p, q; int n; scanf("%d%d%d",&p,&q,&n); if (p == 0 && q == 0) { int ans = 0; rep(i,n) { int x, y; scanf("%d%d",&x,&y); if (x == 0 && y == 0) ++ans; } cout<<ans<<endl; return 0; } int g = gcd(p,q); p /= g; q /= g; int ans = 0; rep(i,n) { int x, y; scanf("%d%d",&x,&y); x = abs(x); y = abs(y); if (x%g || y%g) continue; x /= g; y /= g; if (x+y&1) { if (p+q&1) ++ans; } else ++ans; } cout<<ans<<endl; return 0; }