結果

問題 No.321 (P,Q)-サンタと街の子供たち
ユーザー kotatsugamekotatsugame
提出日時 2020-03-04 09:34:46
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 537 bytes
コンパイル時間 477 ms
コンパイル使用メモリ 69,324 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-22 01:00:02
合計ジャッジ時間 3,416 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 36 ms
5,376 KB
testcase_15 AC 79 ms
5,376 KB
testcase_16 AC 33 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 40 ms
5,376 KB
testcase_19 AC 50 ms
5,376 KB
testcase_20 AC 79 ms
5,376 KB
testcase_21 AC 47 ms
5,376 KB
testcase_22 AC 15 ms
5,376 KB
testcase_23 AC 69 ms
5,376 KB
testcase_24 AC 18 ms
5,376 KB
testcase_25 AC 45 ms
5,376 KB
testcase_26 AC 76 ms
5,376 KB
testcase_27 AC 56 ms
5,376 KB
testcase_28 AC 54 ms
5,376 KB
testcase_29 AC 80 ms
5,376 KB
testcase_30 AC 3 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 40 ms
5,376 KB
testcase_33 AC 40 ms
5,376 KB
testcase_34 AC 28 ms
5,376 KB
testcase_35 AC 58 ms
5,376 KB
testcase_36 AC 3 ms
5,376 KB
testcase_37 AC 48 ms
5,376 KB
testcase_38 AC 39 ms
5,376 KB
testcase_39 AC 12 ms
5,376 KB
testcase_40 AC 75 ms
5,376 KB
testcase_41 AC 20 ms
5,376 KB
testcase_42 AC 66 ms
5,376 KB
testcase_43 AC 31 ms
5,376 KB
testcase_44 AC 58 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    7 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
using namespace std;
long P,Q;
int N;
long X[1<<17],Y[1<<17];
main()
{
	cin>>P>>Q>>N;
	for(int i=0;i<N;i++)cin>>X[i]>>Y[i];
	while(P!=0&&P!=Q)
	{
		Q%=2*P;
		if(Q>2*P-Q)Q=2*P-Q;
		swap(P,Q);
	}
	if(Q==0)
	{
		int cnt=0;
		for(int i=0;i<N;i++)cnt+=X[i]==0&&Y[i]==0;
		cout<<cnt<<endl;
		return 0;
	}
	int cnt=0;
	for(int i=0;i<N;i++)
	{
		if(P==0)
		{
			if(X[i]%Q==0&&Y[i]%Q==0)cnt++;
		}
		else
		{
			if(X[i]%P==0&&Y[i]%P==0&&(X[i]/P+Y[i]/P)%2==0)
			{
				cnt++;
			}
		}
	}
	cout<<cnt<<endl;
}
0