当前位置:网站首页>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
边栏推荐
- When tidb meets Flink: tidb efficiently enters the lake "new play" | tilaker team interview
- C import Xls data method summary I (upload files and create Workbooks)
- Install the pit that the electron has stepped on
- Use classname to modify style properties
- Feign implements dynamic URL
- After listening to the system clear message notification, Jerry informed the device side to delete the message [article]
- In yolov5, denselayer is used to replace focus, and the FPN structure is changed to bi FPN
- ES6 deletes an attribute in all array objects through map, deconstruction and extension operators
- Flex flexible layout, box in the middle of the page
- Stringutils and collectionutils
猜你喜欢
Pyinstaller packaging py script warning:lib not found and other related issues
Remember a lazy query error
Chapter 3.4: starrocks data import - Flink connector and CDC second level data synchronization
SQL statement
Push technology practice | master these two tuning skills to speed up tidb performance a thousand times!
Introduction to Tianchi news recommendation: 4 Characteristic Engineering
Small program graduation project based on wechat e-book small program graduation project opening report function reference
When tidb meets Flink: tidb efficiently enters the lake "new play" | tilaker team interview
Small program graduation project based on wechat examination small program graduation project opening report function reference
Magical usage of edge browser (highly recommended by program ape and student party)
随机推荐
Why can't it run (unresolved)
Hash table, string hash (special KMP)
Applet graduation design is based on wechat course appointment registration. Applet graduation design opening report function reference
求esp32C3板子連接mssql方法
Special copy UML notes
Neo4j learning notes
LeetCode226. Flip binary tree
Why is the operation unsuccessful (unresolved) uncaught syntaxerror: invalid or unexpected token (resolved)
Chapter 3.4: starrocks data import - Flink connector and CDC second level data synchronization
Ceramic metal crowns - current market situation and future development trend
Maximum likelihood method, likelihood function and log likelihood function
Solution to the problem that jsp language cannot be recognized in idea
Install the pit that the electron has stepped on
Audio resource settings for U3D resource management
Bacteriostatic circle scanning correction template
Feign implements dynamic URL
Intel's new GPU patent shows that its graphics card products will use MCM Packaging Technology
A fan summed up so many interview questions for you. There is always one you need!
Conditional test, if, case conditional test statements of shell script
String & memory function (detailed explanation)