C - Card Game (Third Edition)
2017-08-14 19:51
155 查看
Fat brother and Maze are playing a kind of special (hentai) game with some cards. In this game, every player gets N cards at first and these are their own card decks. Each of these two decks of cards is stacking together at the beginning of the game, and their
order would not change during this game. The game goes for N rounds and in each round, Fat Brother and Maze would draw one card from the top of their own remaining card deck and sum these two integers together. If this number is greater than 10, Fat Brother
would score 1 victory point and otherwise Maze would score 1 victory points. And then these two cards are removed from the game such that they would not appear in the later rounds. As we all know, Fat Brother is very clever, so he would like to know the number
of the victory points he could get if he knows all the integers written in these cards. At the beginning of this game, each player has 0 victory point.
Input
The first line of the date is an integer T (1 <= T <= 100), which is the number of the text cases.
Then T cases follow, each case contains an integer N (1 <= N <= 10000) which described before. Then follow two lines with N integers each. The first N integers indicate the cards which Fat Brother gets from top to bottom, and the second N integers indicate
the cards which Maze gets from top to bottom.
All the integers are positive and least than 10.
Output
For each case, output the case number first, and then output the number of victory points Fat Brother would gets in this game.
Sample Input
2
1
5
6
2
3 4
3 4
Sample Output
Case 1: 1
Case 2: 0
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int i,n,t,cou=1;
int str1[10000+5],str2[10000+5];
int main()
{
scanf("%d",&t);
while(t--)
{
int coun=0;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&str1[i]);
for(i=0;i<n;i++)
scanf("%d",&str2[i]);
for(i=0;i<n;i++)
{
if(str1[i]+str2[i]>10)
coun++;
}
printf("Case %d: %d\n",cou++,coun);
}
}
order would not change during this game. The game goes for N rounds and in each round, Fat Brother and Maze would draw one card from the top of their own remaining card deck and sum these two integers together. If this number is greater than 10, Fat Brother
would score 1 victory point and otherwise Maze would score 1 victory points. And then these two cards are removed from the game such that they would not appear in the later rounds. As we all know, Fat Brother is very clever, so he would like to know the number
of the victory points he could get if he knows all the integers written in these cards. At the beginning of this game, each player has 0 victory point.
Input
The first line of the date is an integer T (1 <= T <= 100), which is the number of the text cases.
Then T cases follow, each case contains an integer N (1 <= N <= 10000) which described before. Then follow two lines with N integers each. The first N integers indicate the cards which Fat Brother gets from top to bottom, and the second N integers indicate
the cards which Maze gets from top to bottom.
All the integers are positive and least than 10.
Output
For each case, output the case number first, and then output the number of victory points Fat Brother would gets in this game.
Sample Input
2
1
5
6
2
3 4
3 4
Sample Output
Case 1: 1
Case 2: 0
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int i,n,t,cou=1;
int str1[10000+5],str2[10000+5];
int main()
{
scanf("%d",&t);
while(t--)
{
int coun=0;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&str1[i]);
for(i=0;i<n;i++)
scanf("%d",&str2[i]);
for(i=0;i<n;i++)
{
if(str1[i]+str2[i]>10)
coun++;
}
printf("Case %d: %d\n",cou++,coun);
}
}
相关文章推荐
- 3. Growth of Functions——Introduction to Algorithms Third Edition
- Free BOOK: Mastering Enterprise Java Beans Third Edition (3th)
- PMP Examination Tips (PMBoK Third Edition)
- 2009-07-26 Machine Vision——Third Edition 阅读进行时
- iOS 6 by Tutorials Third Edition
- C# in Depth Third Edition 学习笔记-- C#2的一些特性
- OS X 10.10 编译APUE Third Edition 源码
- “Effective C++ Third Edition”学习笔记(一)
- 4. Divide-and-Conquer——Introduction to Algorithms Third Edition
- “Effective C++ Third Edition”学习笔记(二)
- Writing Secure Code Third Edition
- 【期望】fuzoj 2265 Card Game (Second Edition)
- What's New in the XML in a Nutshell Third Edition
- Writing Secure Code Third Edition
- 对C++Primer third edition中文件流操作的补充
- 第三版前言:Preface to the Third Edition
- 4. Exercises and Problems——Introduction to Algorithms Third Edition
- C# in Depth Third Edition 学习笔记-- Lambda表达式和表达式树
- Effective C++ Third Edition 读书笔记 1
- “Effective C++ Third Edition”学习笔记(三)