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:
Post
by _.B._ » Fri Apr 30, 2004 10:40 pm
Indeed!, got accepted by these posts
Keep posting!.
_.
zero_cool
New poster
Posts: 27 Joined: Fri Sep 02, 2005 6:33 am
Post
by zero_cool » Sun Oct 02, 2005 7:26 am
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 » Tue Oct 04, 2005 5:46 pm
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 » Tue Oct 04, 2005 10:42 pm
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
Post
by omniscientone » Wed Nov 16, 2005 7:42 pm
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 » Wed Nov 16, 2005 7:46 pm
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 » Mon Dec 11, 2006 8:48 am
I've made it the same, I guess, but still get WA with this code:
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 » Fri Dec 22, 2006 8:07 pm
use long long
and i think
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 » Sat Dec 23, 2006 4:47 am
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 » Sat Dec 23, 2006 5:05 am
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.
Steven Luck
New poster
Posts: 13 Joined: Sat Dec 02, 2006 7:51 am
Location: Indonesia
Contact:
Post
by Steven Luck » Sat Dec 23, 2006 5:38 am
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.
Post
by Obaida » Mon Mar 24, 2008 11:44 am
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
Post
by noor_aub » Sat Aug 29, 2009 7:52 am
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
Post
by saiful_sust » Wed Sep 16, 2009 1:05 am
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.......
noor_aub
New poster
Posts: 26 Joined: Sat Aug 22, 2009 12:16 pm
Post
by noor_aub » Wed Sep 16, 2009 12:45 pm
Thanks for your suggestion.
Last edited by
noor_aub on Fri Sep 18, 2009 1:33 am, edited 1 time in total.