답안 #75034

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
75034 2018-09-08T05:11:40 Z charlies_moo Savrsen (COCI17_savrsen) C++14
0 / 120
3000 ms 3224 KB
#include <cstdio>
#include <cmath>
#include <iostream>

using namespace std;

long long is_perfect(long long n)
{
    long long sum=0;
    for(long long i=1;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
            sum+=i;
			sum+=n/i;
			if(i==1)
				sum-=(n/i);
			if(i<n)
				sum-=i;
        }
    }
    sum-=n;
    long long sqn=sqrt(n);
    if(sqn*sqn==n)
		sum-=sqn;cout<<abs(sum)<<endl;
    return abs(sum);
}

int main()
{
    long long a,b,ans;
    cin>>a>>b;
    for(long long i=a;i<=b;i++)
    	ans+=is_perfect(i);
    cout<<ans;
    return 0;
}

Compilation message

savrsen.cpp: In function 'long long int is_perfect(long long int)':
savrsen.cpp:24:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
     if(sqn*sqn==n)
     ^~
savrsen.cpp:25:12: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   sum-=sqn;cout<<abs(sum)<<endl;
            ^~~~
savrsen.cpp: In function 'int main()':
savrsen.cpp:34:9: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
      ans+=is_perfect(i);
      ~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Incorrect 5 ms 512 KB Output isn't correct
3 Incorrect 468 ms 1080 KB Output isn't correct
4 Incorrect 45 ms 1080 KB Output isn't correct
5 Execution timed out 3021 ms 1840 KB Time limit exceeded
6 Execution timed out 3033 ms 2988 KB Time limit exceeded
7 Execution timed out 3040 ms 2988 KB Time limit exceeded
8 Execution timed out 3025 ms 3224 KB Time limit exceeded