题解:P14758 役满之泪

· · 题解

题目大意:

你要加入最少牌数满足“国士无双”这类牌。

“国士无双”: 满足 13 个数不为 0,且有 >1 的牌。

思路:

简单模拟题。

多简单呢?只用读 13 个数,判断有几个 0 和有没有 >1 的数就行了,没有 >1 的数把判断有几个 0 结果 +1 即可。

AC code:

#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    bool a=0;
    int b,ans=0;
    for(int i=1;i<=13;i++){
        cin>>b;
        if(b>1){
            a=1;//特判>1的数
        }
        if(b==0){
            ans++;//是0的话+1
        }
    }
    if(!a){
        ans++;//判断有没有>1的数,没有的话+1
    }
    cout<<ans;
}