本文主要是介绍UVA10071(重温高中物理公式),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
Time Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %llu
题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=18809
DescriptionA particle has initial velocity and constant acceleration. If its velocity after certain time is v then what will its displacement be in twice of that time?
Input
The input will contain two integers in each line. Each line makes one set of input. These two integers denote the value of v (-100 <= v <= 100) and t(0<=t<= 200) ( t means at the time the particle gains that velocity)
Output
For each line of input print a single integer in one line denoting the displacement in double of that time.
Sample Input
0 0
5 12
Sample Output
0
120
解题思路:
题目大意就是给你一个路程中间点的速度和到达该点的时间,问经过2倍的时间,从最出发点发生的总位移是多少。
裸高中物理公式·····首先用时间中点的平均速度 = 该过程的平均速度 = v = (v0 + v) / 2,得出v0 = v 。用平均速度乘时间的位移公式x1 = (v0 + v) / 2,求出第一段位移x1。接下来用v^2 - v0 ^ 2 = a *a *x,求出加速度a。最后用连续相等时间间隔位移差公式x2 - x1 = a * t ^ 2,求出对应的第二段位移x2。输出x1 + x2即可。
完整代码:
#include <functional>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <cstring>
#include <climits>
#include <cassert>
#include <complex>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;#pragma comment(linker, "/STACK:102400000,102400000")typedef long long LL;
typedef double DB;
typedef unsigned uint;
typedef unsigned long long uLL;/** Constant List .. **/ //{const int MOD = int(1e9)+7;
const int INF = 0x3f3f3f3f;
const LL INFF = 0x3f3f3f3f3f3f3f3fLL;
const DB EPS = 1e-9;
const DB OO = 1e20;
const DB PI = acos(-1.0); //M_PI;int main()
{#ifdef DoubleQfreopen("in.txt","r",stdin);#endifint a , b;while(cin >> a>> b){int v0 = a;int x1 =( (a + v0) * b ) / 2;int aa = (a * a - v0 * v0) / (2 * x1);int x2 = aa * b * b + x1;cout << x1 + x2 << endl;}
}
这篇关于UVA10071(重温高中物理公式)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!