# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
76594 | 2018-09-15T06:27:32 Z | charlies_moo | Savrsen (COCI17_savrsen) | C++ | 912 ms | 39824 KB |
#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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 372 KB | Output is correct |
3 | Correct | 4 ms | 832 KB | Output is correct |
4 | Correct | 2 ms | 832 KB | Output is correct |
5 | Correct | 841 ms | 35824 KB | Output is correct |
6 | Correct | 912 ms | 39824 KB | Output is correct |
7 | Correct | 827 ms | 39824 KB | Output is correct |
8 | Correct | 123 ms | 39824 KB | Output is correct |