跳到正文

题解

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

_czl_约 2 分钟
原文
文章信息与版本

文章信息

发布
2025年7月22日
收录
2025年12月12日
更新
2026年11月20日
篇幅
约 2 分钟
获赞
1
题目
P13365

版本

  1. v1当前

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

题目链接

思路

首先分类讨论:

当今日胜率 PDP_D 为 0%0\% 时,总局胜率 PGP_G 不能是 100%100\%,因为今日至少玩了一局且全输;

当 PDP_D 为 100%100\%时,PGP_G 不能是 0%0\%,因为今日至少赢了一局。

对于 1%−99%1\%-99\% 的情况,需要计算最小可能的 DD 值,若这个最小 DD 超过 NN 则不可能。此外,PGP_G 不能为 0%0\% 或 100%100\%,否则会导致矛盾。

最后输出判断结果。

Code

C++
#include<bits/stdc++.h>
#define int long long
using namespace std;
int t,n,pd,pg;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>t;
    for(int cas=1;cas<=t;cas++){
        cin>>n>>pd>>pg;
        cout<<"Case #"<<cas<<": ";
        if(pd==0){
            if(pg!=100)cout<<"Possible\n";
            else cout<<"Broken\n";
        }
        else if(pd==100){
            if(pg!=0)cout<<"Possible\n";
            else cout<<"Broken\n";
        }
        else{
            int g=__gcd(pd,100ll);
            int d=100/g;
            if(d>n)cout<<"Broken\n";
            else{
                if(pg!=0&&pg!=100)cout<<"Possible\n";
                else cout<<"Broken\n";
            }
        }
    }
    return 0;
}
原文
存档评论1 条抓取于