結果

問題 No.321 (P,Q)-サンタと街の子供たち
ユーザー piyoko_212
提出日時 2015-12-21 18:23:41
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
RE  
実行時間 -
コード長 501 bytes
コンパイル時間 248 ms
コンパイル使用メモリ 34,252 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-18 18:03:48
合計ジャッジ時間 4,072 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 39 RE * 2
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:16:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   16 |         scanf("%d%d",&a,&b);
      |         ~~~~~^~~~~~~~~~~~~~
main.cpp:17:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   17 |         int n;scanf("%d",&n);
      |               ~~~~~^~~~~~~~~
main.cpp:18:34: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   18 |         for(int i=0;i<n;i++)scanf("%d%d",x+i,y+i);
      |                             ~~~~~^~~~~~~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>
#include<algorithm>
using namespace std;
int x[110000];
int y[110000];
int gcd(int a,int b){
	if(a<0)a=-a;
	if(b<0)b=-b;
	while(a){
		b%=a;int c=a;a=b;b=c;
	}
	return b;
}
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	int n;scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d%d",x+i,y+i);
	int g=gcd(a,b);
	int t=(a+b)/g;
	int ret=0;
	for(int i=0;i<n;i++){
		if(x[i]%g||y[i]%g)continue;
		int s=x[i]/g+y[i]/g;
		if(s<0)s=-s;
		if(t%2==0&&s%2!=0)continue;
		ret++;
	}
	printf("%d\n",ret);
}
0