当前位置:网站首页>Beginner level Luogu 1 [sequence structure] problem list solution
Beginner level Luogu 1 [sequence structure] problem list solution
2022-06-27 15:29:00 【Yang Yi】
Catalog
The swimming time of small fish
Primary school mathematics N close 1
Super Marie
- C++ For multiline output R"( )"
#include<iostream>
using namespace std;
int main() {
cout<<R"( ********
************
####....#.
#..###.....##....
###.......###### ### ###
........... #...# #...#
##*####### #.#.# #.#.#
####*******###### #.#.# #.#.#
...#***.****.*###.... #...# #...#
....**********##..... ### ###
....**** *****....
#### ####
###### ######
##############################################################
#...#......#.##...#......#.##...#......#.##------------------#
###########################################------------------#
#..#....#....##..#....#....##..#....#....#####################
########################################## #----------#
#.....#......##.....#......##.....#......# #----------#
########################################## #----------#
#.#..#....#..##.#..#....#..##.#..#....#..# #----------#
########################################## ############)"<<endl;
return 0;
}Letter conversion
- subject : Enter a lowercase letter , Output its corresponding capital letter . For example, the input q[ enter ] when , Will be output Q.
- Be careful :toupper The return is int value , To return a letter , Plus char, namely char(toupper())
#include<iostream> #include<ctype.h> using namespace std; int main(){ char a; cin>>a; cout<<char(toupper(a)); return 0; }
Number reversal
- utilize scanf and printf
#include<iostream>
using namespace std;
int main(){
char a,b,c,d;
scanf("%c%c%c.%c",&a,&b,&c,&d);
printf("%c.%c%c%c",d,c,b,a);
return 0;
}Regreasing soap water
- Enter three decimal places %.3f
printf("%.3f\n",t/n);The swimming time of small fish
#include<iostream>
using namespace std;
int main(){
int a,b,c,d;
cin>>a>>b>>c>>d;
// On the same day ,c Must be greater than a, Just judge d and b
if(d>=b)
{
cout<<c-a<<" "<<d-b;
}
else
{
cout<<c-a-1<<" "<<d+60-b;
}
return 0;
}Primary school mathematics N close 1
- Be careful 1.0/4 and 1/4 The difference between
- If it is 1/4 The result is 0, 1/3 Empathy however 1.0/4 Will come to 0.25

1/4 int type , 1.0/4 double type ; 1/4.0 double type It is also concluded that 0.25
The result of the expression is the result of the highest type
else if(T==13)
{cout<<(int)(pow(1.0*4/3*pi*1064,1.0/3))<<endl;}Triangle area
- sqrt Square root function

Apples and worms
- There are a few intact apples left , Then a few mouthfuls of apple must not count , The final result is int Directly erase the decimal point

#include<iostream>
using namespace std;
int main(){
double m,t,s;
cin>>m>>t>>s;
if(t==0) // Be careful when eating an apple 0 minutes , It means eating apples quickly , In the end, there must be 0 An apple .
{cout<<"0"<<endl;}
else if((int)(m-s/t)<=0){
cout<<"0"<<endl;}
else{
cout<<(int)(m-s/t)<<endl;}
return 0;
}Diagonals
- Four vertices have a diagonal intersection
- unsigned long long Range ratio long long Large scope
- unsigned long long The range is [0,2^64-1].long long The range is [-2^63-1,2^63+1]
n and n-1 There must be one 2 Multiple , therefore 2 It can be divided into ; Empathy n,n-1,n-2 One of them must be 3 Multiple , therefore 3 It can be divided into ( Get rid of 2 It will only eliminate the factor 2 And yes 3 No impact ); Empathy 4 You can also get rid of
#include<iostream>
using namespace std;
int main(){
unsigned long long n;
cin>>n;
cout<<n * (n-1) / 2 * (n-2) / 3 * (n-3) / 4<<endl;
return 0;
}
Late for school
- ceil() Rounding up
#include<iostream>
#include<math.h>
using namespace std;
int main() {
double s, v;
int hour = 7, min;
cin >> s >> v;
int total = ceil(s / v) + 10; //ceil() Rounding up 3/2=2 ceil(s/v) eg: cost 3.2 minute , according to 4 Minute calculation
int totalhour = total / 60;
min = 60 - total % 60; //70min, 6:50 60-10
if (total % 60 == 0)
min = 00;
while (totalhour--)
{
hour--; // If only write if (hour < 0) When hour = 24; when There are 24:30 hour from 7 Began to set , The same goes for the day before ,
if (hour < 0 && min != 00)
hour = 23;
else if (hour < 0)
hour = 24;
}
printf("%02d:%02d",hour ,min );
return 0;
}
边栏推荐
- Elegant custom ThreadPoolExecutor thread pool
- 2022-2-15 learning the imitated Niuke project - Section 5 shows comments
- 易周金融 | Q1手机银行活跃用户规模6.5亿;理财子公司布局新兴领域
- CentOS8-postgresql初始化时报错:initdb: error: invalid locale settings; check LANG and LC_* environment
- How is the London Silver point difference calculated
- Can the teacher tell me what the fixed income + products are mainly invested in?
- [digital signal processing] discrete time signal (discrete time signal knowledge points | signal definition | signal classification | classification according to certainty | classification according t
- 巧用redis实现点赞功能,它不比mysql香吗?
- Pri3d: a representation learning method for 3D scene perception using inherent attributes of rgb-d data
- 优雅的自定义 ThreadPoolExecutor 线程池
猜你喜欢

2022-2-16 learning the imitated Niuke project - Section 6 adding comments

漏洞复现----34、yapi 远程命令执行漏洞

VS编译遇到的问题

保留有效位数;保留小数点后n位;

Great God developed the new H5 version of arXiv, saying goodbye to formula typography errors in one step, and the mobile phone can easily read literature

洛谷入门2【分支结构】题单题解

直播app运营模式有哪几种,我们该选择什么样的模式?

Programming skills: script scheduling

基于SSM的Web网页聊天室系统

Unity3d best practices: folder structure and source control
随机推荐
Talk about redis transactions
[interview questions] common interview questions (I)
volatile与JMM
Reflection learning summary
Buuctf Misc
sql注入原理
Admixture usage document Cookbook
我想买固收+产品,但是不了解它主要投资哪些方面,有人知道吗?
Top ten Devops best practices worthy of attention in 2022
Knightctf 2022 web section
522. 最长特殊序列 II / 剑指 Offer II 101. 分割等和子集
Great God developed the new H5 version of arXiv, saying goodbye to formula typography errors in one step, and the mobile phone can easily read literature
Design and implementation of food recipe and ingredients website based on vue+node+mysql
Notes learning summary
数学建模经验分享:国赛美赛对比/选题参考/常用技巧
Maximum profit of stock (offer 63)
Pri3d: a representation learning method for 3D scene perception using inherent attributes of rgb-d data
AbortController的使用
PSS:你距离NMS-free+提点只有两个卷积层 | 2021论文
Pycharm安装与设置