結果
| 問題 | 
                            No.321 (P,Q)-サンタと街の子供たち
                             | 
                    
| コンテスト | |
| ユーザー | 
                             tnakao0123
                         | 
                    
| 提出日時 | 2025-02-04 16:09:32 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 990 bytes | 
| コンパイル時間 | 713 ms | 
| コンパイル使用メモリ | 43,776 KB | 
| 実行使用メモリ | 6,824 KB | 
| 最終ジャッジ日時 | 2025-02-04 16:09:38 | 
| 合計ジャッジ時間 | 4,748 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 30 WA * 11 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:28:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   28 |   scanf("%d%d%d", &p, &q, &n);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
main.cpp:29:36: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   29 |   for (int i = 0; i < n; i++) scanf("%d%d", xs + i, ys + i);
      |                               ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
            
            ソースコード
/* -*- coding: utf-8 -*-
 *
 * 321.cc: No.321 (P,Q)-繧オ繝ウ繧ソ縺ィ陦励・蟄蝉セ帙◆縺。 - yukicoder
 */
#include<cstdio>
#include<algorithm>
#include<numeric>
 
using namespace std;
/* constant */
const int MAX_N = 100000;
/* typedef */
/* global variables */
int xs[MAX_N], ys[MAX_N];
/* subroutines */
/* main */
int main() {
  int p, q, n;
  scanf("%d%d%d", &p, &q, &n);
  for (int i = 0; i < n; i++) scanf("%d%d", xs + i, ys + i);
  int cnt = 0;
  if (p == 0 && q == 0) {
    for (int i = 0; i < n; i++)
      if (xs[i] == 0 && ys[i] == 0) cnt++;
  }
  else if (p == 0 || q == 0) {
    int d = max(p, q);
    for (int i = 0; i < n; i++)
      if (xs[i] % d == 0 && ys[i] % d == 0) cnt++;
  }
  else { // p > 0 && q > 0
    int g = gcd(p, q);
    p /= g, q /= g;
    bool f = ((p + q) & 1);
    for (int i = 0; i < n; i++)
      if (xs[i] % g == 0 && ys[i] % g == 0 &&
	  (abs(xs[i]) == abs(ys[i]) || f)) cnt++;
  }
  printf("%d\n", cnt);
  
  return 0;
}
            
            
            
        
            
tnakao0123