It's Really Strange ... Then So much my code will like this hiks ... Can you explain what's going on ?Ghust_omega wrote:Hi !! jhonny_yang i summit your code like you posted here and gives AC try to summit the source code on-line
Hope it Helps
Keep posting !!
443 - Humble Numbers
Moderator: Board moderators
-
- New poster
- Posts: 22
- Joined: Fri Jan 17, 2003 8:24 am
-
- Experienced poster
- Posts: 115
- Joined: Tue Apr 06, 2004 7:04 pm
- Location: Venezuela
Hi !! jhonny_yang I Submit your code and get AC the problem its ok, I think that if you submit the code by mail maybe there are problems, try to submit http://acm.uva.es/problemset/submit.php its better, I'm sure that your code its ok
-
- New poster
- Posts: 8
- Joined: Tue Oct 12, 2004 1:54 pm
- Location: Iran-Tehran
- Contact:
443 Can any body tell why WA ???
I got WA .. but I don't know why???
Please help me ... !!!
Thanks...
[cpp]
//http://acm.uva.es/p/v4/443.html
#include <iostream.h>
unsigned long int humbles[5843];
int humble;
void AddtoList(unsigned long int No)
{
int j,i=humble;
humble++;
for(;i>=1;i--)
{
if(No>humbles)
{
//Shifting
for(j=humble;j>=i+2;j--)
humbles[j]=humbles[j-1];
humbles[i+1]=No;
return ;
}
}
}
bool NotInList(unsigned long int No)
{
for(int i=1;i<=humble;i++)
if(humbles==No)
return false;
return true;
}
void GenerateHumbles()
{
unsigned long int n;
for(int i=2;i<=5842&&humbles<=30000;i++)
for(int j=i;j<=5842&&humbles[j]<=120000;j++)
{
n=humbles*humbles[j];
if(n>2000000000)break;
if(NotInList(n))
AddtoList(n);
}
}
int main()
{
int n;
humble=5;
humbles[1]=1;
humbles[2]=2;
humbles[3]=3;
humbles[4]=5;
humbles[5]=7;
GenerateHumbles();
while(cin>>n,n)
{
//The 1st humble number is 1.
if(!(n>10&&n<20))
if(n%10==1)
cout<<"The "<<n<<"st"<<" humble number is "<<humbles[n]<<".\n";
else if(n%10==2)
cout<<"The "<<n<<"nd"<<" humble number is "<<humbles[n]<<".\n";
else if(n%10==3)
cout<<"The "<<n<<"rd"<<" humble number is "<<humbles[n]<<".\n";
else
cout<<"The "<<n<<"th"<<" humble number is "<<humbles[n]<<".\n";
else
cout<<"The "<<n<<"th"<<" humble number is "<<humbles[n]<<".\n";
}
return 0;
}
[/cpp]

Please help me ... !!!
Thanks...

[cpp]
//http://acm.uva.es/p/v4/443.html
#include <iostream.h>
unsigned long int humbles[5843];
int humble;
void AddtoList(unsigned long int No)
{
int j,i=humble;
humble++;
for(;i>=1;i--)
{
if(No>humbles)
{
//Shifting
for(j=humble;j>=i+2;j--)
humbles[j]=humbles[j-1];
humbles[i+1]=No;
return ;
}
}
}
bool NotInList(unsigned long int No)
{
for(int i=1;i<=humble;i++)
if(humbles==No)
return false;
return true;
}
void GenerateHumbles()
{
unsigned long int n;
for(int i=2;i<=5842&&humbles<=30000;i++)
for(int j=i;j<=5842&&humbles[j]<=120000;j++)
{
n=humbles*humbles[j];
if(n>2000000000)break;
if(NotInList(n))
AddtoList(n);
}
}
int main()
{
int n;
humble=5;
humbles[1]=1;
humbles[2]=2;
humbles[3]=3;
humbles[4]=5;
humbles[5]=7;
GenerateHumbles();
while(cin>>n,n)
{
//The 1st humble number is 1.
if(!(n>10&&n<20))
if(n%10==1)
cout<<"The "<<n<<"st"<<" humble number is "<<humbles[n]<<".\n";
else if(n%10==2)
cout<<"The "<<n<<"nd"<<" humble number is "<<humbles[n]<<".\n";
else if(n%10==3)
cout<<"The "<<n<<"rd"<<" humble number is "<<humbles[n]<<".\n";
else
cout<<"The "<<n<<"th"<<" humble number is "<<humbles[n]<<".\n";
else
cout<<"The "<<n<<"th"<<" humble number is "<<humbles[n]<<".\n";
}
return 0;
}
[/cpp]
-
- New poster
- Posts: 8
- Joined: Tue Oct 12, 2004 1:54 pm
- Location: Iran-Tehran
- Contact:
Thanks
Thank you...I got AC ! 

443 Humble Numbers WA
[Deleted]
Last edited by willy on Wed Nov 17, 2004 5:33 am, edited 1 time in total.
-
- New poster
- Posts: 31
- Joined: Sat Apr 01, 2006 6:24 am
- Contact:
443 WA i dont know why. smbd plz help
I am getting WA in this problem although i have done everything rite.
All the suffixes are correct and the values for different inputs is also correct.
But I dont know why its giving WA.
Plz help me.
All the suffixes are correct and the values for different inputs is also correct.
But I dont know why its giving WA.
Plz help me.
Last edited by Ankur Jaiswal on Sun May 07, 2006 8:51 pm, edited 1 time in total.
Try this input:
Your output:
My AC program output:
Good luck... 
Code: Select all
4121
0
Code: Select all
The 4121st humble number is 268738560.
Code: Select all
The 4121st humble number is 268435456.

-
- New poster
- Posts: 31
- Joined: Sat Apr 01, 2006 6:24 am
- Contact:
I'm not sure how it works in C++, but in Java some of those would overflow - it would multiply two ints and then cast them to a 64-bit (long long in your case)
I guess you check it here:
but overflow doesn't have to give you a negative integer (I think) and it looks wrong for some reason 
Maybe that's a problem?
I guess you check it here:
Code: Select all
if(pro>2000000000||pro<0) break;

Maybe that's a problem?
-
- New poster
- Posts: 31
- Joined: Sat Apr 01, 2006 6:24 am
- Contact:
that means if i change the condition to (pro<(long long)2000000000 && pro<(long long)0)
then wud it be ok?
... neways i think that this cud have been the problem bcoz i changed my variables from int to long long and now the program gives correct output.
i havent submitted it yet but now it might be accepted.
then wud it be ok?
... neways i think that this cud have been the problem bcoz i changed my variables from int to long long and now the program gives correct output.
i havent submitted it yet but now it might be accepted.