Submission #86392

# Submission time Handle Problem Language Result Execution time Memory
86392 2018-11-26T08:54:10 Z I_use_Brute_force Savrsen (COCI17_savrsen) C++14
60 / 120
3000 ms 1432 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 ++)

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 = int(1e9) + 123;
const int N = int(1e5) + 1;

vector <int> v;
int lp[N], d[N];
vector <int> pr;

void Resheto()
{
	for(int i = 2; i <= N - 1; i++)
	{
		if(lp[i] == 0)
		{
			lp[i] = i;
			pr.pb(i);
		}
		for(int j = 0; j < sz(pr) && pr[j] <= lp[i] && pr[j] * i * 1ll <= N - 1; j++) lp[pr[j] * i] = pr[j];
	}
}

int Prime_Multipliers(int x)
{
	int del = 2;
	int ans = 1;
	if(d[x]) return x - 1;
	while(x > 1)
	{
		if(d[x]) 
		{
			ans += x; 
			break;
		}
		while(x % del == 0) ans += del, x /= del, cout << del << ' ';
		del++;
	}
	return ans;
}

int main ()
{
	#ifdef JUDGE
		freopen("input.txt", "r", stdin);
	#endif 
	Random();
	Fast_Read_Out();
	int a, b;
	cin >> a >> b;
	Resheto();
	for(int i = 0; i < sz(pr); i++) d[pr[i]]++;
	long long res = 0;
	for(int i = a; i <= b; i++)
	{
		int ans = 0;
		for(int j = 2; j * j <= i; j++)
		{
			if(i % j == 0) 
			{
				ans += j;
				int cur = i / j;
				if(i % cur == 0 && cur != j) ans += cur;
			}
		}
		if(ans == 0)
		{ 
			res += i - 1;
			continue;
		}
		ans++;
		res += abs(i - ans);
	}
	if(a == 1) res++;
	cout << res << 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.
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1272 KB Output is correct
2 Correct 4 ms 1372 KB Output is correct
3 Correct 106 ms 1432 KB Output is correct
4 Correct 18 ms 1432 KB Output is correct
5 Execution timed out 3033 ms 1432 KB Time limit exceeded
6 Execution timed out 3040 ms 1432 KB Time limit exceeded
7 Execution timed out 3036 ms 1432 KB Time limit exceeded
8 Execution timed out 3042 ms 1432 KB Time limit exceeded