当前位置:网站首页>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;
}边栏推荐
- Coredata acquisition in swift sorting, ascending, descending
- Detailed explanation of rect class
- Pit encountered by fastjason
- What kind of experience is it to develop a "grandson" who will call himself "Grandpa"?
- Concatapter tutorial
- Couldn't load this key (openssh ssh-2 private key (old PEM format))
- Using appbarlayout to realize secondary ceiling function
- [untitled]
- Sort (simple description)
- ES6 learning road 5 symbol
猜你喜欢

Dart asynchronous task

基于Svelte3.x桌面端UI组件库Svelte UI

Interpretation of source code demand:a rotation equivariant detector for aerial object detection

Couldn't load this key (openssh ssh-2 private key (old PEM format))

Talk about how the kotlin process started?

Implementing custom drawer component in quick application

Agp7.0|kts makes a reinforced plug-in

Based on svelte3 X desktop UI component library svelte UI

Evaluation standard for audio signal quality of intelligent speakers

Pytorch BERT
随机推荐
Dart basic notes
Duplicate entry '2' for key 'primary appears in JPA‘
Rew acoustic test (IV): test principle of rew
Flink Exception -- No ExecutorFactory found to execute the application
Esp32 things (VIII): music playing function of function development
Bind threads to run on a specific CPU logical kernel
Detailed explanation of rect class
Introduction to the runner of mmcv
Pytorch BERT
Opencv learning notes -day 11 (split() channel separation function and merge() channel merge function)
C accesses mongodb and performs CRUD operations
Talk about the kotlin cooperation process and the difference between job and supervisorjob
Rew acoustic test (V): equipment required for test
127.0.0.1、0.0.0.0和localhost
Implementing custom drawer component in quick application
Do you want the dialog box that pops up from the click?
Opencv learning notes -day3 (mat object and creation related operations mat:: clone(), mat:: copyto(), mat:: zeros(), mat:: ones(), scalar()...)
Mmdet line by line code interpretation of positive and negative sample sampler
启动jar包报错UnsupportedClassVersionError,如何修复
[untitled]