UVA 382 Perfection Solution


Solve In C:

#include<stdio.h>
int main()
{

    long long int sum=0,i,j,n;
    printf("PERFECTION OUTPUT\n");
    while(scanf("%lld",&n)!=EOF)

    {
        sum=0;
        if(n==0)
            break;
        for(j=1; j<=n/2; j++)
        {
            if(n%j==0)
                sum=sum+j;
        }

        if(sum==n)
            printf("%5lld  PERFECT\n",sum);
        else if(sum<n)
            printf("%5lld  DEFICIENT\n",n);
        else
            printf("%5lld  ABUNDANT\n",n);
    }
    printf("END OF OUTPUT\n");
}


No comments

Most View Post

Recent post

Codeforces Round 971 (Div. 4) 2009C. The Legend of Freya the Frog Solution

  Problem Link    https://codeforces.com/contest/2009/problem/C S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. h ...

Powered by Blogger.