大提琴的声音就像一条河,左岸是我无法忘却的回忆,右岸是我值得紧握的璀璨年华,中间流淌的,是我年年岁岁淡淡的感伤。

链接:https://ac.nowcoder.com/acm/problem/17650
来源:牛客网

题目描述

蛋蛋非常热衷于挑战自我,今年暑假他准备沿川藏线骑着自行车从成都前往拉萨。川藏线的沿途有着非常美丽的风景,但在这一路上也有着很多的艰难险阻,路况变化多端,而蛋蛋的体力十分有限,因此在每天的骑行前设定好目的地、同时合理分配好自己的体力是一件非常重要的事情。
由于蛋蛋装备了一辆非常好的自行车,因此在骑行过程中可以认为他仅在克服风阻做功(不受自行车本身摩擦力以及自行车与地面的摩擦力影响)。某一天他打算骑N段路,每一段内的路况可视为相同:

对于第i段路,我们给出有关这段路况的3个参数 si,ki,vi′ ,

si 表示这段路的长度,

ki 表示这段路的风阻系数,

vi′ 表示这段路上的风速(表示在这段路上他遇到了顺风,反之则意味着他将受逆风影响)。

若某一时刻在这段路上骑车速度为v,则他受到的风阻大小为 F=ki(v−vi′)2

(这样若在长度为s的路程内保持骑行速度v不变,则他消耗能量(做功)E=ki(v−vi′)2s)。
设蛋蛋在这天开始时的体能值是 Eu ,请帮助他设计一种行车方案,使他在有限的体力内用最短的时间到达目的地。请告诉他最短的时间T是多少。

输入描述:

第一行包含一个正整数N和一个实数Eu,分别表示路段的数量以及蛋蛋的体能值。 接下来N行分别描述N个路段,每行有3个实数 si,ki,vi′ ,分别表示第 i 段路的长度,风阻系数以及风速。

输出描述:

输出一个实数T,表示蛋蛋到达目的地消耗的最短时间,要求至少保留到小数点后6位。

示例1

输入

复制

3 10000
10000 10 5
20000 15 8
50000 5 6

输出

复制

12531.34496464 

说明

一种可能的方案是:蛋蛋在三段路上都采用匀速骑行的方式,其速度依次为5.12939919, 8.03515481, 6.17837967。

备注:

对于10%的数据,N=1
对于40%的数据,N<=2
对于60%的数据,N<=100
对于80%的数据,N<=1000
对于所有数据,N<=10000,0<=Eu<=108,0<si<=100000,0<ki<=1,−100<vi′<100。数据保证最终的答案不会超过105。
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <ctime>
#include <cctype>
#include <bitset>
#include <utility>
#include <sstream>
#include <complex>
#include <iomanip>
#define inf 1e5
typedef long long ll;
using namespace std;
const double wc=1e-12;
int n;
double eu,s[10010],k[10010],u[10010],v[10010];
bool check(double x)
{double e=0;for (int i=1; i<=n; i++){double left=max(u[i],0.0),right=inf;while (right-left>=wc){double mid=(left+right)/2.0;if (2*x*k[i]*(mid-u[i])*mid*mid>=1)right=mid;elseleft=mid;}v[i]=left;e+=k[i]*s[i]*(v[i]-u[i])*(v[i]-u[i]);}return e>=eu;
}
int main()
{scanf("%d%lf",&n,&eu);for (int i=1; i<=n; i++)scanf("%lf%lf%lf", s+i, k+i, u+i);double left=0,right=inf;while(right-left>=wc){double mid=(left+right)/2.0;if (check(mid))left=mid;elseright=mid;}double t=0;for(int i=1; i<=n; i++)t+=s[i]/v[i];printf("%.8lf\n",t);return 0;
}

链接:https://ac.nowcoder.com/acm/problem/19014
来源:牛客网

题目描述

