当前位置:网站首页>Beginner level Luogu 2 [branch structure] problem list solution
Beginner level Luogu 2 [branch structure] problem list solution
2022-06-27 15:29:00 【Yang Yi】
Catalog
Leap year judgment
- ①400 Multiple
- ② yes 4 But it's not 100 Multiple
if((n%4==0&&n%100!=0)||n%400==0)Obesity
- At output time , Please round to six digits Significant figures Output , If there is a suffix in the decimal part 00, Do not output suffixes 00.
- You can use %g
(106 Bar message ) Keep valid digits ; After decimal point n position ;_ Yang Yi's blog -CSDN Blog
printf("%.6g\nOverweight", criterion);Three digit sorting

Unhappy Jinjin
#include<iostream>
#include<iomanip>
using namespace std;
int main() {
int a[7], b[7],sum[7],max=0,k;
for (int i = 0; i < 7; i++)
{
cin >> a[i] >> b[i];
}
bool happy = true;
for (int i = 0; i < 7; i++)
{
sum[i] = a[i] + b[i];
if (sum[i] > 8)
{
happy = false;
}
if (sum[i] > max)
{
max = sum[i];
k = i;
}
}
if (happy == true)
cout << "0";
if (happy == false)
cout << k+1;
return 0;
}Buy a pencil
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
using namespace std;
int main() {
int n,a;
double pencil[3], sum[3];
long long price[3];
cin >> n;
for (int i = 0; i < 3; i++)
{
cin >> pencil[i] >> sum[i];
}
for (int i = 0; i < 3; i++)
{
price[i]=ceil(n / pencil[i])*sum[i];
}
cout<<min(price[2],min(price[0], price[1]));
return 0;
}ISBN number
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
using namespace std;
int main() {
string a;
int sum = 1,sbm=0;
char x = 'X';
cin >> a;
for (int i = 0; i < 11; i++)
{
if (isdigit(a[i]))
{
sbm += (a[i]-'0') * sum;
++sum;
}
}
sbm %= 11;
if (a[12] == 'X'&&sbm == 10)
{
cout << "Right";
}
else if (a[12]!='X' && a[12]-'0' == sbm)
{
cout << "Right";
}
else
{
for (int i = 0; i < 12; i++)
{
cout << a[i];
}
if (sbm == 10)
cout << "X";
else
cout << sbm;
}
return 0;
}The voyage of a small fish
#include<iostream>
using namespace std;
int main() {
int n, x,a=0;
cin >> x >> n;
// Direct overall arrangement
while (n--)
{
if (x != 6 && x != 7)
a += 250;
x++;
if (x == 8)
x = 1;
}
cout << a;
return 0;
}Trigonometric functions
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
int main() {
int a, b, c,min1,max1;
cin >> a >> b >> c;
min1 = min(c, min(a, b));
max1 = max(c, max(a, b));
// right triangle Minimum acute angle sin value It must be The smallest edge / The largest edge
for (int i = 2; i <= min1; i++) // Factor finding , elimination .
{
if (min1%i == 0 && max1%i == 0)
{
min1 = min1 / i;
max1 = max1 / i;
}
}
cout << min1 << "/" << max1;
return 0;
}
ABC
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
string a;
int A[3];
for (int i = 0; i < 3; i++)
{
cin >> A[i];
}
cin >> a;
sort(A, A + 3);
for (int i = 0; i < 3; i++)
{
cout << A[a[i] - 'A']<<" ";
}
return 0;
}边栏推荐
- 洛谷_P1003 [NOIP2011 提高组] 铺地毯_暴力枚举
- Jupiter core error
- 关于TensorFlow使用GPU加速
- Is flutter easy to learn? How to learn? The most complete introduction and actual combat of flutter in history. Take it away without thanks~
- Référence forte, faible, douce et virtuelle de threadlocal
- Use GCC to generate an abstract syntax tree "ast" and dump it to Dot file and visualization
- QT notes (XXVIII) using qwebengineview to display web pages
- What are the characteristics of fixed income + products?
- 我想买固收+产品,但是不了解它主要投资哪些方面,有人知道吗?
- [advanced mathematics] from normal vector to surface integral of the second kind
猜你喜欢

Leetcode 724. Find the central subscript of the array (yes, once)

Admixture usage document Cookbook

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

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

CAS之比较并交换

CAS comparison and exchange
![洛谷_P1008 [NOIP1998 普及组] 三连击_枚举](/img/9f/64b0b83211bd1c615f2db9273bb905.png)
洛谷_P1008 [NOIP1998 普及组] 三连击_枚举

Knowledge map model
Talk about redis transactions
![洛谷_P1002 [NOIP2002 普及组] 过河卒_dp](/img/80/4edf21e0ac316fe3dd727159621acb.png)
洛谷_P1002 [NOIP2002 普及组] 过河卒_dp
随机推荐
AI begets the moon, and thousands of miles share the literary heart
Design and implementation of food recipe and ingredients website based on vue+node+mysql
Synchronized and lock escalation
ThreadLocal之强、弱、软、虚引用
Massive data! Second level analysis! Flink+doris build a real-time data warehouse scheme
CAS comparison and exchange
数学建模经验分享:国赛美赛对比/选题参考/常用技巧
Eolink 推出面向中小企业及初创企业支持计划,为企业赋能!
R language error
Can the teacher tell me what the fixed income + products are mainly invested in?
Computer screen splitting method
[interview questions] common interview questions (I)
Julia1.1 installation instructions
Today, Teng Xu came out with 37k during the interview. It's really a miracle. He showed me his skill
How QT sets some areas to be transparent in the background image
What is the London Silver unit
What is the London Silver code
[WUSTCTF2020]girlfriend
The global chip market may stagnate, and China's chip expansion accelerates to improve its self-sufficiency rate against the trend
AutoCAD - line width setting