当前位置:网站首页>Research on lg1403 divisor
Research on lg1403 divisor
2022-06-30 09:14:00 【The man of Jike will never admit defeat】
Title Description
Xiao Lian is studying some problems related to divisor recently , He counts every positive number N The number of divisors of , And f(N) To express . for example 12 The number of divisors is 1、2、3、4、6、12. therefore f(12)=6.f(n) Express n The approximate number of , Now give n, Ask for f(1) To f(n) The sum of .
Input format :
The input line , An integer n
Output format :
Output an integer , Represents the sum
sample input #1:3
sample output #1:5
thinking: Write the program on the first day after the holiday , I wrote two math problems , And this is not so simple , The key is function f(i) = n/i The determination of , This problem is transformed into , Find the sum of all the factors , Is to find that each number factor is 1 The number of and ( n/1 ), Each number factor is 2 The number of and ( n/2 ),…… So the result came out , It's easy to know the answer, isn't it , But I didn't think of it ... thank
#include<iostream>
using namespace std;
int n,ans;
int main(void){
cin>>n;
for(int i=1;i<=n;i++)
ans+=n/i;
cout<<ans;
}
边栏推荐
- Talk about the kotlin cooperation process and the difference between job and supervisorjob
- Introduction to MySQL basics day4 power node [Lao Du] class notes
- Design specification for smart speakers v1.0
- Opencv learning notes -day10 logical operation of image pixels (usage of rectangle function and rect function and bit related operation in openCV)
- Bind threads to run on a specific CPU logical kernel
- Occasionally, Flink data is overstocked, resulting in checkpoint failure
- C#访问MongoDB并执行CRUD操作
- Wikimedia Foundation announces the first customers of its new commercial product "Wikimedia enterprise"
- 127.0.0.1、0.0.0.0和localhost
- Opencv learning notes -day4 image pixel reading and writing operations (array traversal and pointer traversal implementation, uchar vec3b data type and mat class functions mat:: at(), mat:: ptr())
猜你喜欢
C accesses mongodb and performs CRUD operations
Rew acoustic test (III): generate test signal
Esp32 things (3): overview of the overall system design
Duplicate entry '2' for key 'primary appears in JPA‘
The elegant combination of walle and Jianbao
Deep understanding of kotlin collaboration context coroutinecontext
维基媒体基金会公布新商业产品“维基媒体企业”首批客户
Explanation on the use of password profiteering cracking tool Hydra
基于Svelte3.x桌面端UI组件库Svelte UI
Interpretation of source code demand:a rotation equivariant detector for aerial object detection
随机推荐
Flink Sql -- toAppendStream doesn‘t support consuming update and delete changes which
[JPEG] how to compile JPEG turbo library files on different platforms
Esp32 things (I): Preface
[shutter] solve failed assertion: line 5142 POS 12: '_ debugLocked‘: is not true.
JVM调优相关命令以及解释
Esp32 things (II): sharpening the knife without mistaking firewood - make preparations before project development
Small program learning path 1 - getting to know small programs
Six implementation methods of singleton mode
Concatapter tutorial
Alcohol tester scheme: what principle does the alcohol tester measure alcohol solubility based on?
Dart basic notes
挖财开户安全吗?怎么有人说不靠谱。
Rew acoustic test (V): equipment required for test
基于Svelte3.x桌面端UI组件库Svelte UI
C # get the current timestamp
C accesses mongodb and performs CRUD operations
[cmake] make command cannot be executed normally
Use of Baidu face recognition API
Esp32 (6): Bluetooth and WiFi functions for function development
Opencv learning notes -day 12 (ROI region extraction and inrange() function operation)