比赛 20161114 评测结果 EEEEEWWEEE
题目名称 输出全靠花 最终得分 0
用户昵称 Hoohan(%Dalao) 运行时间 0.816 s
代码语言 C++ 内存使用 0.33 MiB
提交时间 2016-11-14 11:53:23
显示代码纯文本
  1. //xumingshi.cpp
  2. //ByHoohan
  3. #include<iostream>
  4. #include<cstdio>
  5. #include<cmath>
  6. #include<algorithm>
  7. #include<cstring>
  8. #include<cstdlib>
  9. using namespace std;
  10.  
  11. int n,g[1010][4];
  12. bool manzu[1010][4]={0};
  13. int ans=-10000;
  14.  
  15. int eg(int a,int b,int &x,int &y)
  16. {
  17. if(b==0)
  18. {
  19. x=1;y=0;
  20. return a;
  21. }
  22. int r=eg(b,a%b,x,y);
  23. int t=x;x=y;y=t-a/b*y;
  24. return r;
  25. }
  26.  
  27. bool pd(int a,int b,int l)//pd=judge.a and b is known.l is x/y/z/w?
  28. {
  29. int ren1,ren2,r;
  30. r=eg(a,b,ren1,ren2);
  31. if(! (abs(ren1+ren2)==1) )return 0;
  32. //cout<<a<<' '<<b<<' '<<r<<endl;
  33. bool ok=0;
  34. for(int i=0;i<n;i++)
  35. {
  36. if(g[i][l]%r == 0)
  37. {
  38. manzu[i][l]=1;
  39. ok=1;
  40. }
  41. }
  42. return ok;
  43. }
  44.  
  45. int sou()
  46. {
  47. int ls=0;
  48. for(int i=0;i<n;i++)
  49. {
  50. if( manzu[i][0]==1 && manzu[i][1]==1 && manzu[i][2]==1 && manzu[i][3]==1) ls+=1;
  51. }
  52. return ls;
  53. }
  54.  
  55. int main()
  56. {
  57. freopen("xumingshi.in","r",stdin);
  58. freopen("xumingshi.out","w",stdout);
  59. cin>>n;
  60. for(int i=0;i<n;i++) cin>>g[i][0]>>g[i][1]>>g[i][2]>>g[i][3];
  61. //___Testing EG____//
  62. //int x,y,r=eg(g[0][3],g[1][3],x,y);
  63. //cout<<x<<' '<<y<<' '<<r<<endl;
  64. //___Testing EG____//
  65. for(int i=0;i<=n-1;i++)
  66. {
  67. for(int j=i+1;j<=n-1;j++)
  68. {
  69. memset(manzu,0,sizeof(manzu));
  70. if(pd(g[i][0] , g[j][0] , 0)){
  71. if(pd(g[i][1] , g[j][1] , 1)){
  72. if(pd(g[i][2] , g[j][2] , 2)){
  73. if(pd(g[i][3] , g[j][3] , 3)){
  74. ans=max(sou() , ans);
  75. //cout<<"i,j "<<i<<","<<j<<endl;
  76. //for(int i=0;i<n;i++) cout<<manzu[i][0]<<' '<<manzu[i][1]<<' '<<manzu[i][2]<<' '<<manzu[i][3]<<endl;
  77. }
  78. }
  79. }
  80. }
  81. }
  82. }
  83. cout<<ans;
  84. return 0;
  85. }