## 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
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
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
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
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 !?

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
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.

shamim
A great helper
Posts: 498
Joined: Mon Dec 30, 2002 10:10 am
Location: Bozeman, Montana, USA
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
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

???
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

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

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

PerHagen
New poster
Posts: 23
Joined: Thu Oct 14, 2004 1:45 am
Location: lima
ThX my error was::: a=-a !!!

bye
hello !

tmdrbs6584
Learning poster
Posts: 98
Joined: Sat Jan 21, 2006 12:45 pm
Location: Busan,Corea(Republic of)
1 2 -> 4
3 4 -> 24
5 6 -> 60
7 8 -> 112
9 0 -> 0

tmdrbs6584
Learning poster
Posts: 98
Joined: Sat Jan 21, 2006 12:45 pm
Location: Busan,Corea(Republic of)
you must use long long inteager

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