您的位置:首页 > 其它

HDU1006

2016-07-14 11:27 211 查看
我只是想存一下这些水题的代码

#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
using namespace std;
int main()
{
int n;
while (cin >> n)
{
if (n == -1)break;
int sum = 0;
for (int a = 0;a < 12;a++)
{
for (int b = 0;b < 60;b++)
{
for (int c = 0;c < 60;c++)
{
long double x = abs(30 * a * 120 - 55 * b * 12 - 11 * c);
long double yi = min(x, 360 * 120 - x);
x = abs(6 * b * 120 - 59 * c * 12);
long double er = min(x, 360 * 120 - x);
x = abs(30 * a * 120 + 5 * b * 12 - 719 * c);
long double san = min(x, 360 * 120 - x);
if (yi >= n * 120 && er >= n * 120 && san >= n * 120)sum++;
}
}
}
printf("%.3f\n", (100.0*sum) / (12 * 3600));
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: