当前位置:网站首页>One question per day, punch in
One question per day, punch in
2022-06-25 14:50:00 【䨁 逦】
P2141 [NOIP2014 Popularization group ] Abacus mental arithmetic test
Submit 284.44k
adopt 82.03k
The time limit 1.00s
Memory limit 125.00MB
Submit your answers to the questionnaire
Retract
Title Description
Abacus mental calculation is a kind of calculation technology that can complete fast calculation by simulating the change of abacus in the brain . Abacus mental arithmetic training , Can develop intelligence , It can bring a lot of convenience to our daily life , So it's popularized in many schools .
Some school's abacus mental arithmetic teacher uses a kind of quick examination abacus mental arithmetic addition ability test method . He randomly generates a set of positive integers , The numbers in the set are different , Then ask the students to answer : How many of them , Exactly equal to the other two in the set ( Different ) Sum of the numbers ?
Recently, the teacher gave some test questions , Please help me find out .
( This topic is 2014NOIP Universal T1)
Input format
There are two lines , The first line contains an integer nn, The number of positive integers given in the test .
The second line has nn A positive integer , Every two positive integers are separated by a space , A positive integer given in a test .
Output format
An integer , The answer to a test question .
I/o sample
Input #1 Copy
4 1 2 3 4
Output #1 Copy
2
explain / Tips
【 Sample explanation 】
from 1+2=3,1+3=41+2=3,1+3=4, So the answer to meet the test requirements is 22.
Be careful , The addend and the addend must be two different numbers in the set .
【 Data description 】
about 100\%100% The data of ,3 ≤ n ≤ 1003≤n≤100, The size of the positive integer given by the test question does not exceed 10,00010,000.
There is a hole in this question
such as 2+3=5 , and 1+4=5 It's a kind of , Therefore, it is necessary to check the duplicate , So I can mark
#include<cstdio>
#include<iostream>
using namespace std;
int a[105]={0};
int main(){
int n=0;
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
scanf("%d",&a[i]);
}
int x=0,y=0,all=0;
for(int i=1;i<n;i++)
{
x=a[i];
for(int j=i+1;j<=n;j++)
{
y=a[j];
for(int h=1;h<=n;h++)
{
if(x+y==a[h])
{
all++;
}
}
}
}
printf("%d",all);
return 0;
} No duplicate check code
According to the code of the topic
#include<cstdio>
#include<iostream>
using namespace std;
int a[105]={0},b[105];
int main(){
int n=0;
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
scanf("%d",&a[i]);
b[i]=2;
}
int x=0,y=0,all=0;
for(int i=1;i<n;i++)
{
x=a[i];
for(int j=i+1;j<=n;j++)
{
y=a[j];
for(int h=1;h<=n;h++)
{
if(x+y==a[h]&&b[h]!=1)
{
all++;
b[h]=1;
}
}
}
}
printf("%d",all);
return 0;
}
边栏推荐
- Compile Caffe's project using cmake
- 14 -- 验证回文字符串 Ⅱ
- Build a minimalist gb28181 gatekeeper and gateway server, establish AI reasoning and 3D service scenarios, and then open source code (I)
- JS Base64 Library Learning
- PubSub JS library realizes "cross component" data transfer
- Async await to achieve sleep waiting effect
- Master XSS completely from 0 to 1
- Uniapp cloud packaging app
- 分享自己平时使用的socket多客户端通信的代码技术点和软件使用
- 15 -- k points closest to the origin
猜你喜欢

TSDB在民机行业中的应用

Jaspersoft studio adding MySQL database configuration

Gif动画怎么在线制作?快试试这款gif在线制作工具

JS component

Gif动图如何裁剪?收下这个图片在线裁剪工具

New good friend Pinia, leading the new era of state management

【Try to Hack】vulnhub DC1

Heavyweight! The domestic IDE is released and developed by Alibaba. It is completely open source! (high performance + high customization)

What moment makes you think there is a bug in the world?

Time stamp calculation and audio-visual synchronization of TS stream combined video by ffmpeg protocol concat
随机推荐
Application of TSDB in civil aircraft industry
Extend JS copy content to clipboard
JS floating point multiplication and division method can not accurately calculate the problem
HMS Core机器学习服务实现同声传译,支持中英文互译和多种音色语音播报
dmsetup命令
【中国海洋大学】考研初试复试资料分享
How to make GIF animation online? Try this GIF online production tool
The best screenshot tool in the world, color absorption tool snipaste
[deep learning] multi label learning
NBD Network Block Device
Common classes in QT
JS functions
Add the resources directory under test in idea
2022年广东高考分数线出炉,一个几家欢喜几家愁
dev/mapper的解释
In 2022, the score line of Guangdong college entrance examination was released, and several families were happy and several worried
从408改考自主命题,211贵州大学考研改考
Customization and encapsulation of go language zap library logger
Gif动图如何裁剪?收下这个图片在线裁剪工具
合宙Air32F103CBT6开发板上手报告