设为首页 加入收藏

TOP

nyoj 949哈利波特(细节题)
2015-07-20 17:29:41 来源: 作者: 【 】 浏览:2
Tags:nyoj 949 哈利波特 细节

哈利波特

时间限制:1000 ms | 内存限制:65535 KB 难度:3
描述

Harry 新学了三种魔法,他可以用第一种魔法把 a 克的沙子变成 b 克金属,可以用第二种魔法把 c 克金属变成 d 克金子,可以用第三种魔法把 e 克金子变成 f 克沙子。Harry 的两个好朋友Ron和Hermione知道了非常高兴,但是Ron和Hermione有个分歧,Ron觉得Harry可以用这三种魔法获得无限的金子,Hermione觉得不能获得无限多的。Harry想知道到底谁是对的

输入
输入6个整数 a,b,c,d,e,f
(0<=a,b,c,d,e,f<=1000)
输出
输出谁是对的,如果Ron是对的输出“Ron”,否则输出“Hermione”
样例输入
100 200 250 150 200 250
100 50 50 200 200 100
1 1 0 1 1 1
100 1 100 1 0 1
样例输出
Ron
Hermione
Ron
Ron
上传者

ACM_王莹

思路:正向黄金 《逆向黄金(Ron)

正向 :k=b/c*d

逆向: q=(k/e)*f

w=(q/a)*b

p=(w/c)*d//逆向黄金

要注意,输入可以有0 所以

1.a=0 bcd 时候 无限黄金ron c=0&&d 无限变出金子 ron

2.当(a=0||c=0||e=0)&&b、d、f 也是无限金子

3.当(a==0&&b==0)||(e==0&&f==0)||(c==0&&d==0) herminoe中间有一个环节不能转换

(用的syy的代码 比我写的更简单)


 
#include
      
       
int main()
{
    double a,b,c,d,e,f;
    while(~scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f))
    {
        if(c==0&&d)
        {
            printf("Ron\n");
            continue;
        }
        if(a==0&&b&&c&&d)
        {
            printf("Ron\n");
            continue;
        }
        if((a==0||c==0||e==0)&&b&&d&&f)
        {
            printf("Ron\n");
            continue;
        }
        if((a==0&&b==0)||(e==0&&f==0)||(c==0&&d==0))
        {
            printf("Hermione\n");
            continue;
        }
        double k=(b/c)*d;
        double q=(k/e)*f;
        double w=(q/a)*b;
        double p=(w/c)*d;
        if(p>k)
            printf("Ron\n");
        else
            printf("Hermione\n");
    }
    return 0;
}  
      



<script type="text/java script">
<script type="text/java script">BAIDU_CLB_fillSlot("771048");
点击复制链接 与好友分享! 回本站首页
<script> function copyToClipBoard(){ var clipBoardContent=document.title + '\r\n' + document.location; clipBoardContent+='\r\n'; window.clipboardData.setData("Text",clipBoardContent); alert("恭喜您!复制成功"); }
<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"24"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇HDoj-2524 - 矩形A+B 下一篇leetcode - Combinations

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·About - Redis (2025-12-26 08:20:56)
·Redis: A Comprehens (2025-12-26 08:20:53)
·Redis - The Real-ti (2025-12-26 08:20:50)
·Bash 脚本教程——Li (2025-12-26 07:53:35)
·实战篇!Linux shell (2025-12-26 07:53:32)