您的位置:首页 > 其它

HDU 4277  USACO ORZ

2013-12-14 20:04 344 查看
题意:题目给出n条边 , 要求用这n条组成一个三角形 , 问最多能成多少个三角形?

这题真的是一个水题 , 可能当时题目读错了(英文差啊) , 后面做得时候又一直超时 ,
看大神的解题报告之后才知道真的很简单。

简单的搜索加判重

判重可以用 hash 、 set+运算符重载

代码:

   
#include 

   
#include 

   
#include 

   
#include 

   
#include 

   
#include 

   
#include 

    #define LL
long long 

    #define N
25 

    using
namespace std; 

    int
num


    int
n,summ,xj,xk; 

    int
Case; 

    struct
node  //要去学学

   


       
int x,y,z; 

       
bool operator < (const struct node &a)
const 

       
{

           
return (x!=a.x)?(x

       
}

   
}temp,ans; 

    set
hashx; 

    void
dfs(int); 

    int
main() 

   


       
scanf("%d",&Case); 

       
for(int c=0;c

       


           
summ=0;hashx.clear(); 

           
scanf("%d",&n); 

           
for(int i=1;i<=n;i++) 

           


               
scanf("%d",&num[i]); 

               
summ+=num[i]; 

           


           
temp.x=num[1];temp.y=0; 

      
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: