Submission #76593

# Submission time Handle Problem Language Result Execution time Memory
76593 2018-09-15T06:25:49 Z charlies_moo Savrsen (COCI17_savrsen) C++
75 / 120
964 ms 39652 KB
#include <cstdio>
#include <cmath>
#include <iostream>

using namespace std;

long long ans=0;
int sum[10000000]; 

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

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 time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 4 ms 836 KB Output is correct
4 Incorrect 3 ms 836 KB Output isn't correct
5 Incorrect 832 ms 35856 KB Output isn't correct
6 Incorrect 964 ms 39652 KB Output isn't correct
7 Correct 792 ms 39652 KB Output is correct
8 Correct 98 ms 39652 KB Output is correct