Untitled
unknown
c_cpp
2 years ago
876 B
1
Indexable
#include <bits/stdc++.h> #define ios ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0) using namespace std ; const int maxn = 1e6+7; int total = 1e6+7; long long sum , res; vector<int> v[maxn] , v2[maxn]; void mobius(int a){ for(int i = 2 ; i*i <= total ; i++){ if(v.size() == 0){ for(int j = i ; j <= total ; j+= i){ v[j].push_back(i); } } } for(int i = 0 ; i <= a ; i++){ sum = 0 ; for(int j = 0 ; j < v.size() ; j++){ sum *= v[i][j] ; } if(sum != v[i]) v2[i] = 0; else if(v[i].size() % 2 == 0) v2[i] = 1; else v2[i] = -1; } } int main(){ ios; int a ; cin >> a; for(int i = 2 ; i <= a ; i++){ res += v2[i] * pow(a/i , 2); } cout << a*a + res; return 0; }
Editor is loading...