1716: 毒

Time Limit: 2 Sec  Memory Limit:
128 MB

Submit: 96  Solved: 43



SubmitStatusWeb
Board

Description

现有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 Input

2
2 2 1000
3 2 1000

Sample Output

3.464
6.055

读题很重要啊!!!原来是第i瓶比第i-1瓶毒性高那摩多!怪不得测试数据都不过,不过有一点就是要把毒性排序,因为已经取余了


#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
int a[1000100];
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
memset(a,0,sizeof(a));
int n,k,m;
scanf("%d%d%d",&n,&k,&m);
a[1]=1;
for(int i=2;i<=n;i++)
a[i]=a[i-1]+((i-1)*k)%m;
sort(a+1,a+1+n);
double s=a[n];
for(int i=n-1;i>=1;i--)
s=2*sqrt(s*a[i]);
printf("%.3f\n",s);
}
return 0;
}


zzulioj--1716--毒(模拟水题)的更多相关文章

  1. HDOJ 2317. Nasty Hacks 模拟水题

    Nasty Hacks Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Tota ...

  2. POJ 2014:Flow Layout 模拟水题

    Flow Layout Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 3091   Accepted: 2148 Descr ...

  3. HDU - 1716 排列2 水题

    排列2 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submis ...

  4. 模拟水题,查看二维数组是否有一列都为1(POJ2864)

    题目链接:http://poj.org/problem?id=2864 题意:参照题目 哈哈哈,这个题discuss有翻译哦.水到我不想交了. #include <cstdio> #inc ...

  5. UVA 10714 Ants 蚂蚁 贪心+模拟 水题

    题意:蚂蚁在木棍上爬,速度1cm/s,给出木棍长度和每只蚂蚁的位置,问蚂蚁全部下木棍的最长时间和最短时间. 模拟一下,发现其实灰常水的贪心... 不能直接求最大和最小的= =.只要求出每只蚂蚁都走长路 ...

  6. Codeforces 1082B Vova and Trophies 模拟,水题,坑 B

    Codeforces 1082B Vova and Trophies https://vjudge.net/problem/CodeForces-1082B 题目: Vova has won nn t ...

  7. HDU4287-STL模拟水题

    一场2012天津网络预选赛的题,签到题. 但是还是写了三四十分钟,C++和STL太不熟悉了,总是编译错误不知道怎么解决. 一开始用的Char [] 后来改成了string,STL和string搭配起来 ...

  8. hdu 4891 模拟水题

    http://acm.hdu.edu.cn/showproblem.php?pid=4891 给出一个文本,问说有多少种理解方式. 1. $$中间的,(s1+1) * (s2+1) * ...*(sn ...

  9. Mishka and Contest(模拟水题)

    Mishka started participating in a programming contest. There are nn problems in the contest. Mishka' ...

随机推荐

  1. angularjs1-4 事件指令

    <div ng-app="myApp"> <div ng-controller="firstController"> <div n ...

  2. hdoj--2120--Ice_cream's world I(并查集判断环)

    Ice_cream's world I Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Othe ...

  3. 【POJ 2482】 Stars in Your Windows

    [题目链接] http://poj.org/problem?id=2482 [算法] 线段树 + 扫描线 [代码] #include <algorithm> #include <bi ...

  4. 【转】iOS 设置APP的名称(浅述APP版本国际化与本地化)

    原文网址:http://www.jianshu.com/p/a3a70f0398c4 前言 App的名字设置方式有很多种,如果在App打包上线时不做修改,最终App的名字就是Xcode在建立工程时的名 ...

  5. 1. Two Sum[E]两数之和

    题目 Given an array of integers, return indices of the two numbers such that they add up to a specific ...

  6. POJ 1466 最大独立点集

    思路:匈牙利 n-ans/2; // by SiriusRen #include <cstdio> #include <cstring> #define N 505 using ...

  7. Java io 操作

    package tlistpackage; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFou ...

  8. struts2学习之基础笔记1

    第6章 Strusts 2框架 1  引出 Web App  àà MVC  àà View 视图(jsp,html,JS) | C(Servlet)Filter,Listneer | M(数据bea ...

  9. Java操作Kafka执行不成功

    使用kafka-clients操作kafka始终不成功,原因不清楚,下面贴出相关代码及配置,请懂得指点一下,谢谢! 环境及依赖 <dependency> <groupId>or ...

  10. c#初学12-12-为什么mian函数必须是static的

    c#初学12-12-为什么mian函数必须是static的 c#程序刚开始启动的时候都会有唯一一个入口函数main()函数, 而非静态成员又称实例成员,必须作用于实例.在程序刚开始运行的时候,未建立任 ...