当前位置:网站首页>Summary of Haut OJ 2021 freshman week
Summary of Haut OJ 2021 freshman week
2022-07-05 05:20:00 【hunziHang】
problem E: Juju Games ( Pit point : The second line of input string needs to eat the newline character in advance )
Problem description :
Juju wrote a course design whim and made a puzzle ( Simple ) Little games . The middle part of the game is to use the keyboard W、A、S、D( On behalf of 、 Left 、 Next 、 Right ) To control character movement , Now the game character is at the origin , Get together for you n Capital letters ‘W’’A’’S’’D’, If the character goes through this n After operation, it is still at the origin. Please output ”YES”, Otherwise output ”NO”( No quotation marks ).
Input :
first line , A positive integer n, And n<=100
The second line ,n Characters , Each character is a capital letter ‘W’ or ’A’ or ’S’ or ’D’
Output :
a line , If the character is still output at the origin ”YES”( No quotation marks ), Otherwise output ”NO”( No quotation marks )
The sample input :
8 WASDWASD
Sample output :
YES
Cause analysis :
For the first time, I forgot to suck out the line break in advance
Solution :
#include<stdio.h>
int main(){
int w = 0, a = 0, s = 0, d = 0; // Statistics WASD Number of occurrences of
int n, i;
char op;
scanf("%d%*c", &n); // Use %*c Eat the end of the line It's fine too getchar();
for(i = 1; i <= n; i++){
scanf("%c", &op);
// Count the occurrence times of various characters
if(op == 'W') w++;
else if(op == 'A') a++;
else if(op == 'S') s++;
else if(op == 'D') d++;
}
// If the up and down times are equal And The left and right times are equal , Stop at the origin
if(w == s && a == d) printf("YES");
else printf("NO");
return 0;
}
problem F: Lucky numbers of Juju ( Error point : Complicate the problem )
Problem description :
Juju looks AC A lot of questions and high accuracy , But Juju likes to attribute these to “ luck ”. Juju has its own lucky number :5141919. Juan Juan also wants to be lucky, but doesn't want to be like Juju numbers , I want to know about a number x Can you delete any of them from Juju's lucky numbers 1 obtain .
Input :
a line , An integer x( Guarantee x It's not equal to 5141919)
Output :
If possible, output “YES”, Otherwise output “NO”.( No quotation marks )
The sample input :
51499
Sample output :
YES
Cause analysis :
Ideas : Create two arrays , The first array record 5141919 The number of times each number appears , The second array stores the number of occurrences of each number of the input integer , Then compare the two arrays by 1 Whether the number of times each number appears is the same , Then judge the second array 1 It appears less than the first array ;
Simple ideas : Enumerate everything directly
Solution :
#include<stdio.h>
int main(){
int n;
scanf("%d", &n);
if(n == 5499 || n == 51499 || n == 54199 || n == 54919 || n == 514199 || n == 514919 || n == 541919)
printf("YES");
else printf("NO");
return 0;
}
problem H: Aggregated Rating The goal is ( Error point : Code complexity )
Problem description :
Juju is playing a big multiplayer game tonight (?) Write bug game , Juju's evaluation is : Send , Lose big points !( In fact, every time Juju says this, he will get a big score ). Out Rating( fraction ) After the gathering, set a new Rating The goal is . Juju believes that if the non-zero number in each digit of a number does not exceed 1 individual , Then the number can be regarded as a Rating The goal is .
such as ,600,10000,7 It's all reasonable Rating The goal is , and 12,3001,12345 It is not .
Now? , Juju knows her Rating, Write it down as n, Please tell Juju the next Rating How many points is the goal still missing ?
Input :
a line , A positive integer n, And n<=100000
Output :
a line , A positive integer , At present Rating From the next Rating How many points is the goal .
The sample input :
2021
Sample output :
979
Cause analysis :
1. To find the highest digit, I used an array to find ( Simple ideas : Directly find the digits , Input number / 10 Of ( digit -1) Power )
Solution :
#include<stdio.h>
#include<math.h>
int main(){
int rat, r, ans, k, t = 0;
scanf("%d", &rat);
r = rat;
// Find digit
while(rat){
t++;
rat = rat / 10;
}
// Find out 10 Of ( length -1) Power
k = pow(10, t - 1);
// Find out the result
ans = ((r / k) + 1) * k - r;
printf("%d", ans);
return 0;
}
summary :
1. Pay more attention to details , We still need to strengthen the training of character types
2. Don't solve problems honestly , Is there any coincidence , Simple way to solve .
边栏推荐
- How can the Solon framework easily obtain the response time of each request?
- lxml.etree.XMLSyntaxError: Opening and ending tag mismatch: meta line 6 and head, line 8, column 8
- Heap sort summary
- Download and use of font icons
- The next key of win generates the timestamp file of the current day
- Unity ugui source code graphic
- 使用Room数据库报警告: Schema export directory is not provided to the annotation processor so we cannot expor
- cocos2dx_ Lua particle system
- A new micro ORM open source framework
- [转]: OSGI规范 深入浅出
猜你喜欢
Pointnet++的改进
嵌入式数据库开发编程(五)——DQL
Grail layout and double wing layout
Reverse one-way linked list of interview questions
object serialization
【论文笔记】Multi-Goal Reinforcement Learning: Challenging Robotics Environments and Request for Research
[轉]: OSGI規範 深入淺出
质量体系建设之路的分分合合
lxml.etree.XMLSyntaxError: Opening and ending tag mismatch: meta line 6 and head, line 8, column 8
SAP-修改系统表数据的方法
随机推荐
On-off and on-off of quality system construction
Research on the value of background repeat of background tiling
Heap sort summary
[paper notes] multi goal reinforcement learning: challenging robotics environments and request for research
Solon 框架如何方便获取每个请求的响应时间?
64 horses, 8 tracks, how many times does it take to find the fastest 4 horses at least
[to be continued] [UE4 notes] L2 interface introduction
Stm32cubemx (8): RTC and RTC wake-up interrupt
Haut OJ 1221: a tired day
[turn]: OSGi specification in simple terms
Use of snippets in vscode (code template)
lxml.etree.XMLSyntaxError: Opening and ending tag mismatch: meta line 6 and head, line 8, column 8
远程升级怕截胡?详解FOTA安全升级
软件测试 -- 0 序
[allocation problem] 455 Distribute cookies
YOLOv5-Shufflenetv2
Embedded database development programming (V) -- DQL
YOLOv5添加注意力机制
Download and use of font icons
【论文笔记】Multi-Goal Reinforcement Learning: Challenging Robotics Environments and Request for Research