10499 - The Land of Justice

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

Moderator: Board moderators

_.B._
Experienced poster
Posts: 160
Joined: Sat Feb 07, 2004 7:50 pm
Location: Venezuela
Contact:

Indeed.

Post by _.B._ »

Indeed!, got accepted by these posts :D
Keep posting!.
_.
zero_cool
New poster
Posts: 27
Joined: Fri Sep 02, 2005 6:33 am

10499 WA need help

Post by zero_cool »

I don't know what's wrong with my code. Could anyone give me a critical input???

_____________________________________________________________
code removed
_____________________________________________________________
Last edited by zero_cool on Sat Jan 21, 2006 5:31 pm, edited 1 time in total.
bijon
New poster
Posts: 18
Joined: Thu Jan 06, 2005 2:12 pm

Post by bijon »

i don't understand this

Code: Select all

cout << div; 
switch (rem) { 
case 0: cout << "00"; 
break; 
case 1: cout << "25"; 
break; 
case 2: cout << "50"; 
break; 
case 3: cout << "75"; 
break; 
} 
why you print div then the other value that is in switch-case.

did your output matches with the sample?
for input
2
your code gives
050%

am i right ?[/code]
zero_cool
New poster
Posts: 27
Joined: Fri Sep 02, 2005 6:33 am

Post by zero_cool »

I use div because I've already use double as a data type and i got compile error because of error in output manipulation (i think). And then I changed my code to that. I use long and divide it by 4. and add '25' or '50' or '75' or '00' depend on the remainder. my compiler can't use long long data type so I use that code.

Finally I got accepted. Thanks. By the way, how to manipulate output? I used #include <iomanip> and setprecision, fixed, showpoint but it said compile error.
omniscientone
New poster
Posts: 2
Joined: Wed Nov 16, 2005 7:38 pm

10499 - Land of Justice WA Help please

Post by omniscientone »

Hi,

I used the following code to generate my output, and can't figure out whats wrong with and why its giving a WA. Any help on why its happening would be appreciated. Any sample input where its wrong would be lovely. Thanks

Code: Select all

#include <iostream>

using namespace std;

int main()
{
 int n;
 while(1)
 {
  cin >> n;
  if(n < 0)
   break;

  long prof1 = 0;
  if(n > 1)
   prof1 += n * 25; 

  cout << prof1 << "%" << endl;
 }

 //getch();
}
Thanks guys.
omniscientone
New poster
Posts: 2
Joined: Wed Nov 16, 2005 7:38 pm

Post by omniscientone »

Forget it, found my mistake, needed to use long long instead of long or int.

Thanks anyways
Steven Luck
New poster
Posts: 13
Joined: Sat Dec 02, 2006 7:51 am
Location: Indonesia
Contact:

Post by Steven Luck »

I've made it the same, I guess, but still get WA with this code:

Code: Select all


Removed after AC

Can anyone tell me where the mistake is?
Thanx.
Last edited by Steven Luck on Sat Dec 23, 2006 5:50 am, edited 2 times in total.
"The Only Thing For The Triumph of Evil is For a Good Man to Do Nothing"
Debashis Maitra
Learning poster
Posts: 62
Joined: Sun Jul 09, 2006 8:31 am
Location: University of Dhaka
Contact:

Post by Debashis Maitra »

use long long

and i think

Code: Select all

if(N!=1)printf("%lld%\n",25*N);
is enough to solve this problem
Akash chhoyar swopno
Dream to touch the sky
Steven Luck
New poster
Posts: 13
Joined: Sat Dec 02, 2006 7:51 am
Location: Indonesia
Contact:

Post by Steven Luck »

Ok, thanx, but if 0 < N < 2^31, isn't it enough if I use long int?
"The Only Thing For The Triumph of Evil is For a Good Man to Do Nothing"
Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan »

Suppose N = 2147483647 (2^31-1). The output should be 53687091175 which cant be fit into a normal 32-bit int. So, you can use long long.
Ami ekhono shopno dekhi...
HomePage
Steven Luck
New poster
Posts: 13
Joined: Sat Dec 02, 2006 7:51 am
Location: Indonesia
Contact:

Post by Steven Luck »

Ok, thanx. I didn't notice the range of the output.. :)
"The Only Thing For The Triumph of Evil is For a Good Man to Do Nothing"
Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am
Location: (BUBT) Dhaka,Bagladesh.

Can we do it...?

Post by Obaida »

Thanks... every one
I also got Acc..both time by 25*n...& little joys formula
try_try_try_try_&&&_try@try.com
This may be the address of success.
noor_aub
New poster
Posts: 26
Joined: Sat Aug 22, 2009 12:16 pm

10499 The Land of Justice getting W/S

Post by noor_aub »

I have followed the NSU web help. But I am getting w/a.
I am not getting where I am wrong.
Last edited by noor_aub on Fri Sep 18, 2009 1:31 am, edited 1 time in total.
saiful_sust
Learning poster
Posts: 97
Joined: Fri Aug 22, 2008 10:18 pm
Location: CSE.SUST.SYLHET

Re: 10499 The Land of Justice getting W/S

Post by saiful_sust »

Hi noor_aub
u have two problem
one change int to long

two change this portion of ur code

Code: Select all

if(n==1)
        cout<<"0 %"<<endl;
else
	cout<<n*25<<" %"<<endl;
To

Code: Select all

p = 25*n;
if(n==1)
			cout<<"0%"<<endl;
		else
			cout<<p<<"%"<<endl;
Then PLZ remove ur code....... :D :D :D
noor_aub
New poster
Posts: 26
Joined: Sat Aug 22, 2009 12:16 pm

Re: 10499 The Land of Justice getting W/S

Post by noor_aub »

Thanks for your suggestion.
Last edited by noor_aub on Fri Sep 18, 2009 1:33 am, edited 1 time in total.
Post Reply

Return to “Volume 104 (10400-10499)”