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:

Post by kolpobilashi » Fri Aug 25, 2006 10:49 am

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

Post by srabon » Tue Aug 29, 2006 9:20 am

Sanjana apu thanks a lot . I got ACC. I think you are so brilliant. :D

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

160 - Factors and Factorials

Post by nafi1212 » Sun Sep 03, 2006 10:17 am

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

Post by tan_Yui » Sun Sep 03, 2006 5:33 pm

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

Best regards.

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

Post by nafi1212 » Sun Sep 03, 2006 11:06 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

Post by john_locke » Mon Oct 16, 2006 9:49 pm

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

Post by CrazyTerabyte » Sat Nov 04, 2006 7:41 pm

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

Post by helloneo » Sat Nov 04, 2006 8:31 pm

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

Post by CrazyTerabyte » Sat Nov 04, 2006 8:39 pm

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

Post by nafi1212 » Sun Nov 05, 2006 9:05 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:

Post by john_locke » Fri Nov 10, 2006 3:46 pm

Thanx nafi
got ACC :D after 30 submission

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

Post by albet_januar » Fri Nov 24, 2006 6:17 pm

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.

User avatar
rio
A great helper
Posts: 385
Joined: Thu Sep 21, 2006 5:01 pm
Location: Kyoto, Japan

Post by rio » Fri Nov 24, 2006 7:15 pm

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:

Post by albet_januar » Sat Nov 25, 2006 8:36 pm

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

Post by tan_Yui » Sat Nov 25, 2006 11:37 pm

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.

Post Reply

Return to “Volume 1 (100-199)”