10071 - Back to High School Physics

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

Moderator: Board moderators

keceman
New poster
Posts: 7
Joined: Wed Mar 03, 2004 6:51 am

Post by keceman » Wed Mar 03, 2004 12:20 pm

hm... actually i'm still don't understand what does
while (scanf... == 2 ) mean.. .hehehe

keceman
New poster
Posts: 7
Joined: Wed Mar 03, 2004 6:51 am

Post by keceman » Wed Mar 03, 2004 12:38 pm

ops... i finally finished it, i've changed the code into

while ((cin >> v >> t) != 0)
{
blablabla
}

although i still dont get what does the while statement mean.. heuheuheuhue

eg_frx
New poster
Posts: 21
Joined: Sat Oct 02, 2004 2:17 pm

Post by eg_frx » Tue Oct 26, 2004 3:50 pm

keceman wrote:ops... i finally finished it, i've changed the code into

while ((cin >> v >> t) != 0)
{
blablabla
}

although i still dont get what does the while statement mean.. heuheuheuhue
I would simply do

Code: Select all

while(cin >> v >> t){
...
}
Some explainations here:
When cin fails to send values to v (or t), it returns an empty stream.

plen
New poster
Posts: 1
Joined: Fri Dec 31, 2004 9:15 am

Post by plen » Fri Dec 31, 2004 9:22 am

yes i do agree that the word constant is important.

i initially thought that this was a calculus problem and that integration is needed to find the distance-time function...

:(

Vala
New poster
Posts: 3
Joined: Sun Jan 16, 2005 4:26 am

10071 Wa !?

Post by Vala » Sun Jan 16, 2005 4:30 am

Code: Select all

#include <stdio.h>


int main(int argc, char **argv)
{
	int v1,t1,v2,t2;
	scanf("%d %d",&v1,&t1);
	printf("%d\n",2*v1*t1);
	scanf("%d %d",&v2,&t2);
	printf("%d",2*v2*t2);
	
	return 0;
}
Why's that wrong ?
I don't believe it....
It specifies the 2 inputs are integers,
and so it is......
Why..................................................
(echo)

..
A great helper
Posts: 454
Joined: Thu Oct 18, 2001 2:00 am
Location: Hong Kong

Post by .. » Sun Jan 16, 2005 6:52 am

Hi,

I come from the same University and department as you but I am little bit older. Go back to the course homepage to read the example of 10055(AC code, input and output) provided by your tutor. You will know why you WA.
My signature:
  • Please make discussion about the algorithm BRFORE posting source code.
    We can learn much more in discussion than reading source code.
  • I HATE testing account.
  • Don't send me source code for debug.

User avatar
shamim
A great helper
Posts: 498
Joined: Mon Dec 30, 2002 10:10 am
Location: Bozeman, Montana, USA

Post by shamim » Sun Jan 16, 2005 2:04 pm

Vala, the problem is you are assuming that there will be exactly two test case, in reality there will be many more case and you should read until EOF.

Code: Select all

while ( scanf("%d %d",&v1,&t1) == 2 )
{
printf("%d\n",2*v1*t1);
}

..
A great helper
Posts: 454
Joined: Thu Oct 18, 2001 2:00 am
Location: Hong Kong

Post by .. » Sun Jan 16, 2005 3:05 pm

I should suggest other people not reply this thread anymore in my last reply, but I forget.
As Vala is doing his homework, and him tutor is already providing enough and easy-reading info to him, he should get the answer himself.
My signature:
  • Please make discussion about the algorithm BRFORE posting source code.
    We can learn much more in discussion than reading source code.
  • I HATE testing account.
  • Don't send me source code for debug.

PerHagen
New poster
Posts: 23
Joined: Thu Oct 14, 2004 1:45 am
Location: lima

10071

Post by PerHagen » Wed Jan 19, 2005 11:27 pm

???
my code is
#include <stdio.h>
#include <iostream.h>
void main ()
{int a,b ;
while(scanf("%d %d", &a ,&b)==2)
{
if (a<0) a=-a;
cout << 2*a*b<<endl;
}
}
but is w.a. i don't understand
bye
hello !

growup
New poster
Posts: 2
Joined: Thu Jan 20, 2005 10:31 pm

Hello

Post by growup » Thu Jan 20, 2005 10:38 pm

Hi, Q10071 asks for outputs of "displacement", instead of "distance".
The former is vector(signed), the latter is scalar(unsigned).

:)

PerHagen
New poster
Posts: 23
Joined: Thu Oct 14, 2004 1:45 am
Location: lima

I/O

Post by PerHagen » Fri Jan 21, 2005 3:10 am

and what I/O for is problem???
hello !

PerHagen
New poster
Posts: 23
Joined: Thu Oct 14, 2004 1:45 am
Location: lima

Post by PerHagen » Fri Jan 21, 2005 3:14 am

ThX my error was::: a=-a !!!

bye
hello !

User avatar
tmdrbs6584
Learning poster
Posts: 98
Joined: Sat Jan 21, 2006 12:45 pm
Location: Busan,Corea(Republic of)

Post by tmdrbs6584 » Tue Mar 14, 2006 10:49 am

1 2 -> 4
3 4 -> 24
5 6 -> 60
7 8 -> 112
9 0 -> 0

User avatar
tmdrbs6584
Learning poster
Posts: 98
Joined: Sat Jan 21, 2006 12:45 pm
Location: Busan,Corea(Republic of)

Post by tmdrbs6584 » Tue Mar 14, 2006 10:49 am

you must use long long inteager

User avatar
tmdrbs6584
Learning poster
Posts: 98
Joined: Sat Jan 21, 2006 12:45 pm
Location: Busan,Corea(Republic of)

Post by tmdrbs6584 » Tue Mar 14, 2006 10:50 am

long long int...

Post Reply

Return to “Volume 100 (10000-10099)”