Hust oj 2235 毒(水题)
来源:互联网 发布:页游服务器端 知乎 编辑:程序博客网 时间:2024/05/16 01:31
毒Time Limit: 500 MSMemory Limit: 32768 KTotal Submit: 148(90 users)Total Accepted: 103(87 users)Rating: Special Judge: NoDescription现有n瓶毒药,第1瓶毒药的毒性为1,第i瓶毒药比第i-1瓶毒药的毒性增长了(((i-1)*K)%M),将第i瓶毒药的毒性记做vi。
你可以将任意两瓶毒药混合。若将第i瓶毒药和第j瓶毒药混合,则混合后的毒药的毒性为2*sqrt(vi*vj)。(sqrt表示开方)。
合并到最后,将会只剩下一瓶毒药。请问最后剩下的毒药的毒性最小是多少?Input第一行一个数T,表示有T组数据。
每组数据只有一行,包含三个数n, K, M。
(n <= 1000000)
(K, M <= 1000)Output对于每组数据,输出一个剩余毒药的最小毒性。保留三位小数。Sample Input2
2 2 1000
3 2 1000Sample Output3.464
你可以将任意两瓶毒药混合。若将第i瓶毒药和第j瓶毒药混合,则混合后的毒药的毒性为2*sqrt(vi*vj)。(sqrt表示开方)。
合并到最后,将会只剩下一瓶毒药。请问最后剩下的毒药的毒性最小是多少?Input第一行一个数T,表示有T组数据。
每组数据只有一行,包含三个数n, K, M。
(n <= 1000000)
(K, M <= 1000)Output对于每组数据,输出一个剩余毒药的最小毒性。保留三位小数。Sample Input2
2 2 1000
3 2 1000Sample Output3.464
6.055
想让得到的数最小,一定是两个相邻的毒药混合,所以。。sort一下就好
#include<cstdio>#include<cmath>#include<algorithm>using namespace std;double a[1000005];int main(){ int t; scanf("%d",&t); while(t--) { int n,k,m; scanf("%d%d%d",&n,&k,&m); a[1]=1.0; for(int i=2;i<=n;i++) { a[i]=a[i-1]+(double)(((i-1)*k)%m); } sort(a+1,a+1+n); for(int i=n-1;i>=1;i--) { a[n]=2.0*sqrt(a[n]*a[i]); } printf("%.3lf\n",a[n]); } return 0;}
0 0
- Hust oj 2235 毒(水题)
- Hust oj 1369 Buy Computers(水题)
- Hust oj 2121 你猜猜(水题)
- Hust oj 2125 钱多多(水题)
- Hust oj 1693 Difficult work(水题)
- Hust oj 2000 极差(水题)
- Hust oj 1720 Fibonacci Numbers(水题)
- Hust oj 1629 统计图(水题)
- Hust oj 1431 摞盘子(水题)
- Hust oj 1046 Balls Collision(水题)
- Hust oj 2084(大数)
- Hust oj 1394 XianGe的游戏I(水题)
- Hust oj 1197 Cuts the cake(水题)
- Hust oj 1384 Leyni, LOLI and Toasts(水题)
- Hust oj 2116 Maximum continuous product(水题)
- Hust oj 1673 2013新的旅程(水题)
- Hust oj 1754 Minimum Scalar Product(水题)
- Hust oj 1648 Tailmon与序列(水题)
- Shell脚本编程(一):输出重定向
- UICollectionView
- 实型变量在内存中的存放形式
- iOS开发之高级视图—— UICollectionView
- 去除word文档中单词下的曲线(拼写错误)
- Hust oj 2235 毒(水题)
- 总结下今天看到的关于unsafe的信息
- 根据li标签 查找class="alcw4 alcw41"对应的值
- 如何使用GitHub
- 对象(深入C++对象模型)
- 数据结构 第十章 内部排序之插入排序
- HorizontalScrollView实现右滑菜单与ListView左滑删除冲突解决(事件分发顺序)
- 第十/十一周项目一(2)-点-圆-圆柱类族的设计
- C++ STL--stack/queue 的使用方法