Submission #86493

# Submission time Handle Problem Language Result Execution time Memory
86493 2018-11-26T11:35:56 Z I_use_Brute_force Savrsen (COCI17_savrsen) C++17
120 / 120
2097 ms 78876 KB
 #include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair <int, int>
#define sz(a) (int)(a.size()) 
#define resize(v) v.resize(unique(all(v)) - v.begin()); 
#define all(a) a.begin(), a.end()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)
#define int long long

using namespace std;

void Fast_Read_Out()
{
	ios_base::sync_with_stdio(0);
	cin.tie(), cout.tie();
}

void Random()
{
	unsigned int seed;
	asm("rdtsc" : "=A" (seed));
	srand(seed);        
}

unsigned int Time()
{
	 unsigned int time = clock() / 1000.00;
	 return time;
}

const int inf = (1e9) + 123;
const int N = (1e7);

long long sum[N + 1];

void Resheto()
{
	for(int i = 2; i <= N; i++)
		for(int j = i + i; j <= N; j += i) sum[j] += i;
	sum[1] = 1;	
}

main ()
{
	#ifdef JUDGE
		freopen("input.txt", "r", stdin);
	#endif 
	Random();
	Fast_Read_Out();
	long long a, b;
	cin >> a >> b;
	long long sm = 0;
	Resheto();
	for(int i = a; i <= b; i++) sm += abs(i - sum[i] - 1);
	cout << sm << endl;	
	#ifdef JUDGE
//		cout << Time() << endl;
	#endif
}
// Easy Peasy Lemon Squeezy                                                            Sometimes it's the very people who no one imagines anything of who do the things no one can imagine.

Compilation message

savrsen.cpp:46:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main ()
       ^
# Verdict Execution time Memory Grader output
1 Correct 2089 ms 78584 KB Output is correct
2 Correct 2097 ms 78704 KB Output is correct
3 Correct 2090 ms 78720 KB Output is correct
4 Correct 1998 ms 78776 KB Output is correct
5 Correct 1994 ms 78836 KB Output is correct
6 Correct 2016 ms 78876 KB Output is correct
7 Correct 2004 ms 78876 KB Output is correct
8 Correct 2028 ms 78876 KB Output is correct