SRM467
250pt:
一个学生等老师来上课的,但是他不知道老师啥时候会来的,然后他等waiting时间后觉得无聊就会出去转walking时间,回来等待waiting时间后老师没来就会再次出去。老师会在a...b区间时间任意时刻来,是等概率的。但是老师等t时间后,就会不会让你进来了的。让你求你进不去教室的概率是多少。(所有的数<= 1000W)
思路:因为小于1000w,所以我就暴力把每一分钟的状态都统计出来。
注意长度为0的情况即可(比如老师即到即走的情况)举要特判
#line 7 "LateProfessor.cpp"
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std; #define PB push_back
#define MP make_pair #define REP(i,n) for(i=0;i<(n);++i)
#define FOR(i,l,h) for(i=(l);i<=(h);++i)
#define FORD(i,h,l) for(i=(h);i>=(l);--i) typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<double> VD;
typedef long long LL;
typedef pair<int,int> PII; class LateProfessor
{
public:
double getProbability(int wait, int walk, int late, int st, int end)
{
double sum = (end - st);
int m = wait + walk;
double ans = ;
// int last = -1, len = 0;
if (st == end){
if (st % m <= wait || (st % m > wait && st % m + late > m)) return 0.0;
return 1.0;
}
for (int i = st; i < end; ++i){
if (i % m < wait || (i % m >= wait && i % m + late >= m)) ++ans;
}
return - ans / sum;
} };
500pt:
给定supersum定义如下
- SuperSum(0 , n) = n, for all positive n.
- SuperSum(k , n) = SuperSum(k-1 , 1) + SuperSum(k-1 , 2) + ... + SuperSum(k-1 , n), for all positive k, n.
给定k,n(k <= 50, n <= 10^9),求supersum(k,n)
思路:乍一看不会做,然后就打了个20*20的表,发现斜着看就是一个杨辉三角,然后直接算可以了
答案就是C(n + k, k + 1)
#line 7 "SuperSum.cpp"
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std; #define PB push_back
#define MP make_pair #define REP(i,n) for(i=0;i<(n);++i)
#define FOR(i,l,h) for(i=(l);i<=(h);++i)
#define FORD(i,h,l) for(i=(h);i>=(l);--i)
#define M 1000000007
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<double> VD;
typedef long long LL;
typedef pair<int,int> PII; class SuperSum
{
public:
long long power(long long a, long long b){
long long ret = ;
while (b){
if (b&) ret = (ret * a) % M;
b >>= ;
a = (a * a) % M;
}
return ret;
}
long long C(int n, int m){
long long ret = ;
for (int i = ; i <= m; ++i){
ret = (ret * power(i, M - )) % M;
ret = (ret * (n - i + )) % M;
}
return ret;
}
int calculate(int K, int N)
{
int n = K + N;
int m = K + ;
return C(n, m);
} };
SRM467的更多相关文章
随机推荐
- poj 2492(关系并查集) 同性恋
题目;http://poj.org/problem?id=2492 卧槽很前卫的题意啊,感觉节操都碎了, t组测试数据,然后n,m,n条虫子,然后m行,每行两个数代表a和b有性行为(默认既然能这样就代 ...
- 事件类型(js)
焦点事件:在页面获得或失去焦点时触发. 与document.hasFocus和document.activeElement属性配合,可以得到用户在页面的行踪. blur:元素失去焦点时触发.这个事件不 ...
- ubuntu如何实现双屏显示
转载自https://blog.csdn.net/tianmaxingkong_/article/details/50570538
- RabbitVCS - Ubuntu VCS Graphical Client
Easy version control for Linux RabbitVCS is a set of graphical tools written to provide simple and s ...
- ssh密钥讲解
我们用ssh连接机器时候需要输用户名.密码,但是直接写账户文件的时候由于用的是明文,就存在安全的问题了.别人一旦截取了数据就获得了隐私了.这时候就用上ssh的密钥. ssh的密钥存是成对出现的,一个叫 ...
- js实现多标签页效果
点击导航按钮切换div的内容 html代码: <div class="tabs"> <ul id="tab"> <li>&l ...
- Python module : simuPOP
conda config --add channels conda-forge conda install simupop simuPOP is a general-purpose individua ...
- 销售vs技术岗,做技术的方法思考
销售甚至比技术岗位挣得还多,当然,做技术的比较好的拿到的自然也多. 我在想个问题,技术的天然优势是可以不断地积累,包括写code,写博客,做流程,完善流程,自动化流程,或者把某些工作流程化,自动化,托 ...
- jquery库google加载
加载js库的时候可以加载google CDN,可以同时加载多个jquery库<script src="http://www.google.com/jsapi">< ...
- 2019.01.08 codeforces 1009F. Dominant Indices(长链剖分)
传送门 长链剖分模板题. 题意:给出一棵树,设fi,jf_{i,j}fi,j表示iii的子树中距离点iii距离为jjj的点的个数,现在对于每个点iii要求出使得fif_ifi取得最大值的那个jjj ...