当前位置:网站首页>Contest3145 - the 37th game of 2021 freshman individual training match_ G: Score
Contest3145 - the 37th game of 2021 freshman individual training match_ G: Score
2022-07-04 02:34:00 【This question AC sleep again】
//
problem G: The score
The time limit : 1.000 Sec Memory limit : 128 MB
Title Description
Xiaohua likes a player named fan Zhendong most in the table tennis hall , Today, he lay on the window and watched their training all afternoon , Until he was driven away by the cleaning uncle . Xiaohua has a very good memory , Can record the whole afternoon of the game , For example, it records ( among F It means that fan Zhendong won a point ,A It means that fan Zhendong's opponent gets a point ):FFFFFFFFFFFFFFFFFFFFFFAF. Under the current competition system , At this time, the result of the game is fan Zhendong's first game 11 Than 0 win victory , The second inning 11 Than 0 win victory , The third game is in progress , The current score 1 Than 1.
Because Xiaohua is too absorbed , Didn't pay attention to the score at all , So that it doesn't know the specific score of the afternoon , So Xiaohua asked her good friend programming rabbit to help . But the programming rabbit went to dig carrots , So Xiaohua came to the clever children for help .
Your program is to input a series of game information (FA form ), Output the right results .
notes :
1) Currently using 11 " , To 10 Ping Hou , Need to win 2 Points after , To win , Such as :12:10;17:15 etc. .
2) If a game starts , Then the score does not have to be output .
3) Input data can be at most 20 Letters , The number of lines may be many , There may be at most 10000 That's ok .
Input
The input contains several lines of string ( At most... Per line 20 Letters ), The string is capitalized F、A and E form . among E Indicates the end of the game information , The program should ignore E Everything after that .
Output
The output has several lines , Each line corresponds to the score of a game ( In order of input ).
The sample input Copy
FFFFFFFFFFFFFFFFFFFF
FFAFE
Sample output Copy
11:0
11:0
1:1
Tips
front 11 All points are F, So the first set 11:0, after 11 All points F, So the second sentence is also 11:0, The last two points are A and F, So it is 1:1,E End of the said .
Each line has at most 20 Characters , Only F、A and E Three letters .
about 30% The data of , There is only one line of input .
about 60% The data of , Input no more than 10 That's ok .
about 100% The data of , Input data no more than 10000 That's ok .
//
#include<bits/stdc++.h>
using namespace std;
// Input data can be at most 20 Letters
const int MAXN=22;
char str[MAXN];
int main()
{
int i,a,b,flag;
a=b=flag=0;
while( ~scanf("%s",str) )
{
for( i=0;str[i];i++ )
{
if( str[i]=='E' ) { flag=1; break; } // and break together Cannot use comma expression
else if( str[i]=='F' ) a++;
else if( str[i]=='A' ) b++;
if( a>=10 && b>=10 ) // Currently using 11 " , To 10 Ping Hou , Need to win 2 Points after , To win
{
if( abs(a-b)>=2 ) { printf("%d:%d\n",a,b); a=b=0; }
}
else if( a==11 && b<10 ) { printf("%d:%d\n",a,b); a=b=0; }
else if( b==11 && a<10 ) { printf("%d:%d\n",a,b); a=b=0; }
}
if( flag )
{ // || One possibility is 0
if( a || b ) printf("%d:%d\n",a,b); // If a game starts , Then the score does not have to be output
break;
}
}
return 0;
}
//
find:
01 List possible situations ( Construct special data ) First judge the special data
a>=10 && b>=10
01 |a-b|>=2 printf
02 ... continue
a==11 && b<10
b==11 && a<10
边栏推荐
- 13. Time conversion function
- Sword finger offer 20 String representing numeric value
- [untitled]
- Database concept and installation
- PMP daily three questions (February 14, 2022)
- Comment la transformation numérique du crédit d'information de la Chine passe - t - elle du ciel au bout des doigts?
- 在尋求人類智能AI的過程中,Meta將賭注押向了自監督學習
- false sharing
- Zblog collection plug-in does not need authorization to stay away from the cracked version of zblog
- Design and implementation of redis 7.0 multi part AOF
猜你喜欢
Small program graduation project based on wechat video broadcast small program graduation project opening report function reference
I stepped on a foundation pit today
How to subcontract uniapp and applet, detailed steps (illustration) # yyds dry goods inventory #
Fudan released its first review paper on the construction and application of multimodal knowledge atlas, comprehensively describing the existing mmkg technology system and progress
The boss said: whoever wants to use double to define the amount of goods, just pack up and go
The automatic control system of pump station has powerful functions and diverse application scenarios
Idea if a class cannot be found, it will be red
C language black Technology: Archimedes spiral! Novel, interesting, advanced~
17. File i/o buffer
There is no need to authorize the automatic dream weaving collection plug-in for dream weaving collection
随机推荐
Example 072 calculation of salary it is known that the base salary of an employee of a company is 500 yuan. The amount of software sold by the employee and the Commission method are as follows: Sales
Node write API
C # learning notes: structure of CS documents
Méthode de calcul de la connexion MSSQL de la carte esp32c3
There is no need to authorize the automatic dream weaving collection plug-in for dream weaving collection
查詢效率提昇10倍!3種優化方案,幫你解决MySQL深分頁問題
Take you to master the formatter of visual studio code
In yolov5, denselayer is used to replace focus, and the FPN structure is changed to bi FPN
Life cycle of instance variables, static variables and local variables
Node solves cross domain problems
What are the conditions for the opening of Tiktok live broadcast preview?
13. Time conversion function
Chain ide -- the infrastructure of the metauniverse
STM32 key content
The boss said: whoever wants to use double to define the amount of goods, just pack up and go
LV1 Roche limit
Neo4j learning notes
The reasons why QT fails to connect to the database and common solutions
Safety tips - seat belt suddenly fails to pull? High speed police remind you how to use safety belts in a standardized way
The automatic control system of pump station has powerful functions and diverse application scenarios