C - Cued In Gym - 101606C(模拟水题)
2018-04-04 18:03
330 查看
Snooker is a cue sport played by two players on a rectangular table. The players take turns topot a series of balls of varying colours, where each colour represents a distinct point value forpotting the ball.A player may pot any ball on the table initially, however any subsequent shots must follow apattern: if the previous ball was red, the next ball must be another colour; otherwise, if there arestill red balls left, the next ball must be red.Balls of any colour other than red are initially replaced on the table every time they are potted,and may be used again to score more points. The balls stop being replaced once all of the redballs have been potted.The values of each coloured ball are:
Snooker players are respected universally for their prowess in mental arithmetic. One sweepingglance across the table is enough to tell an experienced contestant how much they could score.For newer players, however, this is a challenge. Write a program to help calculate a score for agiven list of balls remaining on the table.
Input
• one line containing the integers N (1 ≤ N ≤ 21), the number of balls remaining on thetable.
• N further lines, each containing the colour of one of the balls on the table.The list of balls will not be ordered in any way and will contain at most one of each of yellow,green, brown, blue, pink and black.
Output
Output the largest possible score the player can make.
题目:斯诺克,红球与色球交替进,只要桌上还有红球,进洞的色球就可以重新拿回桌上,直到没有红球为止,那么要得到最多的分数就要先进色球且存在的分值最高的色球,与红球交替进球直到没有红球。再将所有色球打进得分就可以。#include <iostream>
using namespace std;
int nr=0,nb=0,np=0,nbl=0,nbr=0,ng=0,ny=0;
int main()
{
int res=0;
int n;
cin>>n;
string s;
for(int i=0;i<n;i++){
cin>>s;
if(s=="red") nr++; //红球个数
else if(s=="black") nb++; //黑球个数
else if(s=="pink") np++; //粉球个数
else if(s=="blue") nbl++; //黑球个数
else if(s=="brown") nbr++; //棕球个数
else if(s=="green") ng++; //绿球个数
else if(s=="yellow") ny++; //黄球个数
}
// cout<<nr<<" "<<nb<<" "<<np<<" "<<nbl<<" "<<nbr<<" "<<ny<<endl;
if(nr){ //选取存在的分数最高的色球与红球交替进球,直到红球个数为0
if(nb){
res+=8*nr;
}
else if(np){
res+=7*nr;
}
else if(nbl){
res+=6*nr;
}
else if(nbr){
res+=5*nr;
}
else if(ng){
res+=4*nr;
}
else if(ny){
res+=3*nr;
}
}
res+=nb*7+np*6+nbl*5+nbr*4+ng*3+ny*2; //将场上色球的分数加上
if(!nb&&!np&&!nbl&&!nbr&&!ng&&!ny) res=1; //如果场上没有色球,那么只能进一颗红球
cout<<res<<endl;
return 0;
}
Snooker players are respected universally for their prowess in mental arithmetic. One sweepingglance across the table is enough to tell an experienced contestant how much they could score.For newer players, however, this is a challenge. Write a program to help calculate a score for agiven list of balls remaining on the table.
Input
• one line containing the integers N (1 ≤ N ≤ 21), the number of balls remaining on thetable.
• N further lines, each containing the colour of one of the balls on the table.The list of balls will not be ordered in any way and will contain at most one of each of yellow,green, brown, blue, pink and black.
Output
Output the largest possible score the player can make.
题目:斯诺克,红球与色球交替进,只要桌上还有红球,进洞的色球就可以重新拿回桌上,直到没有红球为止,那么要得到最多的分数就要先进色球且存在的分值最高的色球,与红球交替进球直到没有红球。再将所有色球打进得分就可以。#include <iostream>
using namespace std;
int nr=0,nb=0,np=0,nbl=0,nbr=0,ng=0,ny=0;
int main()
{
int res=0;
int n;
cin>>n;
string s;
for(int i=0;i<n;i++){
cin>>s;
if(s=="red") nr++; //红球个数
else if(s=="black") nb++; //黑球个数
else if(s=="pink") np++; //粉球个数
else if(s=="blue") nbl++; //黑球个数
else if(s=="brown") nbr++; //棕球个数
else if(s=="green") ng++; //绿球个数
else if(s=="yellow") ny++; //黄球个数
}
// cout<<nr<<" "<<nb<<" "<<np<<" "<<nbl<<" "<<nbr<<" "<<ny<<endl;
if(nr){ //选取存在的分数最高的色球与红球交替进球,直到红球个数为0
if(nb){
res+=8*nr;
}
else if(np){
res+=7*nr;
}
else if(nbl){
res+=6*nr;
}
else if(nbr){
res+=5*nr;
}
else if(ng){
res+=4*nr;
}
else if(ny){
res+=3*nr;
}
}
res+=nb*7+np*6+nbl*5+nbr*4+ng*3+ny*2; //将场上色球的分数加上
if(!nb&&!np&&!nbl&&!nbr&&!ng&&!ny) res=1; //如果场上没有色球,那么只能进一颗红球
cout<<res<<endl;
return 0;
}
相关文章推荐
- HDU 5095 Linearization of the kernel functions in SVM(模拟, 水题)
- 【解题报告】 URAL 1192 Ball in a Dream -- 物理模拟水题
- Gym 100703M It's complicated 水题
- poj 2388 Who's in the Middle(水题)
- Codeforces Gym 101190 (NEERC 2016) H. Hard Refactoring (模拟 + 树状数组)
- poj 1027 The 3n + 1 problem(模拟,水题)
- hdu5319 模拟水题
- NBUT 1455 Malphite (模拟水题)
- 计蒜客 Minimum Distance in a Star Graph 思维水题
- UVa 11054 - Wine trading in Gergovia(扫描法 水题)
- C - Bored Judge Gym - 101102C 模拟
- 【模拟】NEERC15 G Generators (Codeforces GYM 100851)
- Codeforces Gym 101164 D. Reading Digits (模拟)
- Codeforces Gym 100286G Giant Screen 水题
- HDU 5095--Linearization of the kernel functions in SVM【模拟】
- 模拟 HDOJ 5095 Linearization of the kernel functions in SVM
- poj 3782 Equal Sum Partitions 模拟水题
- Codeforces Gym 100345A BibTeX 模拟
- hdu 4461 The Power of Xiangqi【模拟】水题
- I - In Touch-Gym 100492I-水题