Page 5 of 7

Yes...

Posted: Tue Mar 04, 2008 9:06 am
by Obaida
So many thank's I got Accepted... :)

Re: 382 WA

Posted: Fri May 23, 2008 11:28 pm
by WAandAC
I doubt the judge's test case doesn't have 0 at end. Can anyone confirm this?

Thanks

Posted: Sun Jun 15, 2008 1:36 pm
by zyxw
Many thanks to CSEDU_1323 8)
I was getting WA bcoz i was printing "1" as perfect :oops:

Re: 382 getting wa

Posted: Thu Jul 23, 2009 10:24 pm
by mhn
the code seems fine to me..but getting wa..

#include<stdio.h>

int main(){


int a,b,i,sum;


printf("PERFECTION OUTPUT\n");
while(scanf("%d",&a)==1){

sum=0;


if(a==0) {printf("END OF OUTPUT");break;}

else{

for(i=1;i<=a/2;i++){

b=a%i;
if(b==0) sum=sum+i;

}
if(sum==a) printf("%d PERFECT\n",a);
else if(sum<a) printf("%d DEFICIENT\n",a);
else if(sum>a) printf("%d ABUNDANT\n",a);

}


}



return 0;

}

Re: 382 WA

Posted: Thu Jul 23, 2009 10:37 pm
by mf
Use [code]...[/code] tags when posting any source code!

Your program improperly formats the output - see the sample output, and read again the "Output" section of problem statement.

And there should be a \n character at the end of output.

Re: 382 WA

Posted: Thu Aug 06, 2009 10:04 pm
by etameem

Code: Select all

#include <iostream>
using namespace std;

int main()
{
    int n,a,b,i,j=0,k,count=1;

   while( cin>>n)

{
    count=1;
    if(j==0)
cout<<"PERFECTION OUTPUT"<<endl;
    if(n==0)
    {
        cout<<"END OF OUTPUT"<<endl;
        break;

        }
    for(i=2;i<=n/2;i++)
        {
            if(n%i==0)
            count=count+i;
            else
            continue;


            }
if(count==n)
cout<<n<<"  PERFECT"<<endl;

else if (count>n)
cout<<n<<"  ABUNDANT"<<endl;

else
cout<<n<<"  DEFICIENT"<<endl;


j++;
}
    return 0;
    }


i am getting WA, i know there are some mistakes..but where???? how can i reduce the Space problem in the output.?

Re: 382 WA

Posted: Fri Aug 07, 2009 2:40 pm
by mf
Use printf("%5d PERFECT\n", n), et cetera.

Re: 382 WA

Posted: Wed Aug 12, 2009 10:37 am
by etameem
this is my code now...

Code: Select all

#include <iostream>
#include <cstdio>
using namespace std;

int main()
{
    int n,a,b,i,j=0,k,count=1;

   while( cin>>n)

{
    count=1;
    if(j==0)
cout<<"PERFECTION OUTPUT"<<endl;
    if(n==0)
    {
        cout<<"END OF OUTPUT"<<endl;
        break;

        }
    for(i=2;i<=n/2;i++)
        {
            if(n%i==0)
            count=count+i;
            else
            continue;


            }
if(count==n)
//cout<<n<<"  PERFECT"<<endl;
printf("%5d PERFECT\n", n);

else if (count>n)
//cout<<n<<"  ABUNDANT"<<endl;
printf("%5d ABUNDANT\n", n);

else
//cout<<n<<"  DEFICIENT"<<endl;
printf("%5d DEFICIENT\n", n);


j++;
}
    return 0;
    }



i correct that..printf("%5d DEFICIENT\n", n); but still getting a WA.
i don't see any problem there..then why still WA???

Re: 382 WA

Posted: Sun Sep 06, 2009 7:50 pm
by saiful_sust
In ur code there r two wrong thing

no one :
chang this line

Code: Select all

count = 1;
To

Code: Select all

count =0;
and

Code: Select all

for(i=2;i<=n/2;i++)
To

Code: Select all

for(i=1;i<=n/2;i++)
another thing u must have to change.......

Code: Select all

if(count==n)
//cout<<n<<"  PERFECT"<<endl;
printf("%5d PERFECT\n", n);

else if (count>n)
//cout<<n<<"  ABUNDANT"<<endl;
printf("%5d ABUNDANT\n", n);

else
//cout<<n<<"  DEFICIENT"<<endl;
printf("%5d DEFICIENT\n", n);
change it to

Code: Select all

if(count==n)
printf("%5d  PERFECT\n", n);

else if (count>n)
printf("%5d  ABUNDANT\n", n);

else
printf("%5d  DEFICIENT\n", n);

That is printf("%5d##DEFICIENT\n", n);
here # means space

And after ACC PLZ remove ur code.... :-?

Re: 382 WA

Posted: Mon Oct 12, 2009 8:57 pm
by rubelreza
viya, i m not understanding why 1 is deficient????******

Re: 382 WA

Posted: Mon Apr 05, 2010 8:18 pm
by Sadasidha08
//[c]

#include<stdio.h>




