제출 #467894

#제출 시각아이디문제언어결과실행 시간메모리
467894kakayoshiSavrsen (COCI17_savrsen)C++14
120 / 120
1124 ms43692 KiB
#include <bits/stdc++.h> #pragma GCC optimize("O3") using namespace std; typedef long long int ll; typedef pair<ll,ll> pi; typedef pair<ll, pair<ll, ll> > pii; #define forw(i,a,b) for (ll i=a;i<=b;i++) #define forb(i,a,b) for (ll i=a;i>=b;i--) #define fast {ios::sync_with_stdio(false); cin.tie(0); } #define fi first #define se second #define pu push #define puf push_front #define pb push_back #define pof pop_front #define pob pop_back #define fr front #define all(a) a.begin(),a.end() const ll oo=1e18; const ll mod=1e9; const int base=31; const int tx[4]={0,0,1,-1}; const int ty[4]={1,-1,0,1}; // custom const ll maxN=1e7+2; const int tx1[4]={2,2,1,-1}; const int ty1[4]={-1,1,2,2}; ///// ll a, b,ans; vector <int> prime; //prime vector <int> spf; // smallest prime factor void sieve() { spf.assign(maxN+5,2); spf[1]=1; prime.pb(2); for(int i=3;i<=maxN;i+=2) { if (spf[i]==2) prime.pb(spf[i]=i); for(int j=0;j<prime.size() && prime[j]*i<=maxN && prime[j]<=spf[i];j++) spf[i*prime[j]]=prime[j]; } } ll power(ll a,ll n) { ll ans=1; while (n>0) { if (n&1) ans=ans*a; a=a*a; n>>=1; } return ans; } ll get(int x) { ll ans=1; while (x>1) { int p=spf[x]; int res=0; while (x%p==0) { x/=p; res++; } ans*=(power(p,res+1)-1)/(p-1); } return ans; } void solve() { sieve(); cin>>a>>b; forw(i,a,b) ans+=abs(2*i-get(i)); cout<<ans<<endl; } int main() { fast; //freopen("HHH.inp","r",stdin); //freopen("HHH.out","w",stdout); ll t=1; //cin>>t; while (t--) solve(); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

savrsen.cpp: In function 'void sieve()':
savrsen.cpp:41:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |         for(int j=0;j<prime.size() && prime[j]*i<=maxN && prime[j]<=spf[i];j++)
      |                     ~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...