Bob has collected a lot of coins in different kinds. He wants to know which kind of coins is lucky. He finds out a lucky kind of coins by the following way. He tosses all the coins simultaneously, and then removes the coins that come up tails. He then tosses all the remaining coins and removes the coins that come up tails. He repeats the previous step until there is one kind of coins remaining or there are no coins remaining. If there is one kind of coins remaining, then this kind of coins is lucky. Given the number of coins and the probability that the coins come up heads after tossing for each kind, your task is to calculate the probability for each kind of coins that will be lucky.

输入描述:

The first line is the number of test cases. For each test case, the first line contains an integer k representing the number of kinds. Each of the following k lines describes a kind of coins, which contains an integer and a real number representing the number of coins and the probability that the coins come up heads after tossing. It is guaranteed that the number of kinds is no more than 10, the total number of coins is no more than 1000000, and the probabilities that the coins come up heads after tossing are between 0.4 and 0.6.

输出描述:

For each test case, output a line containing k real numbers with the precision of 6 digits, which are the probabilities of each kind of coins that will be lucky.

示例1

输入

复制

3
1
1000000 0.5
2
1 0.4
1 0.6
3
2 0.4
2 0.5
2 0.6

输出

复制

1.000000
0.210526 0.473684
0.124867 0.234823 0.420066
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <ctime>
#include <cctype>
#include <bitset>
#include <utility>
#include <sstream>
#include <complex>
#include <iomanip>
#define inf 0x3f3f3f3f
typedef long long ll;
using namespace std;
double d[20][100],l[20][100];
int a,n,T;
double kpow(double a,int b)
{double ans=1;while(b){if(b&1)ans=ans*a;a=a*a;b>>=1;}return ans;
}
int main()
{scanf("%d",&T);while(T--){double p,k;scanf("%d",&n);for(int i=0; i<n; i++){scanf("%d%lf",&a,&p);k=1;for(int j=0; j<100; j++){k*=p;d[i][j]=kpow(1-k,a);l[i][j]=1-d[i][j];}}if(n==1){printf("1.000000\n");continue;}for(int i=0; i<n; i++){double sum=0;for(int j=0; j<100-1; j++){double t=l[i][j]-l[i][j+1];for(int k=0; k<n; k++)if(k!=i)t*=d[k][j];sum+=t;}printf("%f ",sum);}printf("\n");}
}

链接:https://ac.nowcoder.com/acm/problem/15067
来源:牛客网

题目描述

夫夫有一天对一个数有多少位数感兴趣,但是他又不想跟凡夫俗子一样,
所以他想知道给一个整数n,求n!的在8进制下的位数是多少位。

输入描述:

第一行是一个整数t(0<t<=1000000)(表示t组数据)
接下来t行,每一行有一个整数n(0<=n<=10000000)

输出描述:

输出n!在8进制下的位数。

示例1

输入

复制

3
4
2
5

输出

复制

2
1
3
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <ctime>
#include <cctype>
#include <bitset>
#include <utility>
#include <sstream>
#include <complex>
#include <iomanip>
#define inf 0x3f3f3f3f
#define PI 3.141592653589793
typedef long long ll;
using namespace std;
int t,n;
int main()
{scanf("%d",&t);while(t--){scanf("%d",&n);int ans=1;if(n>2)ans=(n*log(n)-n+log(2*PI*n)/2)/log(8)+1;printf("%d\n",ans);}return 0;
}

