The following program is my ACcepted code for UVA-10038 .
It's a for everybody to learn and discuss.
If there is any mistake or comment, please let me know. :D
此乃UVA 10038 的AC code!
一個簡單的高中物理題
讓我們回想一下這個方程式: V = V0 + a * t
我把 2 倍時間的速度稱為 "V2"
此V2 = V0 + 2 * a * t
而經過 2 倍時間的位移 = (V2 + V0) * 2 * t / 2
= (2 * V0 + 2 * a * t ) * t = 2 * (V0 + a * t) * t = 2 * V * t !
It's a simple High School Physics.
Let's remind this equation: V = V0 + a * t .
I call the V in twice of that time "V2".
This V2 = V0 + 2 * a * t .
and the displacement be in twice of that time = (V2 + V0) * 2 * t / 2
= (2 * V0 + 2 * a * t ) * t = 2 * (V0 + a * t) * t = 2 * V * t !
//This program is for UVA 10071 Back to High School Physics
//題目來源 Problem link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=12&page=show_problem&problem=1012
#include<stdio.h>
#include<stdlib.h>
int main()
{
int t, v;
while(scanf("%d %d", &v, &t) != EOF)
{
//the displacement can be negative!
printf("%d\n", 2 * t * v);
}
return 0;
}
Please feel free to use it after adding this blog as an reference. (http://autekroy.blogspot.tw) If there is any mistake or comment, please let me know. :D
歡迎使用與分享任何內容,但請記得標示此部落格為出處。(http://autekroy.blogspot.tw/) 如果有發現任何的錯誤與建議請留言或跟我連絡。 : )
It's a for everybody to learn and discuss.
If there is any mistake or comment, please let me know. :D
此乃UVA 10038 的AC code!
歡迎一同討論學習,如有錯誤與任何建議請留言 : )
一個簡單的高中物理題
讓我們回想一下這個方程式: V = V0 + a * t
我把 2 倍時間的速度稱為 "V2"
此V2 = V0 + 2 * a * t
而經過 2 倍時間的位移 = (V2 + V0) * 2 * t / 2
= (2 * V0 + 2 * a * t ) * t = 2 * (V0 + a * t) * t = 2 * V * t !
It's a simple High School Physics.
Let's remind this equation: V = V0 + a * t .
I call the V in twice of that time "V2".
This V2 = V0 + 2 * a * t .
and the displacement be in twice of that time = (V2 + V0) * 2 * t / 2
= (2 * V0 + 2 * a * t ) * t = 2 * (V0 + a * t) * t = 2 * V * t !
//This program is for UVA 10071 Back to High School Physics
//題目來源 Problem link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=12&page=show_problem&problem=1012
#include<stdio.h>
#include<stdlib.h>
int main()
{
int t, v;
while(scanf("%d %d", &v, &t) != EOF)
{
//the displacement can be negative!
printf("%d\n", 2 * t * v);
}
return 0;
}
Please feel free to use it after adding this blog as an reference. (http://autekroy.blogspot.tw) If there is any mistake or comment, please let me know. :D
歡迎使用與分享任何內容,但請記得標示此部落格為出處。(http://autekroy.blogspot.tw/) 如果有發現任何的錯誤與建議請留言或跟我連絡。 : )
沒有留言:
張貼留言
請留下您的任何想法或建議!
Please leave any thought or comment!