Submission #76594

#TimeUsernameProblemLanguageResultExecution timeMemory
76594charlies_mooSavrsen (COCI17_savrsen)C++98
120 / 120
912 ms39824 KiB
#include <cstdio> #include <cmath> #include <iostream> using namespace std; long long ans=0; int sum[10000001]; int main() { int a,b; cin>>a>>b; for(int i=a;i<=b;++i) sum[i]=1; sum[1]=0; int upb=sqrt(b); for(int i=2;i<=upb;++i) for(int j=a/i;j<=b/i;++j) { if(i>j) continue; sum[j*i]=(j>1) ? (sum[j*i]+i) : sum[j*i]; sum[j*i]+=j; sum[j*i]=(i==j) ? (sum[j*i]-i) : sum[j*i]; } for(int i=a;i<=b;++i) ans+=abs(sum[i]-i); cout<<ans; return 0; }

Compilation message (stderr)

savrsen.cpp: In function 'int main()':
savrsen.cpp:18:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
     for(int i=2;i<=upb;++i)
     ^~~
savrsen.cpp:27:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  for(int i=a;i<=b;++i)
  ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...