Submission #482193

# Submission time Handle Problem Language Result Execution time Memory
482193 2021-10-23T15:19:39 Z MilosMilutinovic Savrsen (COCI17_savrsen) C++14
120 / 120
1042 ms 39444 KB
#include <bits/stdc++.h>
#define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
#define fb(i,a,b) for(int (i) = (a); (i) >= (b); --(i))
#define pb push_back

using namespace std;

int sum[10000005];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	ff(i,1,1e7){
	   for(int j = i + i; j <= 1e7; j += i)sum[j] += i;
	}
	int a, b;
	cin >> a >> b;
	long long ans = 0;
	ff(i,a,b)ans += abs(i-sum[i]);
	cout << ans;
	return 0;
}

Compilation message

savrsen.cpp: In function 'int main()':
savrsen.cpp:2:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    2 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
savrsen.cpp:15:2: note: in expansion of macro 'ff'
   15 |  ff(i,1,1e7){
      |  ^~
savrsen.cpp:2:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    2 | #define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
      |                           ^
savrsen.cpp:21:2: note: in expansion of macro 'ff'
   21 |  ff(i,a,b)ans += abs(i-sum[i]);
      |  ^~
# Verdict Execution time Memory Grader output
1 Correct 933 ms 39444 KB Output is correct
2 Correct 942 ms 39432 KB Output is correct
3 Correct 964 ms 39424 KB Output is correct
4 Correct 1038 ms 39424 KB Output is correct
5 Correct 1042 ms 39432 KB Output is correct
6 Correct 989 ms 39428 KB Output is correct
7 Correct 1006 ms 39432 KB Output is correct
8 Correct 981 ms 39424 KB Output is correct