結果
| 問題 |
No.321 (P,Q)-サンタと街の子供たち
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-07-01 22:38:28 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 27 ms / 2,000 ms |
| コード長 | 379 bytes |
| コンパイル時間 | 2,037 ms |
| コンパイル使用メモリ | 193,024 KB |
| 最終ジャッジ日時 | 2025-01-30 03:12:47 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 41 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:7:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
7 | scanf("%d%d%d",&p,&q,&n);
| ~~~~~^~~~~~~~~~~~~~~~~~~
main.cpp:10:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
10 | scanf("%d%d",&x,&y);
| ~~~~~^~~~~~~~~~~~~~
main.cpp:18:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
18 | scanf("%d%d",&x,&y);
| ~~~~~^~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
int p,q,d,f,n,x,y,s=0;
scanf("%d%d%d",&p,&q,&n);
if(p==0&&q==0){
while(n--){
scanf("%d%d",&x,&y);
if(x==0&&y==0)s++;
}
}else{
d=gcd(p,q);
if(p/d%2==0||q/d%2==0)f=1;
else f=0;
while(n--){
scanf("%d%d",&x,&y);
if(x%d==0&&y%d==0&&(f||(x/d+y/d)%2==0))s++;
}
}
printf("%d\n",s);
return 0;
}