-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2291.cpp
More file actions
34 lines (29 loc) · 771 Bytes
/
2291.cpp
File metadata and controls
34 lines (29 loc) · 771 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*
problem: Divine Numbers
url: https://www.urionlinejudge.com.br/judge/en/problems/view/2291
*/
#include <iostream>
#include <vector>
using namespace std;
vector<long long> divisores(long long n) {
vector<long long> somaDivisoresAcumulada(n);
for(long long i = 1; i <= n; i++){
for (long long j = i; j <=n; j +=i){
somaDivisoresAcumulada[j] += i;
}
}
for(long long i = 1; i <=n; i++){
somaDivisoresAcumulada[i] += somaDivisoresAcumulada[i-1];
}
return somaDivisoresAcumulada;
}
int main() {
vector<long long> somaDivisoresAcumulada = divisores(1000000);
long long n;
cin >> n;
while(n) {
cout << somaDivisoresAcumulada[n] << endl;
cin >> n;
}
return 0;
}