当前位置:网站首页>Abacus mental arithmetic test
Abacus mental arithmetic test
2022-07-05 01:43:00 【Stars are not last night 334】
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 n, The number of positive integers given in the test .
The second line has n 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=4, So the answer to meet the test requirements is 2.
Be careful , The addend and the addend must be two different numbers in the set .
【 Data description 】
about 100% The data of ,3≤n≤100, The size of the positive integer given by the test question does not exceed 10,000.
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,a[100],b[100],bk=0;// First , Defining variables ,n Is the number of numbers ,a It's the number. ,b To eliminate repetition ,bk It's to record (book)
cin>>n;// Read in
for(int i=0;i<n;i++){
cin>>a[i];// Read in
b[i]=2;// Be careful , Here's the point , Many people don't get full marks because of this , The repeated calculation is included , So here we need something like a switch to indicate whether it repeats , If 2 It's the one that hasn't been moved , If 1 It's moved
}
for(int i=0;i<n;i++){// Because it only needs two numbers to calculate , So you can simply do two cycles , Here is the law of Mathematics , Such as :1,2,3,4 Choose two of the four numbers and add them , Want all combinations , We have 1,2、1,3、1,4、2,3、2,4、3,4
for(int o=i+1;o<n;o++){
for(int p=0;p<n;p++){// Repeatedly test all the numbers one by one to see if they are the sum of all the combinations
if(a[p]==a[i]+a[o]&&b[p]!=1){// Determine whether it is the sum of all combinations . For uniqueness , So to test a Have you been passive ,b It comes in handy here
bk++;
b[p]=1;// If you haven't moved, just a Corresponding b Set as moved
}
}
}
}
cout<<bk;// Output
return 0;
}
边栏推荐
- Comment mettre en place une équipe technique pour détruire l'entreprise?
- 微信小程序:微群人脉微信小程序源码下载全新社群系统优化版支持代理会员系统功能超高收益
- Application and Optimization Practice of redis in vivo push platform
- 如何搭建一支搞垮公司的技術團隊?
- runc hang 导致 Kubernetes 节点 NotReady
- Database postragesq peer authentication
- Win: use PowerShell to check the strength of wireless signal
- Blue Bridge Cup Square filling (DFS backtracking)
- Redis' hyperloglog as a powerful tool for active user statistics
- Unified blog writing environment
猜你喜欢
Do you know the eight signs of a team becoming agile?
[development of large e-commerce projects] performance pressure test - Optimization - impact of middleware on performance -40
[OpenGL learning notes 8] texture
The perfect car for successful people: BMW X7! Superior performance, excellent comfort and safety
runc hang 导致 Kubernetes 节点 NotReady
Li Kou Jianzhi offer -- binary tree chapter
【大型电商项目开发】性能压测-优化-中间件对性能的影响-40
To sort out messy header files, I use include what you use
Is there a sudden failure on the line? How to make emergency diagnosis, troubleshooting and recovery
Win:使用 PowerShell 检查无线信号的强弱
随机推荐
Lsblk command - check the disk of the system. I don't often use this command, but it's still very easy to use. Onion duck, like, collect, pay attention, wait for your arrival!
Exploration and Practice of Stream Batch Integration in JD
PHP 基础篇 - PHP 中 DES 加解密详解
phpstrom设置函数注释说明
Heartless sword English translation of Xi Murong's youth without complaint
How to build a technical team that will bring down the company?
Classification of performance tests (learning summary)
[CTF] AWDP summary (WEB)
Win: use shadow mode to view the Desktop Session of a remote user
Common bit operation skills of C speech
Outlook:总是提示输入用户密码
PHP Basics - detailed explanation of DES encryption and decryption in PHP
Wechat applet: the latest WordPress black gold wallpaper wechat applet two open repair version source code download support traffic main revenue
Redis' hyperloglog as a powerful tool for active user statistics
JS implementation determines whether the point is within the polygon range
Nebula Importer 数据导入实践
微信小程序:独立后台带分销功能月老办事处交友盲盒
A simple SSO unified login design
Expansion operator: the family is so separated
Async/await you can use it, but do you know how to deal with errors?