結果
| 問題 | No.321 (P,Q)-サンタと街の子供たち |
| コンテスト | |
| ユーザー |
FF256grhy
|
| 提出日時 | 2015-12-14 01:52:50 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 16 ms / 2,000 ms |
| コード長 | 682 bytes |
| 記録 | |
| コンパイル時間 | 353 ms |
| コンパイル使用メモリ | 41,376 KB |
| 実行使用メモリ | 7,720 KB |
| 最終ジャッジ日時 | 2026-03-28 11:57:58 |
| 合計ジャッジ時間 | 1,723 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 41 |
ソースコード
#include <stdio.h>
int p, q, n, x[100000], y[100000];
int gcd(int a, int b) {
if(b == 0) { return a; }
return gcd(b, a % b);
}
int main(void) {
scanf("%d%d%d", &p, &q, &n);
int i;
for(i = 0; i < n; i++) {
scanf("%d%d", &x[i], &y[i]);
}
if(p < q) { int temp = p; p = q; q = temp; }
int d = gcd(p, q), counter = 0;
for(i = 0; i < n; i++) {
if(q != 0) {
if(
x[i] % d == 0 && y[i] % d == 0 &&
( ((p + q) / d) % 2 == 1 || ((x[i] + y[i]) / d) % 2 == 0 )
) { counter++; }
} else if(p != 0) {
if( x[i] % p == 0 && y[i] % p == 0 ) { counter++; }
} else {
if( x[i] == 0 && y[i] == 0 ) { counter++; }
}
}
printf("%d\n", counter);
return 0;
}
FF256grhy