当前位置:网站首页>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;
}
边栏推荐
- 保留有效位数;保留小数点后n位;
- Programming skills: script scheduling
- On traversal of tree nodes
- Nvidia Deepstream 运行延迟,卡顿,死机处理办法
- Longest substring without repeated characters (Sword finger offer 48)
- 关于TensorFlow使用GPU加速
- I want to buy fixed income + products, but I don't know what its main investment is. Does anyone know?
- Handling methods for NVIDIA deepstream running delay, jamming and crash
- VS编译遇到的问题
- AbortController的使用
猜你喜欢

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

Let's talk about the process of ES Indexing Documents

Fundamentals of software engineering (I)

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

Today, Teng Xu came out with 37k during the interview. It's really a miracle. He showed me his skill

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

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

AQS Abstract queue synchronizer

CV领域一代宗师黄煦涛教授86岁冥诞,UIUC专设博士奖学金激励新锐

E ModuleNotFoundError: No module named ‘psycopg2‘(已解决)
随机推荐
What kind of experience is it to read other people's code
设计原则和思想:设计原则
漏洞复现----34、yapi 远程命令执行漏洞
E ModuleNotFoundError: No module named ‘psycopg2‘(已解决)
In the past, domestic mobile phones were arrogant in pricing and threatened that consumers would like to buy or not, but now they have plummeted by 2000 for sale
CentOS8-postgresql初始化时报错:initdb: error: invalid locale settings; check LANG and LC_* environment
基于WEB平台的阅读APP设计与实现
Pychart installation and setup
#28对象方法扩展
Leetcode 724. Find the central subscript of the array (yes, once)
Hyperledger Fabric 2. X custom smart contract
洛谷入门2【分支结构】题单题解
[high concurrency] deeply analyze the callable interface
Pisa-Proxy 之 SQL 解析实践
Strong, weak, soft and virtual references of ThreadLocal
AbortController的使用
AI begets the moon, and thousands of miles share the literary heart
Eolink 推出面向中小企业及初创企业支持计划,为企业赋能!
522. longest special sequence II / Sword finger offer II 101 Split equal sum subset
数学建模经验分享:国赛美赛对比/选题参考/常用技巧