题解:P13365 [GCJ 2011 #1A] FreeCell Statistics

· · 题解

题目传送门

这道题就是一道简单的 if 题,算得上是黄题里很简单的一道题了!

PG = 100 时:总胜率为 100%,意味着所有局都赢了,因此今天的胜率也必须是 100%PD = 100)。否则直接判定为 Broken。

PG = 0 时:总胜率为 0%,意味着所有局都输了,因此今天的胜率也必须是 0%PD = 0)。否则直接判定为 Broken。

PD = 100 时:今天全胜,总胜率 PG,可以是任意值(只要存在 G≥D 满足总胜率条件)。

PD = 0 时:今天全败,总胜率 PG,可以是任意值(同理)。

#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll gcd(ll a, ll b)//求最大公约数
{
    if(b==0)return a;
    return gcd(b,a%b);
}
ll T;
int main(){
    cin>>T;
    for(ll i=1;i<=T;i++)
    {
        ll n,PD,PG;
        cin>>n>>PD>>PG;
        string s="Broken";
        //判断
        if(PG==100)
        {
            if(PD==100)s="Possible";
        }
        else if(PG==0)
        {
            if(PD==0)s="Possible";
        }
        else if(PD==0||PD==100)s="Possible";
        else
        {
            ll d=100/gcd(PD,100);
            if(d<=n)s="Possible";
        }
        cout<<"Case #"<<i<<": "<<s<<"\n";//输出
    }
    return 0;
}