A题列个方程就解决了。
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
#define pi 3.14159265359
inline void file()
{
freopen("D:\\go.txt", "r", stdin);
freopen("D:\\leave.txt", "w", stdout);
}
int main()
{
//file();
//ios::sync_with_stdio(false);
double d, h, v, e;
scanf("%lf%lf%lf%lf", &d, &h, &v, &e);
if ((pi * (d / 2) * (d / 2) * e >= v))
printf("NO\n");
else
{
double tmp1 = pi * (d / 2) * (d / 2) * h;
double tmp = pi * (d / 2) * (d / 2) * e;
printf("YES\n%.12f\n", tmp1 / (v - tmp));
}
return 0;
}
B题就是两边之和大于第三边,一下就搞定了
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
using namespace std;
typedef __int64 ll;
#define pi 3.14159265359
const int MAX = 1e5 + 5;
typedef long long ll;
ll arr[MAX];
inline void file()
{
freopen("D:\\go.txt", "r", stdin);
freopen("D:\\leave.txt", "w", stdout);
}
int main()
{
//file();
//ios::sync_with_stdio(false);
int n;
scanf("%d", &n);
ll res = 0;
for (int i = 0; i < n; ++i)
{
scanf("%I64d", &arr[i]);
res += arr[i];
}
ll a = res / 3;
sort(arr , arr + n);
ll t1 = 0;
for (int i = n - 1; i >= 0; --i)
{
t1 += arr[i];
if (t1 >= a)
break;
}
ll tmp = res - t1;
printf("%I64d\n", abs(tmp - t1) + 1);
return 0;
}
A,B都是很简单的应该,,用文件交题A和B的时候,代码复制错了,WA了几次。。。。。