fjnu 1824 Undercut
来源:互联网 发布:致知是什么意思 编辑:程序博客网 时间:2024/06/05 00:11
Description
Undercut is a card game where two players each have five cards numbered one through five. At each round, each player selects a card, then simultaneously reveals it. If the cards are of equal value, there is no score. Otherwise, there are two cases: the two cards are exactly one point apart (this is called an undercut), or the cards are more than one point apart. In the latter case, the person revealing the larger of the cards gets the number of points on the larger card. In the case of an undercut the player with the lower card gets the sum of the two cards. The exception to this is when the cards are 1 and 2, in which case the player with the lower card gets 6 points (instead of only 3 points). After each round, the cards are returned to the hands and they play another round.
For example, if there are 5 rounds and player A plays (in this order) 5, 3, 1, 3, 5 and player B plays 3, 3, 3, 3, 4, then the scoring for each round would be: A gets 5 points, no points, B gets 3 points, no points, B gets 9 points. The totals would be A: 5, B: 12.
In this problem you will be given card plays for both players and must determine the final scores.
Input
There will be multiple input instances. Each instance will be one game. The first line of input for a game will be an integer n <= 20. (A value of n = 0 terminates input.) The next two lines will each contain n integers between 1 and 5 inclusive indicating the cards played on each of n rounds. The first line are player A's card plays and the second line are player B's card plays.
Output
Each input instance should generate one line of output of the form:
A has a points. B has b points.
where the value of a and b are for you to determine. A blank line should separate output lines.
Sample Input
55 3 1 3 53 3 3 3 442 3 1 11 5 5 50
Sample Output
A has 5 points. B has 12 points.
KEY:题目好好看,不是很难;
A has 0 points. B has 21 points.Source:#include<iostream>
using namespace std;
int s1,s2;
int N;
int a[25];
int b[25];
void score()
...{
s1=s2=0;
for(int i=1;i<=N;i++)
...{
if(a[i]==b[i]) continue;
if(abs(a[i]-b[i])==1)
...{
if((a[i]==1&&b[i]==2)||(a[i]==2&&b[i]==1))
...{
if(a[i]==1) s1+=6;
if(b[i]==1) s2+=6;
}
else
...{
if(a[i]>b[i]) s2+=a[i]+b[i];
else s1+=a[i]+b[i];
}
}
if(abs(a[i]-b[i])>1)
...{
if(a[i]>b[i]) s1+=a[i];
else s2+=b[i];
}
}
}
void input()
...{
int i;
for(i=1;i<=N;i++)
cin>>a[i];
for(i=1;i<=N;i++)
cin>>b[i];
}
int main()
...{
// freopen("fjnu_1824.in","r",stdin);
cin>>N;
while(N!=0)
...{
input();
score();
cout<<"A has "<<s1<<" points. B has "<<s2<<" points."<<endl<<endl;
cin>>N;
}
return 0;
}
- fjnu 1824 Undercut
- Undercut
- Undercut
- Undercut
- FJNU
- 1057 Undercut
- ZOJ1057 Undercut
- JOJ1087: Undercut
- ZOJ-1057-Undercut
- ZOJ 1057 Undercut
- zoj 1057 Undercut 水题
- ZOJ--1057:Undercut
- ZOJ Problem Set - 1057||Undercut
- FJNU字符串
- FJNU字符串
- fjnu 1772
- ZOJ 1057 Undercut (格式问题)
- fjnu 1980 集合
- Text控件中文本内容鼠标点击一下就全选中
- fjnu 1060 Web Navigation
- fjnu 1840 Reverse Text
- 【语法】const 用法整理
- fjnu 1518 Above Average
- fjnu 1824 Undercut
- tij学习笔记(通过代码话多态)
- fjnu 1319 Perfection
- fjnu 1848 Prime Cuts
- fjnu 1945 Hello Kitty
- 测试一下csdn的blog功能
- URI&URL
- fjnu 1007 Ride to School
- 重温:冒泡算法