【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;
}
原文地址:https://www.cnblogs.com/AWCXV/p/7626275.html