160 - Factors and Factorials

All about problems in Volume 1. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

kolpobilashi
Learning poster
Posts: 54
Joined: Mon Jan 02, 2006 3:06 am
Location: Dhaka,Bangladesh
Contact:
check your code for input greater than 52. your output format doesn't match with sample output.
change :

Code: Select all

``if(k>15) printf("\n "); ``
to:

Code: Select all

``if(k>15) printf("\n      "); ``
and also you forget to check another thing.
change:

Code: Select all

``for(i=0;a[i]<=n;i++) ``
to:

Code: Select all

``for(i=0;a[i]<=n&&i<25;i++) ``
best regards.
Sanjana

srabon
New poster
Posts: 4
Joined: Thu Aug 10, 2006 3:27 pm
Sanjana apu thanks a lot . I got ACC. I think you are so brilliant.

nafi1212
New poster
Posts: 5
Joined: Sat Sep 02, 2006 10:33 pm

160 - Factors and Factorials

I get WA for 160.

#include <vector>
#include <stdio.h>

#include <list>
using namespace std;
int primes[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};

int p160(int x, int i, vector<int>::iterator counter)
{
if((x%primes)==0){
counter++;
if((x/primes)!=1)
p160(x/primes,i,counter);
else
return 1;
}else{
p160(x,i+1, counter);
}
return 1;
}
int p160(int x)
{
vector<int>counter(25,0);
for(int i=2;i<=x;i++)
p160(i,0, counter.begin());
while(!counter.back()){
counter.pop_back();
};
printf("%3d! =", x);
for(unsigned int i=0;i<counter.size();i++){

printf("%3d", counter);
if(i==14){
printf("\n ");
}
}
printf("\n");
return 1;
}
int main()
{
vector<int>nums;
for(;;){
int tmp;
fscanf(stdin, "%d", &tmp);
if(!tmp)
break;
if(tmp<2||tmp>100)
continue;
nums.push_back(tmp);

}
for(unsigned int i=0;i<nums.size();i++){
p160(nums);
}
return 1;

}

tan_Yui
Experienced poster
Posts: 155
Joined: Sat Jul 10, 2004 12:41 am

Re: 160 WA?? PLZ

Read the problem description, then check again the output format
After fixed it, you'll get Accepted.

Best regards.

nafi1212
New poster
Posts: 5
Joined: Sat Sep 02, 2006 10:33 pm
After editing output, GOT AAC, many thanks tan_yui

john_locke
New poster
Posts: 13
Joined: Sat Oct 07, 2006 6:42 pm
Contact:

160-wa

here is my code cant find the error values are correct, format is correct but still get WA.....
so plz help me
CODE IS DELETED

thanx in advance[/quote]
Last edited by john_locke on Fri Nov 10, 2006 3:44 pm, edited 1 time in total.

CrazyTerabyte
New poster
Posts: 25
Joined: Fri Jul 16, 2004 3:19 am
Location: Brazil
Contact:

160 - WA

Instead of starting a new thread, I will post in this one.

Here is my code: (deleted)

I've tested it for all numbers from 2 to 100. The output looks correct to me. But I still get wrong answer. Can someone help me?
Last edited by CrazyTerabyte on Sat Nov 04, 2006 8:45 pm, edited 1 time in total.

helloneo
Guru
Posts: 516
Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea

Re: 160 - WA

CrazyTerabyte wrote:Instead of starting a new thread, I will post in this one.

Here is my code:
I've tested it for all numbers from 2 to 100. The output looks correct to me. But I still get wrong answer. Can someone help me?
Your ouput is wrong..
Try this input

Code: Select all

``````1
2
3
4
5
100
0
``````
My output

Code: Select all

``````  1! =  0
2! =  1
3! =  1  1
4! =  3  1
5! =  3  1  1
100! = 97 48 24 16  9  7  5  5  4  3  3  2  2  2  2
1  1  1  1  1  1  1  1  1  1
``````
Your output

Code: Select all

``````  1! =  0
2! =  0
3! =  1
4! =  1
5! =  1  1
100! = 48 24 16  9  7  5  5  4  3  3  2  2  2  2  1
1  1  1  1  1  1  1  1  1
``````
Last edited by helloneo on Sun Nov 05, 2006 4:31 am, edited 1 time in total.

CrazyTerabyte
New poster
Posts: 25
Joined: Fri Jul 16, 2004 3:19 am
Location: Brazil
Contact:

Re: 160 - WA

helloneo wrote:Your ouput is wrong..
Try this input
I got exactly the same output as yours.

hum... After some time finally I found I was not initializing ONE position in my array. After fixed that, I got accepted.

Thanks.

nafi1212
New poster
Posts: 5
Joined: Sat Sep 02, 2006 10:33 pm
Ur programme doesn't output the result in correct format.
Example

Code: Select all

``63``
ur prog's output is:

Code: Select all

``````
63! = 57 30 14 10  5  4  3  3  2  2  2  1  1  1  1
1  1  1
``````
But It should be:

Code: Select all

`````` 63! = 57 30 14 10  5  4  3  3  2  2  2  1  1  1  1
1   1   1
``````
[/list]

john_locke
New poster
Posts: 13
Joined: Sat Oct 07, 2006 6:42 pm
Contact:
Thanx nafi
got ACC after 30 submission

albet_januar
New poster
Posts: 35
Joined: Wed Apr 12, 2006 6:03 pm
Location: jakarta, indonesia
Contact:

Code: Select all

``````deleted after Ac.. at last, i know my mistake.. hikx
``````
thx
Last edited by albet_januar on Mon Nov 27, 2006 7:31 pm, edited 2 times in total.

rio
A great helper
Posts: 385
Joined: Thu Sep 21, 2006 5:01 pm
Location: Kyoto, Japan
I run your code with my PC, and it even doesn't pass the sample.
Try debug at least you pass the sample.

albet_januar
New poster
Posts: 35
Joined: Wed Apr 12, 2006 6:03 pm
Location: jakarta, indonesia
Contact:
i change my code.. but still it WA.. dun know why..

tan_Yui
Experienced poster
Posts: 155
Joined: Sat Jul 10, 2004 12:41 am

Code: Select all

``````         if(hasil[i])
{
else printf("%3lld", hasil[i]);
counter++;
}``````
In this part, 'else' is illegal then return compile error.
By the way, there are already many many threads about problem 160.
http://online-judge.uva.es/board/search.php
Did you check all posts from here?
There are a lot of test data, so you can use it for debugging.

Best regards.