当前位置:网站首页>LV1 previous life archives
LV1 previous life archives
2022-07-04 01:57:00 【HBUcs2020】
At a glance , Use a binary tree , This feature is very consistent
This question is really not difficult compared with the lottery question , The title is concise and clear
#include<iostream>
using namespace std;
int main()
{
int x,y;
cin>>x>>y;
while(y--)
{
int s=1,sum=0;
for(int i=0;i<x;i++)
{
char c;
cin>>c;
if(c=='y')
{
s=s*2;
}
else
{
s=s*2+1;
}
sum=sum*2+1;
}
cout<<s-sum<<endl;
}
return 0;
}
This kind of funny fortune telling applet is often encountered in the online world , The implementation principle is very simple , Just design a few questions , Select a path in the judgment tree according to the player's answer to each question ( As shown in the figure below ), The conclusion is the node corresponding to the end of the path .
Now let's number the conclusions from left to right , Number from 1 Start . It is assumed that the answers here are simple “ yes ” or “ no ”, Suppose you answer “ yes ” Corresponding to the left path , answer “ no ” Corresponding to the path to the right . A series of answers for a given player , Please return the number of the conclusion .
Input format :
The first line of input gives two positive integers :N(≤30) The number of questions to answer in a test for players ;M(≤100) For the number of players .
And then M That's ok , Each line gives the player's N answer . Here we use y
representative “ yes ”, use n
representative “ no ”.
Output format :
For each player , Output the number of its corresponding conclusion in one line .
sample input :
3 4
yny
nyy
nyn
yyn
sample output :
3
5
6
2
边栏推荐
- Description of setting items of Jerry [chapter]
- JVM performance tuning and practical basic theory - medium
- Force buckle day32
- Douban scoring applet Part-3
- Infiltration learning diary day19
- Openbionics robot project introduction | bciduino community finishing
- What is the student party's Bluetooth headset recommendation? Student party easy to use Bluetooth headset recommended
- Mongodb learning notes: command line tools
- Huawei rip and BFD linkage
- Jerry's update contact [article]
猜你喜欢
Jerry's watch listens to the message notification of the target third-party software and pushes the message to the device [article]
After listening to the system clear message notification, Jerry informed the device side to delete the message [article]
IPv6 experiment
Bacteriostatic circle scanning correction template
JVM performance tuning and practical basic theory - medium
Will the memory of ParticleSystem be affected by maxparticles
Solution of cursor thickening
High level application of SQL statements in MySQL database (I)
The automatic control system of pump station has powerful functions and diverse application scenarios
Use classname to modify style properties
随机推荐
Chain ide -- the infrastructure of the metauniverse
Logical operator, displacement operator
Jerry's modification setting status [chapter]
I don't know why it can't run in the project and how to change it
Development of user-defined navigation bar in uniapp
Basic editing specifications and variables of shell script
The boss said: whoever wants to use double to define the amount of goods, just pack up and go
JVM performance tuning and practical basic theory - medium
MySQL - use of aggregate functions and group by groups
MySQL introduction - functions (various function statistics, exercises, details, tables)
Meta metauniverse female safety problems occur frequently. How to solve the related problems in the metauniverse?
Hamburg University of Technology (tuhh) | intelligent problem solving as integrated hierarchical reinforcement learning
High level application of SQL statements in MySQL database (I)
Iclr2022 | ontoprotein: protein pre training integrated with gene ontology knowledge
Conditional statements of shell programming
1189. Maximum number of "balloons"
LeetCode 168. Detailed explanation of Excel list name
Gee: create a new feature and set corresponding attributes
Solution of cursor thickening
Portapack application development tutorial (XVII) nRF24L01 launch C