记录编号 |
349335 |
评测结果 |
AAAAAAAAAA |
题目名称 |
输出全靠花 |
最终得分 |
100 |
用户昵称 |
jinqiu |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.254 s |
提交时间 |
2016-11-14 21:15:06 |
内存使用 |
6.29 MiB |
显示代码纯文本
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn = 1030, size = 50;
int n, ans;
bool spot[size][size][size][size];
struct SPOT {
int x, y, z, w;
}s[maxn];
int read();
void _gcd(int &, int &, int &, int &);
int gcd(int, int);
int cnt(int, int);
int main() {
freopen("xumingshi.in", "r", stdin);
freopen("xumingshi.out", "w", stdout);
int i, j;
n = read();
for(i = 1; i <= n; i++) {
s[i].x = read();
s[i].y = read();
s[i].z = read();
s[i].w = read();
s[i].x += 20;
s[i].y += 20;
s[i].z += 20;
s[i].w += 20;
spot[s[i].x][s[i].y][s[i].z][s[i].w] = true;
}
for(i = 1; i <= n; i++)
for(j = 1; j <= n; j++)
if(i != j)
ans = max(ans, cnt(i, j));
cout << ans << "\n";
return 0;
}
int cnt(int a, int b) {
int t = 0;
int x = s[a].x - s[b].x, y = s[a].y - s[b].y, z = s[a].z - s[b].z, w = s[a].w - s[b].w;
_gcd(x, y, z, w);
int X = s[a].x, Y = s[a].y, Z = s[a].z, W = s[a].w;
while(true) {
if(!(X <= 40 && Y <= 40 && Z <= 40 && W <= 40) || !(X >= 0 && Y >= 0 && Z >= 0 && W >= 0)) break;
if(spot[X][Y][Z][W]) t++;
X += x, Y += y, Z += z, W += w;
}
return t;
}
void _gcd(int &a, int &b, int &c, int &d) {
int common = gcd(a, gcd(b, gcd(c, d)));
a /= common, b /= common, c /= common, d /= common;
return;
}
int gcd(int a, int b) {
return b == 0 ? a : gcd(b, a % b);
}
int read() {
char s = getchar();
int f = 1, t = 0;
while(s < '0' || s > '9') {
if(s == '-') f = -1;
s = getchar();
}
while(s >= '0' && s <= '9') {
t = (t << 3) + (t << 1) + s - '0';
s = getchar();
}
return t*f;
}