Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- typedef long double ld;
- #define int ll
- #define doube ld
- #define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
- #define pii pair<int , int>
- #define pb emplace_back
- #define endl '\n'
- #define all(x) x.begin() , x.end()
- #define rall(x) x.rbegin() , x.rend()
- #define F first
- #define S second
- const int mod = 1e9 + 7;
- const int MAXX = 2005;
- const int N = 2000;
- int n;
- int ans = 0;
- bool p[MAXX];
- vector<int> v;
- vector<int>::iterator it;
- int gcd(int a , int b){
- while(a && b){
- if(a > b)
- a %= b;
- else
- b %= a;
- }
- return a + b;
- }
- void sieve(){
- p[2] = true;
- for(int i = 3; i <= N; i += 2){
- p[i] = true;
- }
- for(int i = 3; (i * i) <= N; i += 2){
- if(p[i]){
- for(int j = (i + i + i); j <= N; j += (2 * i)){
- p[j] = false;
- }
- }
- }
- v.pb(2);
- for(int i = 3; i < N; i += 2){
- if(p[i])
- v.pb(i);
- }
- }
- int f(int n , int x , int per){
- int k = per;
- int sum = 0;
- for(int i = 1; i <= 21; i++){
- it = upper_bound(all(v) , x);
- int pos = it - v.begin();
- int l = v[pos];
- if((k * l * l) <= n){
- sum += f(n , l , k);
- }
- k *= x;
- if((k * x) > n)
- break;
- cout << k << endl;
- sum += (((n / k) - (n / (k * x))) * (n / (k * x)));
- }
- cout << x << " " << per << " " << sum << endl;
- return sum;
- }
- signed main()
- {
- _FastIO;
- sieve();
- cin >> n;
- int ans = f(n , 1LL * 2 , 1LL * 1);
- ans = (n * n) - (2 * ans);
- int sum = 0;
- for(int i = 1; i <= n; i++){
- for(int j = 1; j <= n; j++){
- if(gcd(i * i , j) == gcd(i , j * j)){
- sum++;
- }
- }
- }
- cout << sum << " " << ans << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement