当前位置:网站首页>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;
}
边栏推荐
- Design and implementation of reading app based on Web Platform
- Julia1.1 installation instructions
- 原子操作类
- Massive data! Second level analysis! Flink+doris build a real-time data warehouse scheme
- Synchronized and lock escalation
- 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
- Abnormal analysis of pcf8591 voltage measurement data
- Unity3d best practices: folder structure and source control
- 2022年最新《谷粒学院开发教程》:8 - 前台登录功能
- 创建数据库并使用
猜你喜欢
Using redis skillfully to realize the like function, isn't it more fragrant than MySQL?
QT notes (XXVIII) using qwebengineview to display web pages
Is flutter easy to learn? How to learn? The most complete introduction and actual combat of flutter in history. Take it away without thanks~
阅读别人的代码,是一种怎样的体验
Professor huangxutao, a great master in CV field, was born at the age of 86. UIUC specially set up a doctoral scholarship to encourage cutting-edge students
[high concurrency] deeply analyze the callable interface
洛谷_P1002 [NOIP2002 普及组] 过河卒_dp
What kind of experience is it to read other people's code
Talk about redis transactions
ReentrantLock、ReentrantReadWriteLock、StampedLock
随机推荐
专用发票和普通发票的区别
CV领域一代宗师黄煦涛教授86岁冥诞,UIUC专设博士奖学金激励新锐
Computer screen splitting method
避孕套巨头过去两年销量下降40% ,下降原因是什么?
Cesium 使用MediaStreamRecorder 或者MediaRecorder录屏并下载视频,以及开启摄像头录像。【转】
注解学习总结
Use GCC to generate an abstract syntax tree "ast" and dump it to Dot file and visualization
What is the London Silver code
Teach you how to realize pynq-z2 bar code recognition
Jupiter core error
Julia1.1 installation instructions
基于Vue+Node+MySQL的美食菜谱食材网站设计与实现
VS编译遇到的问题
Pychart installation and setup
All you want to know about large screen visualization is here
我想买固收+产品,但是不了解它主要投资哪些方面,有人知道吗?
How to change a matrix into a triple in R language (i.e. three columns: row, col, value)
[MySQL] query valid data based on time
ThreadLocal之强、弱、軟、虛引用
Use of abortcontroller