Home > Back-end >  For Tom and Jerry (presumably so called)
For Tom and Jerry (presumably so called)

Time:09-18

QiQi recently fell in love with Tom and Jerry, and then do a about Tom and Jerry's dream, a dream is like that, in a infinite long straight road, chasing Jerry Tom in the beginning, Jerry from Tom n m (n & gt; 0), Tom make track for to Jerry, Tom's speed is v1m/s, Jerry, Jerry speed for v2m/s, (v1 v2, are no less than 0) Jerry have a cheating artifact, it can use the ground plate to make Tom pause 1 s after it, but after the dishes from the beginning comes once every 5 seconds (0 seconds without plate), would you please guess to Jerry, Tom?

input format:
Input number three, respectively is n, v1 and v2, respectively at the beginning of the distance of the Tom and Jerry, v1, v2 says Tom and Jerry running speed, the initial value is 100,

output format:
If Tom chased to Jerry, output "Jerry GG!" Otherwise, output "Jerry win!"

input sample:
Given a set of input here, for example:

42 68 35
79, 59, 63
The output sample:
Here is given the corresponding output, for example:

Jerry GG!
Jerry win!

CodePudding user response:

Try this program can pass the test?
# include & lt; stdio.h>
Int main ()
{
Int n, v1, v2,
While (the scanf (" % d % d % d ", & amp; N, & amp; V1, & amp; V2)==3)
{
If (5 * v1, v2) (n + 5 * & gt;=0)
Printf (" Jerry GG! \n");
Else if ((n + 6 * v2) - 5 * v1 & gt; N)
Printf (" Jerry win! \n");
}
return 0;
}

CodePudding user response:

reference 1st floor Tryagain2006 response:
try this program can pass the test?
# include & lt; stdio.h>
Int main ()
{
Int n, v1, v2,
While (the scanf (" % d % d % d ", & amp; N, & amp; V1, & amp; V2)==3)
{
If (5 * v1, v2) (n + 5 * & gt;=0)
Printf (" Jerry GG! \n");
Else if ((n + 6 * v2) - 5 * v1 & gt; N)
Printf (" Jerry win! \n");
}
return 0;
}


Although I have not run but a see your code no
From the beginning to the end, there is no time, to be decided for a second or 5 seconds to be decided?

CodePudding user response:

refer to the second floor 5250 response:
Quote: refer to 1st floor Tryagain2006 response:

Try this program can pass the test?
# include & lt; stdio.h>
Int main ()
{
Int n, v1, v2,
While (the scanf (" % d % d % d ", & amp; N, & amp; V1, & amp; V2)==3)
{
If (5 * v1, v2) (n + 5 * & gt;=0)
Printf (" Jerry GG! \n");
Else if ((n + 6 * v2) - 5 * v1 & gt; N)
Printf (" Jerry win! \n");
}
return 0;
}


Although I have not run but a see your code no
From the beginning to the end, there is no time, to be decided for a second or 5 seconds to be decided?

Mathematical model is the key, as long as the established mathematical model, you will find that this has no direct relationship between the with time,

CodePudding user response:

# include & lt; stdio.h>
Int main ()
{
Int n, v1, v2,
While (the scanf (" % d % d % d ", & amp; N, & amp; V1, & amp; V2))
{
Int t=0;//time
While (1)
{
If (v1 & lt;=v2) {//if Tom speed slower than jerry, Tom never catch jerry
Printf (" jerry win \ n ");
break;
}

If ((v1 * (t/t - 5)) & gt;=(v2 * (t + t/5) + n))//on the contrary, if Tom quickly, so Tom always catch jerry, even may be a long, long time
{
Printf (" after % d second jerry GG \ n ", t);
break;
}
The else
T++;
}
}
return 0;
}

CodePudding user response:

Establish mathematical model:
The distance of the 5 s after Tom and Jerry=5 * v1 - v2) (n + 5 * and if & gt;=0, then catch Jerry GG!
Otherwise, the 6 s, Tom and Jerry's distance=(n + 6 * v2) - 5 * v1, if & gt; N is unable to catch up

CodePudding user response:

reference Tryagain2006 reply: 3/f
Quote: refer to the second floor 5250 response:

Quote: refer to 1st floor Tryagain2006 response:

Try this program can pass the test?
# include & lt; stdio.h>
Int main ()
{
Int n, v1, v2,
While (the scanf (" % d % d % d ", & amp; N, & amp; V1, & amp; V2)==3)
{
If (5 * v1, v2) (n + 5 * & gt;=0)
Printf (" Jerry GG! \n");
Else if ((n + 6 * v2) - 5 * v1 & gt; N)
Printf (" Jerry win! \n");
}
return 0;
}


Although I have not run but a see your code no
From the beginning to the end, there is no time, to be decided for a second or 5 seconds to be decided?

Mathematical model is the key, as long as the established mathematical model, you will find that this time and there is no direct relationship,



5250 reference 4 floor response:
# include & lt; stdio.h>
Int main ()
{
Int n, v1, v2,
While (the scanf (" % d % d % d ", & amp; N, & amp; V1, & amp; V2))
{
Int t=0;//time
While (1)
{
If (v1 & lt;=v2) {//if Tom speed slower than jerry, Tom never catch jerry
Printf (" jerry win \ n ");
break;
}

If ((v1 * (t/t - 5)) & gt;=(v2 * (t + t/5) + n))//on the contrary, if Tom quickly, so Tom always catch jerry, even may be a long, long time
{
Printf (" after % d second jerry GG \ n ", t);
break;
}
The else
T++;
}
}
return 0;
}


Change the if ((v1 * (t - t/5) & gt; * t + n=(v2)

CodePudding user response:

reference 5 floor Tryagain2006 reply:
to establish mathematical model:
The distance of the 5 s after Tom and Jerry=5 * v1 - v2) (n + 5 * and if & gt;=0, then catch Jerry GG!
Otherwise, the 6 s, Tom and Jerry's distance=(n + 6 * v2) - 5 * v1, if & gt; N cannot catch up with the
why is & gt; n? Mouse - the cat should not greater than 0
  • Related