結果

問題 No.321 (P,Q)-サンタと街の子供たち
ユーザー ctyl_0
提出日時 2015-12-14 02:33:43
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 84 ms / 2,000 ms
コード長 1,532 bytes
コンパイル時間 765 ms
コンパイル使用メモリ 84,360 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-06 21:51:49
合計ジャッジ時間 3,530 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define var auto
#define mod 1000000007
#define inf 2147483647
#define nil -1
#define mp make_pair
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p) {
if(p){
cout << fixed << setprecision(p) << a << "\n";
}
else{
cout << a << "\n";
}
}
// end of template
int gcd(int a, int b){
if (b == 0) {
return a;
}
else{
return gcd(b, a % b);
}
}
bool judge(int x, int y, int p, int q, int g){
if (x % g != 0 || y % g != 0 || (x + y) % gcd(p + q, abs(p - q)) != 0) {
return false;
}
return true;
}
bool judge0(int x, int y){
if (x == 0 && y == 0) {
return true;
}
return false;
}
int main() {
cin.tie(0);
// source code
int P, Q, N;
cin >> P >> Q >> N;
int G = gcd(P, Q);
int cnt = 0;
if (P == 0 && Q == 0) {
rep(i, N){
int x, y;
cin >> x >> y;
cnt += judge0(x, y) ? 1 : 0;
}
}
else{
rep(i, N){
int x, y;
cin >> x >> y;
cnt += judge(x, y, P, Q, G) ? 1 : 0;
}
}
cout << cnt << endl;
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0