中南大学第十一届大学生程序设计竞赛-COJ1902-Happy Chinese Poker

本文介绍了一款三人斗地主游戏的得分计算方法,通过分析每局游戏中玩家A的身份和胜负情况,实现A玩家得分的自动计算。游戏采用快乐豆作为交易单位,详细解析了不同情况下的得失分规则。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1902: Happy Chinese Poker

Submit Page Summary Time Limit: 1 Sec Memory Limit: 128 Mb Submitted: 5 Solved: 3
Description
Happy Chinese Poker is a Chinese Poker game involved by three players. In each round, there is one player running for the landlord, while the other two players are farmers. The game always ends with the victory of the landlord or farmers, and the game uses happy beans for trading. The transaction of happy beans appears in the following cases:

If a farmer wins in each round of game, then another farmer also wins. As a result, the landlord has to pay 1000 happy beans for his failure, and each farmer can get 500 happy beans.
If the landlord wins in each round of game, both two farmers have to pay 500 happy beans respectively for their failure and the landlords win 1000 happy beans.
Each player has to pay 100 happy beans for each round as a game fee.
The boy A is addicted to the game, Happy Chinese Poker, because he enjoys the pleasure of winning happy beans. Today he invited his friends B and C to play the game for N rounds. Assuming that all of them have enough happy beans and their wins or loses situation in each round is known, can you help A count today’s profit and loss situation of happy beans ( the difference value between the time A starts the game and finishes the game )

Input
There are multiply cases.(<=200) Each case’s first line contains an integer N represent play the game for N rounds .(N<=1000) In next N lines,every line contains three integers a,b,c(Respectively, said A, B, C game win or lose , 0 represent lose , 1represent win)

Output
For each case , output an integer represent today’s profit and loss situation of happy beans for A in one line.

Sample Input
3
0 1 1
0 0 1
1 1 0

1
1 0 0
Sample Output
-1300
900
Hint
Source
中南大学第十一届大学生程序设计竞赛

Author
Forget_ever

题目大意: A,B,C三人斗地主,一共斗了N局,要求给出A最后的得分
解题思路:逐局确定A的地主/农民身份以及A的胜负情况,用一个变量累加各局积分,最后扣除每一局的游戏费用,再输出得分即可。
考查内容:基本编程语言(循环语句,分支判断语句)
时间复杂度: O(n)
题目难度:

#include<iostream>
#include<string>
#include<cmath>
typedef long long LL;
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    int a,b,c;
    while(cin>>n)
    {
        LL ans=0;
        for(int i=0;i<n;i++)
        {
            ans-=100;
            cin>>a>>b>>c;
            if(a==0&&b==0&&c==1) ans-=500;
            else if(a==0&&b==1&&c==0) ans-=500;
            else if(a==0&&b==1&&c==1) ans-=1000;
            else if(a==1&&b==0&&c==0) ans+=1000;
            else if(a==1&&b==0&&c==1) ans+=500;
            else if(a==1&&b==1&&c==0) ans+=500;
        }
        cout<<ans<<endl;
    }
    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值