随笔-38  评论-23  文章-0  trackbacks-0
队友写的代码..没看题目。
这是hdu大牛的解题报告:http://acm.hdu.edu.cn/forum/read.php?tid=13133

#include<iostream>
using namespace std;
int h[15];
bool f[15];
double h1[15];
int ji_suan(double t1,double t2);
int main()
{
    
int n,flag,i,a,t;
    
while(scanf("%d",&n)!=EOF)
    
{
        flag
=0;
        
//memset(f,false,sizeof(f));
        for(i=0;i<14;i++)
            f[i]
=false;
        
for(i=0;i<n;i++)
        
{
            scanf(
"%d%lf",&a,&h1[i]);
            h[a]
=i;
            f[a]
=true;
            
if(a==14)
            
{
                
if(h1[i]>5.0||h1[i]<5.0)
                    flag
=1;
            }

            
if(a==7)
            
{
                
if(h1[i]<0||h1[i]>0.8)
                    flag
=1;
            }

        }

        
if(flag==1)
        
{
            printf(
"No\n");
            
continue;
        }

        printf(
"Yes\n");
        
if(f[1]==true&&f[2]==true)
        
{
            t
=ji_suan(h1[h[1]],h1[h[2]]);
            
if(t==0)
                printf(
"3 L\n");
            
else
                printf(
"3 H\n");
            flag
=1;

        }

        
if(f[4]==true&&f[5]==true)
        
{
            t
=ji_suan(h1[h[4]],h1[h[5]]);
            
if(t==0)
                printf(
"6 L\n");
            
else
                printf(
"6 H\n");
            flag
=1;

        }

        
if(f[9]==true&&f[10]==true)
        
{
            t
=ji_suan(h1[h[9]],h1[h[10]]);
            
if(t==0)
                printf(
"8 L\n");
            
else
                printf(
"8 H\n");
            flag
=1;

        }

        
if(f[12]==true&&f[13]==true)
        
{
            t
=ji_suan(h1[h[12]],h1[h[13]]);
            
if(t==0)
                printf(
"11 L\n");
            
else
                printf(
"11 H\n");
            flag
=1;
        }

    }

    
return 0;
}

int ji_suan(double t1,double t2)
{
    
if(t1>=4.5&&t1<=5.5&&t2>=4.5&&t2<=5.5)
        
return 0;
    
if(t1>=4.5&&t1<=5.5&&(t2<4.5||t2>5.5))
        
return 1;
    
if(t2>=4.5&&t2<=5.5&&(t1<4.5||t1>5.5))
        
return 1;
    
else
        
return 1;
}


posted on 2009-05-02 20:45 米游 阅读(348) 评论(0)  编辑 收藏 引用 所属分类: ACM

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理