牛客每日练习----骑行川藏,Lucky Coins,不凡的夫夫相关推荐

  1. [NOI2012]骑行川藏

    [NOI2012]骑行川藏 思路一:二分导数 http://www.cnblogs.com/RabbitHu/p/9019762.html 考虑"性价比"即花费单位能量缩短的时间. ...

  2. bzoj 2876: [Noi2012]骑行川藏 拉格朗日数乘

    2876: [Noi2012]骑行川藏 Time Limit: 20 Sec  Memory Limit: 128 MBSec  Special Judge Submit: 1033  Solved: ...

  3. 2876: [Noi2012]骑行川藏

    2876: [Noi2012]骑行川藏 Time Limit: 20 Sec  Memory Limit: 128 MBSec  Special Judge Submit: 1243  Solved: ...

  4. 高等数学(拉格朗日乘子法):NOI 2012 骑行川藏

    [NOI2012] 骑行川藏 输入文件:bicycling.in   输出文件:bicycling.out   评测插件 时间限制:1 s   内存限制:128 MB NOI2012 Day1 Des ...

  5. BZOJ2876 [Noi2012]骑行川藏

    本文版权归ljh2000和博客园共有,欢迎转载,但须保留此声明,并给出原文链接,谢谢合作. 本文作者:ljh2000 作者博客:http://www.cnblogs.com/ljh2000-jump/ ...

  6. [BZOJ2876] [NOI2012]骑行川藏

    Description 蛋蛋非常热衷于挑战自我,今年暑假他准备沿川藏线骑着自行车从成都前往拉萨.川藏线的沿途有着非常美丽的风景,但在这一路上也有着很多的艰难险阻,路况变化多端,而蛋蛋的体力十分有限,因 ...

  7. bzoj 2876: [Noi2012]骑行川藏 拉格朗日乘子法

    题意 蛋蛋非常热衷于挑战自我,今年暑假他准备沿川藏线骑着自行车从成都前往拉萨.川藏线的沿途有着非常美丽的风景,但在这一路上也有着很多的艰难险阻,路况变化多端,而蛋蛋的体力十分有限,因此在每天的骑行前设 ...

  8. bzoj 2876: [Noi2012]骑行川藏 二分+拉格朗日乘数法

    题意 蛋蛋非常热衷于挑战自我,今年暑假他准备沿川藏线骑着自行车从成都前往拉萨.川藏线的沿途有着非常美丽的风景,但在这一路上也有着很多的艰难险阻,路况变化多端,而蛋蛋的体力十分有限,因此在每天的骑行前设 ...

  9. bzoj2876: [Noi2012]骑行川藏 :拉格朗日乘数法

    题目链接 bzoj2876 题目描述 Description 蛋蛋非常热衷于挑战自我,今年暑假他准备沿川藏线骑着自行车从成都前往拉萨.川藏线的沿途有着非常美丽的风景,但在这一路上也有着很多的艰难险阻, ...

最新文章

  1. 2021年4月自动驾驶领域重要动态速览
  2. Nginx + CGI/FastCGI + C/Cpp
  3. 四、设计模式——策略模式
  4. vba 在光标插入文字_VBA学习入门方法!Office Excel教程 Excel入门 Excel技巧 Excel学习!...
  5. CentOS 7下搭建配置 SVN 服务器
  6. MapReduce会自动忽略文件夹下的.开头的文件
  7. jenkins html报告不显示样式
  8. 【蓝桥杯】题目 1429: 兰顿蚂蚁
  9. matlab实现qr分解
  10. oracle更新前触发器,Oracle之前更新触发器
  11. 安装autocad2006出错
  12. 不同数据量下主键类型的选择
  13. 海康威视错误代码0xf_技术讨论 | 看我如何重置海康威视IP摄像机的管理员密码...
  14. 在浏览器环境下,用Excel.js读取excel文件
  15. 打印的几种方法(lodop、window.print)
  16. Excel批量根据银行卡号查询银行卡的详细信息
  17. 解决联想笔记本电脑经常突然休眠的问题
  18. 人工智能有什么价值和意义
  19. mysql无法执行二进制文件_kail系统64,mysql64,出现-bash: bin/mysqld: 无法执行二进制文...
  20. 什么是智能设备远程监控系统?

热门文章

  1. vsphere学习笔记系列-vmotion
  2. R语言LR逻辑回归实例
  3. 使用 Web3.js 进行 Matic 测试网上链操作
  4. Log4cpp: log4cpp快速使用指南
  5. 双足竞走机器人的意义_基于STM32双足竞步机器人的研究与设计
  6. Unknown column 'JOIN.id' in 'order clause'和 Unknown column 'XXXX.id' in 'order clause'的解决办法
  7. String“+”与StringBuffer/StringBuilder 对象的append方法
  8. 怎么样跑步才会消耗掉脂肪而不是肌肉和水分呢
  9. 有关防火墙的调研总结
  10. MySQL慢SQL探究