int main()
{
long int n;

long int i=0,sum;




printf("PERFECTION OUTPUT\n");


while(scanf("%ld",&n))
{



sum=0;


if(n==0)
break;

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

}
if(sum==n)
printf("%5ld PERFECT\n",n);
else if(sum<n)
printf("%5ld DEFICIENT\n",n);
else
printf("%5ld ABUDANT\n",n);
}
printf("END OF OUTPUT\n");
return 0;

}//[c]

Re: 382 WA

Posted: Thu Jul 29, 2010 8:10 pm
by shaon_cse_cu08
U r taking one input and processing that input one at a time....
But the problem is about inputting a set of input... And processing them....
The line "PERFECTION OUTPU" Will be on top of the output set.... Not Avobe ur input set....

U should slightly change ur program by taking all the input in an array... And testing each case of the array element....

Re: 382 WA

Posted: Wed Apr 13, 2011 5:13 pm
by anik.bit0104

Code: Select all

#include <iostream>
#include <stdio.h>
#include <cmath>
using namespace std;

//functions
void listOfDivisors(unsigned int givenNum);
int caseCounter=0;
unsigned int isPerfectOrAbundOrDef(unsigned int l);
string numberOfSpaces(unsigned int givenNum);

unsigned int arrayOfDivisors[20000];

int main()
{
  unsigned int givenNum;



  while (scanf("%d",&givenNum)==1)
    {
      if (givenNum==0)
        {
          cout<<"END OF OUTPUT";
          break;
        }

      listOfDivisors(givenNum);


      unsigned int result=isPerfectOrAbundOrDef(givenNum);

        if(caseCounter==0) cout<<"PERFECTION OUTPUT"<<endl;
        caseCounter++;
      if (result==0) cout<< numberOfSpaces(givenNum) << givenNum <<"  PERFECT"<<endl;
      else if (result==1) cout << numberOfSpaces(givenNum) << givenNum <<"  ABUNDANT"<<endl;
      else cout << numberOfSpaces(givenNum) <<givenNum<<"  DEFICIENT"<<endl;


      for (unsigned int j=0;j<20000 ;j++ )
        {
          arrayOfDivisors[j]=0;
        }

    }

  return 0;
}


unsigned int isPerfectOrAbundOrDef(unsigned int l)
{

  unsigned int sumOfDivisors=0;

  for (unsigned int i=0;i<20000 ;i++ )
    {
      sumOfDivisors=sumOfDivisors+arrayOfDivisors[i];
    }

  if (sumOfDivisors>l) return 1;
  else if (sumOfDivisors==l) return 0;
  else return -1;
}


void listOfDivisors(unsigned int givenNum)
{

  unsigned int i=0;

  for (unsigned int l=1; l<= int(givenNum/2);l++)
    {

      if ((givenNum%l)==0)
        {
          arrayOfDivisors[i]=l;
          i++;
        }

    }


}

string numberOfSpaces(unsigned int givenNum)
{

string numOfSpaces;

unsigned int i=ceil(log10(givenNum));

if(i==5)      numOfSpaces=numOfSpaces+"";
else if(i==4) numOfSpaces=numOfSpaces+" ";
else if(i==3) numOfSpaces=numOfSpaces+"  ";
else if(i==2) numOfSpaces=numOfSpaces+"   ";
else if(i==1) numOfSpaces=numOfSpaces+"    ";
return numOfSpaces;

}
can anyone tell me, what's the f***ing problem with this code? driving me damn crazy..

382 WA

Posted: Wed Apr 20, 2011 12:20 pm
by @mjad
why wrong answer please help me

Code: Select all

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
long i, num,sum;
int list[100];
char input[50000];

int main() {

    gets(input);
    char *p;
    printf("PERFECTION OUTPUT\n");
    p = strtok(input," ");
    while( p != NULL )
    {
        num = atol( p);
        if(num == 0)
            break;
        sum = 0;
        for( i = 1; i <= num/2; i++) {
            if( num %i == 0) {
                sum = sum + i;
            }
        }

        if(num == sum) {
            printf("%5d  PERFECT\n", num);
        }
        else if( num < sum) {
            printf("%5d  ABUNDANT\n", num);
        }
        else if( num > sum) {
            printf("%5d  DEFICIENT\n", num);
        }
        p = strtok(NULL," ");
    }
    printf("END OF OUTPUT\n");

    return 0;
    }


Why Presentation Error on 382???

Posted: Sat Jul 02, 2011 6:03 pm
by zishaniuc1745026197
Hey Please help !
Presentation error why?
#include<stdio.h>
int main()
{
long int num,i,sum;
printf("PERFECTION OUTPUT\n");
while(scanf("%ld",&num)==1)
{
if(num==0)
{
printf("END OF OUTPUT\n");
break;
}
else
{
sum=0;
for(i=1;i<num;i++)
{
if(num%i==0) sum+=i;
}
if(sum==num) printf("%5ld PERFECT\n",num);
else if(sum<num) printf("%5ld DEFICIENT\n",num);
if(sum>num) printf("%5ld ABUNDANT\n",num);
}
}
return 0;
}