zoukankan      html  css  js  c++  java
  • 【codeforces 65A】Harry Potter and Three Spells

    【题目链接】:http://codeforces.com/problemset/problem/65/A

    【题意】

    你有3种魔法;
    1.可以将a单位的石头变成b单位的铅
    2.可以将c单位的铅变成d单位的金子
    3.可以将e单位的金子变成f单位的石头;
    问你能不能用这3种魔法通过有限量的石头得到无限量的金子;

    【题解】

    ①这几个数字都大于0
    假设一开始你有a*c*e单位的石头;
    ->换成b*c*e单位的铅
    ->换成b*d*e单位的金子
    ->换成b*d*f单位的石头;
    若a*c*e< b*d*f则可以在得到一定量的金子的情况下又获得等量的石头;
    则可以一直增加金子;则可以获得无限量的金子;
    ②b,d,f里面有等于0的
    d首先不能等于0;
    然后,如果c等于0则也可行;
    或者c不等于0;
    但是b>0且a==0
    或者
    b>0且a>0且(e==0,f>0)也可行;

    【Number Of WA

    1

    【完整代码】

    #include <bits/stdc++.h>
    using namespace std;
    #define lson l,m,rt<<1
    #define rson m+1,r,rt<<1|1
    #define LL long long
    #define rep1(i,a,b) for (int i = a;i <= b;i++)
    #define rep2(i,a,b) for (int i = a;i >= b;i--)
    #define mp make_pair
    #define pb push_back
    #define fi first
    #define se second
    #define ms(x,y) memset(x,y,sizeof x)
    #define Open() freopen("D:\rush.txt","r",stdin)
    #define Close() ios::sync_with_stdio(0),cin.tie(0)
    
    typedef pair<int,int> pii;
    typedef pair<LL,LL> pll;
    
    const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
    const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
    const double pi = acos(-1.0);
    const int N = 1e6+100;
    const int MOD = 1e9+7;
    
    int a,b,c,d,e,f;
    
    int main(){
        //Open();
        Close();
        cin >> a >> b >> c >> d >> e >> f;
        if ( (a*c*e < b*d*f) || (d && (!c || (b &&(!a || (!e && f))))))
            cout <<"Ron"<<endl;
        else
            cout <<"Hermione"<<endl;
        return 0;
    }
    
  • 相关阅读:
    使用POI读取excel文件内容
    有序链表
    jQuery Validate验证框架详解
    怎样在VS2010中打开VS2012的项目
    在Win8.1系统下如何安装运行SQL Server 2005
    SQL2005 2008配置错误,无法识别的配置节 system.serviceModel machine.config配置文件有问题
    深入浅出学Spring Data JPA
    Java 学习摘要
    JFinal
    spring 4 + jpa(hibernate 3/4) + spring mvc 多数据源配置
  • 原文地址:https://www.cnblogs.com/AWCXV/p/7626275.html
Copyright © 2011-2022 走看看