Submission #86471

# Submission time Handle Problem Language Result Execution time Memory
86471 2018-11-26T11:19:18 Z NurstanDuisengaliev Savrsen (COCI17_savrsen) C++17
120 / 120
1458 ms 39656 KB
#include <bits/stdc++.h>

#define ll long long
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define F first
#define S second

using namespace std;

inline void boost(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
}
int dp[int(1e7) + 1];
inline void solve () {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	boost ();
	int a, b;
	cin >> a >> b;
	dp[1] = -1;
	int k = 0;
	for (int i = 2; i <= b; i ++) {
		if (dp[i] == 0) {
			dp[i] = 0;
			//cout << i << " "; 
		}
		for (int j = i + i; j <= b; j += i) {
			 	dp[j] += i;
		} 
	}
	ll sum = 0;
	for (int i = a; i <= b; i ++) {
		sum += abs(i - dp[i] - 1) ;
		//cout << i - dp[i] - 1 << " ";  
	}
	cout << sum;
}

int main(){                                	
	int kolT = 1;
//	cin >> kolT;
	while (kolT) {
		solve ();
		kolT --;
	}
	exit(0);
}

Compilation message

savrsen.cpp: In function 'void solve()':
savrsen.cpp:24:6: warning: unused variable 'k' [-Wunused-variable]
  int k = 0;
      ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 468 KB Output is correct
3 Correct 5 ms 804 KB Output is correct
4 Correct 1288 ms 39604 KB Output is correct
5 Correct 1458 ms 39652 KB Output is correct
6 Correct 1420 ms 39656 KB Output is correct
7 Correct 1181 ms 39656 KB Output is correct
8 Correct 157 ms 39656 KB Output is correct