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 925 (Div. 3) 1931D. Divisible Pairs Solution

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

Powered by Blogger.