当前位置:网站首页>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;
}
边栏推荐
- Different perspectives
- 優雅的自定義 ThreadPoolExecutor 線程池
- Fundamentals of software engineering (I)
- 我想買固收+產品,但是不了解它主要投資哪些方面,有人知道嗎?
- 2022-2-16 learning the imitated Niuke project - Section 6 adding comments
- Let's talk about the process of ES Indexing Documents
- [high concurrency] deeply analyze the callable interface
- 直播app运营模式有哪几种,我们该选择什么样的模式?
- Pychart installation and setup
- Je veux acheter des produits à revenu fixe + mais je ne sais pas quels sont ses principaux investissements.
猜你喜欢

Talk about redis transactions

Volatile and JMM

Interpretation of new version features of PostgreSQL 15 (including live Q & A and PPT data summary)

基于Vue+Node+MySQL的美食菜谱食材网站设计与实现

What kind of experience is it to read other people's code

E ModuleNotFoundError: No module named ‘psycopg2‘(已解决)

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

PSS:你距离NMS-free+提点只有两个卷积层 | 2021论文

Admixture usage document Cookbook

SQL parsing practice of Pisa proxy
随机推荐
AutoCAD - line width setting
手机号码的格式
Design and implementation of reading app based on Web Platform
Design of spread spectrum communication system based on FPGA (with main code)
Use of abortcontroller
AQS Abstract queue synchronizer
#28对象方法扩展
PCL Library - error reporting solution: cmake and Anaconda conflicts during installation
[advanced mathematics] from normal vector to surface integral of the second kind
Can the teacher tell me what the fixed income + products are mainly invested in?
Maximum profit of stock (offer 63)
Experience sharing of mathematical modeling: comparison between China and USA / reference for topic selection / common skills
[issue 17] golang's one-year experience in developing Meitu
Piblup test report 1- pedigree based animal model
Notes learning summary
Atomic operation class
Let's talk about the process of ES Indexing Documents
R language triple becomes matrix matrix becomes triple
Reflection learning summary
CAS comparison and exchange