标签:
暴力
Code:
1 #include<bits/stdc++.h> 2 3 void solve(); 4 int __search(int a,int b,int c); 5 6 int f[128][128][128]; 7 8 int main(){ 9 int t; 10 scanf("%d",&t); 11 while(t--) 12 solve(); 13 return 0; 14 } 15 16 void solve(){ 17 int x,y,res ; 18 res = 0xffffffff; 19 scanf("%d%d",&x,&y); 20 for(int i = 1;i <= x/2;i++) 21 res =std::max(res,__search(i,x-i,y)); 22 for(int i = 1;i <= y/2;i++) 23 res = std::max(res,__search(x,i,y-i)); 24 printf("%d\n",res); 25 } 26 27 int __search(int a,int b,int c){ 28 int v[1024]; 29 int res; 30 res = 0; 31 memset(v,0,sizeof(v)); 32 if(a>b)std::swap(a,b); 33 if(a>c)std::swap(a,c); 34 if(b>c)std::swap(b,c); 35 36 v[a]=v[b]=v[c]=1; 37 v[a+b]=v[a+c]=v[b+c]=v[b-a]=v[c-a]=v[c-b] = 1; 38 v[a+b+c] =1; 39 v[b+c-a] = v[a+c-b]= v[abs(a+b-c)] =1; 40 //printf("\n%d %d %d\n",a,b,c); 41 for(int i = 1;i < 300;i++) 42 if(v[i]){ 43 res ++; 44 //printf("%d ",i); 45 } 46 return res; 47 48 }
标签:
原文地址:http://www.cnblogs.com/Forgenvueory/p/5210989.html