結果

問題 No.321 (P,Q)-サンタと街の子供たち
ユーザー しらっ亭
提出日時 2016-06-06 21:11:26
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 1,446 bytes
コンパイル時間 1,151 ms
コンパイル使用メモリ 160,064 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-06 22:13:43
合計ジャッジ時間 2,814 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 41
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘void Main()’:
main.cpp:22:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   22 |   scanf("%d %d", &P, &Q);
      |   ~~~~~^~~~~~~~~~~~~~~~~
main.cpp:25:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   25 |   scanf("%d", &N);
      |   ~~~~~^~~~~~~~~~
main.cpp:34:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   34 |     scanf("%d %d", &x, &y);
      |     ~~~~~^~~~~~~~~~~~~~~~~

ソースコード

diff #
プレゼンテーションモードにする

#include <bits/stdc++.h>
using namespace std;
#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FORR(x,arr) for(auto&& x:arr)
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); i--)
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i,n) for (int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
#define BIT(n) (1LL<<(n))
#define SZ(x) ((int)(x).size())
#define fst first
#define snd second
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
typedef long long ll;
// -------------------------------------
void Main() {
int P, Q;
scanf("%d %d", &P, &Q);
int N;
scanf("%d", &N);
int gcd = P == 0 || Q == 0 ? 1 : __gcd(P, Q);
P /= gcd;
Q /= gcd;
int ans = 0;
REP(i, N) {
int x, y;
scanf("%d %d", &x, &y);
if (P == 0 && Q == 0) ans += (x == 0 && y == 0 ? 1 : 0);
else if (P == 0 || Q == 0) {
int r = P + Q;
ans += x % r == 0 && y % r == 0 ? 1 : 0;
}
else {
//
if (x % gcd == 0 && y % gcd == 0) {
x /= gcd;
y /= gcd;
// gcd(P,Q)
if (P % 2 && Q % 2) {
// P,Q
if ((x + y) % 2 == 0) ans++;
}
else ans++;
}
}
}
_P("%d\n", ans);
}
int main() { cin.tie(0); ios::sync_with_stdio(false); Main(); return 0; }
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0