1011 Kindergarten Physics
题目链接http://acm.hdu.edu.cn/showproblem.php?pid=6812
题意:输出t时间后两质点的距离
思路:物理菜鸡推了好久的公式才a下,看了题解说质点移动的距离远小于 10e-6(所容许的误差值), 所以对于任意数据范围内的输入,都直接输出 d 即可。
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
typedef long long ll;
using namespace std;
char a[100005];
set f;
const double G = 6.67430e-11;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
int T; cin >> T;
while(T--)
{
int a,b,d,t; cin >> a >> b >> d >> t;
double ans = (double)sqrt(d * d - 2 * G * (a + b) * d);
printf("%.20lf\n",ans);
}
return 0;
}
1002 Blow up the Enemy
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6803 题意:张三和父亲玩游戏,彼此最开始都有100滴血,每人能从多种武器中选一种给对方造成伤害A并在时间D后才能再次攻击,每个人选择武器的概率相等,且如果同时死亡(HP<=0),则双方都有50%的概率获胜,帮张三选择一种武器使得胜率最大化。
思路:算每个武器将HP扣完所需要花的时间,从小到大排序,最小的即为最佳情况,有几种武器将HP扣完所画的时间相等就从1减去父亲获胜的概率(因为张三选择这种武器的同时父亲也可以选择这种武器,此时父亲获胜的概率为50% * (1/n))
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <unordered_map>
typedef long long ll;
using namespace std;
int v[1005];
set<int> f;int n,a,d;
const double G = 6.67430e-11;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
int T; cin >> T;
while(T--)
{
cin >> n;
for(int i = 1; i <= n; i++)
{
cin >> a >> d;
v[i] = ((100 + a - 1) / a - 1) * d;
}
sort(v + 1,v + n + 1);
int temp = v[1];
double ans=1;
for(int i = 1; i <= n; i++)
{
if(temp == v[i])
{
double d = 1.0 / (2 * n);
ans = ans - d;
}
else break;
}
printf("%lf\n",ans);
}
return 0;
} 
京公网安备 11010502036488号