当前位置:网站首页>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;
}
边栏推荐
- MySQL backup and recovery + experiment
- node工程中package.json文件作用是什么?里面的^尖括号和~波浪号是什么意思?
- Yyds dry goods inventory [Gan Di's one week summary: the most complete and detailed in the whole network]; detailed explanation of MySQL index data structure and index optimization; remember collectio
- Do you know the eight signs of a team becoming agile?
- Blue Bridge Cup Square filling (DFS backtracking)
- Complex, complicated and numerous: illustration of seven types of code coupling
- Nebula importer data import practice
- Great God developed the new H5 version of arXiv, saying goodbye to formula typography errors in one step, and mobile phones can also easily read literature
- Database postragesq peer authentication
- MySQL REGEXP:正则表达式查询
猜你喜欢
Wechat applet: the latest WordPress black gold wallpaper wechat applet two open repair version source code download support traffic main revenue
Win:使用 PowerShell 检查无线信号的强弱
Great God developed the new H5 version of arXiv, saying goodbye to formula typography errors in one step, and mobile phones can also easily read literature
Remote control service
[flutter topic] 64 illustration basic textfield text input box (I) # yyds dry goods inventory #
JS implementation determines whether the point is within the polygon range
[development of large e-commerce projects] performance pressure test - Performance Monitoring - heap memory and garbage collection -39
Yyds dry inventory jetpack hit dependency injection framework Getting Started Guide
Actual combat simulation │ JWT login authentication
Exploration and Practice of Stream Batch Integration in JD
随机推荐
Include rake tasks in Gems - including rake tasks in gems
Redis(1)之Redis简介
Interesting practice of robot programming 16 synchronous positioning and map building (SLAM)
Yyds dry inventory swagger positioning problem ⽅ formula
Global and Chinese markets of emergency rescue vessels (errv) 2022-2028: Research Report on technology, participants, trends, market size and share
To sort out messy header files, I use include what you use
node工程中package.json文件作用是什么?里面的^尖括号和~波浪号是什么意思?
Wechat applet: independent background with distribution function, Yuelao office blind box for making friends
PowerShell: use PowerShell behind the proxy server
PHP Joseph Ring problem
Yyds dry goods inventory kubernetes management business configuration methods? (08)
MySQL regexp: Regular Expression Query
【CTF】AWDP总结(Web)
PHP wechat official account development
Database postragesql lock management
微信小程序:星宿UI V1.5 wordpress系统资讯资源博客下载小程序微信QQ双端源码支持wordpress二级分类 加载动画优化
Global and Chinese market of veterinary thermometers 2022-2028: Research Report on technology, participants, trends, market size and share
Database postragesq role membership
Win: add general users to the local admins group
Win:使用 PowerShell 检查无线信号的强弱