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;
}