結果
| 問題 |
No.849 yuki国の分割統治
|
| コンテスト | |
| ユーザー |
tarattata1
|
| 提出日時 | 2019-07-06 14:57:31 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 69 ms / 2,000 ms |
| コード長 | 2,012 bytes |
| コンパイル時間 | 890 ms |
| コンパイル使用メモリ | 80,196 KB |
| 実行使用メモリ | 9,728 KB |
| 最終ジャッジ日時 | 2024-10-06 23:53:59 |
| 合計ジャッジ時間 | 2,740 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 26 |
コンパイルメッセージ
main.cpp: In function ‘int main(int, char**)’:
main.cpp:33:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
33 | scanf("%lld%lld%lld%lld%d", &a, &b, &c, &d, &n);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:38:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
38 | scanf("%lld%lld", &x[i], &y[i]);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996)
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;
ll gcd(ll a, ll b) {
if(b == 0) return a;
return gcd(b,a%b);
}
int main(int argc, char* argv[])
{
ll a,b,c,d;
int n;
scanf("%lld%lld%lld%lld%d", &a, &b, &c, &d, &n);
vector<ll> x(n),y(n);
int i;
for(i=0; i<n; i++) {
scanf("%lld%lld", &x[i], &y[i]);
}
ll d1=a, a1=d, b1=-b, c1=-c;
ll det=a*d-b*c;
if(det!=0) {
map<pair<ll,ll>, int> z;
det = abs(det);
for(i=0; i<n; i++) {
ll tmp0 = a1*x[i]+c1*y[i];
ll tmp1 = b1*x[i]+d1*y[i];
tmp0 = (tmp0%det + det)%det;
tmp1 = (tmp1%det + det)%det;
z[make_pair(tmp0,tmp1)]++;
}
printf("%d\n", (int)z.size());
}
else {
map<pair<ll,ll>, int> z;
int flag=0;
if(a*b<0) flag=1;
a = (a*c!=0? gcd(abs(a),abs(c)): 0);
b = (b*d!=0? gcd(abs(b),abs(d)): 0);
if(flag) b=-b;
for(i=0; i<n; i++) {
if(a!=0) {
if(x[i]<0) {
x[i]=-x[i];
y[i]=-y[i];
}
ll p = x[i] / a;
x[i] -= p * a;
y[i] -= p * b;
}
else {
if(y[i]<0) {
x[i]=-x[i];
y[i]=-y[i];
}
ll p = y[i] / b;
x[i] -= p * a;
y[i] -= p * b;
}
z[make_pair(x[i],y[i])]++;
}
printf("%d\n", (int)z.size());
}
return 0;
}
tarattata1