比赛 |
20161114 |
评测结果 |
EEEEEWWEEE |
题目名称 |
输出全靠花 |
最终得分 |
0 |
用户昵称 |
Hoohan(%Dalao) |
运行时间 |
0.816 s |
代码语言 |
C++ |
内存使用 |
0.33 MiB |
提交时间 |
2016-11-14 11:53:23 |
显示代码纯文本
- //xumingshi.cpp
- //ByHoohan
- #include<iostream>
- #include<cstdio>
- #include<cmath>
- #include<algorithm>
- #include<cstring>
- #include<cstdlib>
- using namespace std;
-
- int n,g[1010][4];
- bool manzu[1010][4]={0};
- int ans=-10000;
-
- int eg(int a,int b,int &x,int &y)
- {
- if(b==0)
- {
- x=1;y=0;
- return a;
- }
- int r=eg(b,a%b,x,y);
- int t=x;x=y;y=t-a/b*y;
- return r;
- }
-
- bool pd(int a,int b,int l)//pd=judge.a and b is known.l is x/y/z/w?
- {
- int ren1,ren2,r;
- r=eg(a,b,ren1,ren2);
- if(! (abs(ren1+ren2)==1) )return 0;
- //cout<<a<<' '<<b<<' '<<r<<endl;
- bool ok=0;
- for(int i=0;i<n;i++)
- {
- if(g[i][l]%r == 0)
- {
- manzu[i][l]=1;
- ok=1;
- }
- }
- return ok;
- }
-
- int sou()
- {
- int ls=0;
- for(int i=0;i<n;i++)
- {
- if( manzu[i][0]==1 && manzu[i][1]==1 && manzu[i][2]==1 && manzu[i][3]==1) ls+=1;
- }
- return ls;
- }
-
- int main()
- {
- freopen("xumingshi.in","r",stdin);
- freopen("xumingshi.out","w",stdout);
- cin>>n;
- for(int i=0;i<n;i++) cin>>g[i][0]>>g[i][1]>>g[i][2]>>g[i][3];
-
- //___Testing EG____//
- //int x,y,r=eg(g[0][3],g[1][3],x,y);
- //cout<<x<<' '<<y<<' '<<r<<endl;
- //___Testing EG____//
-
- for(int i=0;i<=n-1;i++)
- {
- for(int j=i+1;j<=n-1;j++)
- {
- memset(manzu,0,sizeof(manzu));
- if(pd(g[i][0] , g[j][0] , 0)){
- if(pd(g[i][1] , g[j][1] , 1)){
- if(pd(g[i][2] , g[j][2] , 2)){
- if(pd(g[i][3] , g[j][3] , 3)){
- ans=max(sou() , ans);
-
- //cout<<"i,j "<<i<<","<<j<<endl;
- //for(int i=0;i<n;i++) cout<<manzu[i][0]<<' '<<manzu[i][1]<<' '<<manzu[i][2]<<' '<<manzu[i][3]<<endl;
-
- }
- }
- }
- }
- }
- }
- cout<<ans;
- return 0;
- }