382 - Perfection
Moderator: Board moderators
382 An easy problem!
You've done a mistake according to judges output.
in your code after printf
I think it's why you are getting wrong answer from the particular problem.
Also you'll get presentation error for
But you should print
means two spaces after right justification.
in your code after printf
not END_OF_OUTPUT!END OF OUTPUT
I think it's why you are getting wrong answer from the particular problem.
Also you'll get presentation error for
Code: Select all
printf("%5d ", number);
Code: Select all
printf("%5d ", number);
Last edited by linux on Sat Sep 16, 2006 2:27 pm, edited 1 time in total.
Solving for fun..
Oh, thank you very much!
I noticed I commit a stupid mistake. I modified my source and got AC for this problem. Thank you very much 

Why Presentation Error on 382???
I have solve it and check it that it works with correct output format.
after submitting, i get PE.
But i sure, i do it as it say in sample output format.
I am afraid on ACM!!!
after submitting, i get PE.
But i sure, i do it as it say in sample output format.
I am afraid on ACM!!!

Code: Select all
Code has removed
Last edited by Oronno on Sat Dec 23, 2006 7:11 pm, edited 1 time in total.
I like programming but i am so lazy to do it...
-
- New poster
- Posts: 7
- Joined: Mon Mar 05, 2007 9:59 am
382,wrong answer
I can't guess why the following code is getting WA. Can anyone help me out, plz... ??
Code: Select all
#include<iostream.h>
#include<iomanip.h>
#include<stdio.h>
void main()
{
long int i;
long int x,sum;
cout<<"PERFECTION OUTPUT\n";
while(cin>>x&&x)
{
sum=1;
for(i=2;i<=x/2;i++)
{
if(x%i==0)
{
sum+=i;
}
}
if(sum==x)
cout<<setw(5)<<x<<" PERFECT\n";
else if(sum<x)
cout<<setw(5)<<x<<" DEFICIENT\n";
else
cout<<setw(5)<<x<<" ABUNDANT\n";
}
cout<<"END OF OUTPUT";
}
I need help too...
I was wondering why mine is wrong...It gives me all the correct answers but gives wa when submitted.
thanks for any help.
[Edited by Jan. pls use code tags]
Code: Select all
AC Now!!
[Edited by Jan. pls use code tags]
Last edited by scott1991 on Fri Mar 07, 2008 11:21 pm, edited 1 time in total.
Last edited by scott1991 on Fri Mar 07, 2008 11:21 pm, edited 1 time in total.
I got RE on my code, why???
Code:
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader vhod = new BufferedReader(new InputStreamReader(System.in));
int[] tab = new int[100];
int k = 0;
String line = vhod.readLine();
StringTokenizer num = new StringTokenizer(line, " ");
while (true) {
int a = Integer.parseInt(num.nextToken());
if (a == 0) break;
tab[k++] = a;
}
int[] rez = solve(tab);
System.out.println();
System.out.println("PERFECTION OUTPUT");
for (int i = 0; i < k; i++) {
int d = (Integer.toString(tab)).length();
if (d == 1) System.out.print(" ");
if (d == 2) System.out.print(" ");
if (d == 3) System.out.print(" ");
if (d == 4) System.out.print(" ");
System.out.print(tab + " ");
if (rez == 0) System.out.println("PERFECT");
if (rez == -1) System.out.println("DEFICIENT");
if (rez == 1) System.out.println("ABUNDANT");
}
System.out.println("END OF OUTPUT");
}
public static int[] solve(int[] tab) {
int n = tab.length;
int[] rez = new int[n];
for (int i = 0; i < n; i++) {
int d = sum(tab);
if (d < tab) rez = -1;
if (d > tab) rez = 1;
}
return rez;
}
public static int sum(int a) {
int v = 1;
for (int i = 2; i < a; i++) {
if (a%i == 0) v += i;
}
return v;
}
}
Code:
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader vhod = new BufferedReader(new InputStreamReader(System.in));
int[] tab = new int[100];
int k = 0;
String line = vhod.readLine();
StringTokenizer num = new StringTokenizer(line, " ");
while (true) {
int a = Integer.parseInt(num.nextToken());
if (a == 0) break;
tab[k++] = a;
}
int[] rez = solve(tab);
System.out.println();
System.out.println("PERFECTION OUTPUT");
for (int i = 0; i < k; i++) {
int d = (Integer.toString(tab)).length();
if (d == 1) System.out.print(" ");
if (d == 2) System.out.print(" ");
if (d == 3) System.out.print(" ");
if (d == 4) System.out.print(" ");
System.out.print(tab + " ");
if (rez == 0) System.out.println("PERFECT");
if (rez == -1) System.out.println("DEFICIENT");
if (rez == 1) System.out.println("ABUNDANT");
}
System.out.println("END OF OUTPUT");
}
public static int[] solve(int[] tab) {
int n = tab.length;
int[] rez = new int[n];
for (int i = 0; i < n; i++) {
int d = sum(tab);
if (d < tab) rez = -1;
if (d > tab) rez = 1;
}
return rez;
}
public static int sum(int a) {
int v = 1;
for (int i = 2; i < a; i++) {
if (a%i == 0) v += i;
}
return v;
}
}
Why i got RE..
Some one please help me I got RE.....
Code: Select all
Removed
[code]
Last edited by Obaida on Tue Mar 04, 2008 9:08 am, edited 1 time in total.
try_try_try_try_&&&_try@try.com
This may be the address of success.
This may be the address of success.
-
- New poster
- Posts: 10
- Joined: Mon Feb 25, 2008 8:22 pm
- Location: Dhaka, Bangladesh.