include fstream using namespace std ifstream cin sum in ofstream cout

 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
#include <fstream>
using namespace std;
ifstream cin("sum.in");
ofstream cout("sum.out");
long long answer=0,mod;
int F(long long x){
answer=0;
mod=123456789;
for(int i=1;i<=x;i++){
for(int j=1;j<=i;j++){
if(i%j==0)answer=(answer+j*j)%mod;
}
}
return answer;
}
int main(){
long long n;
cin>>n;
F(n);
cout<<answer;
return 0;
}