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 kn.

给定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的更多相关文章

随机推荐

  1. PHP学习笔记(二)

    1.表单 PHP 的 $_GET和 $_POST用于检索表单中的值,比如用户输入. $_GET和$_POST变量分别用于收集来自 method="get" 和method=&quo ...

  2. Java 使用jdk自带的wsimport命令生成webservice客户端代码

    wsimport -s E:\workspace\givemewords\src -p com.test.service -keep http://localhost:8085/Service/Fun ...

  3. powerdesigner mysql逆向工程注释不显示问题

  4. scrapy爬取网址,进而爬取详情页问题

    1.最容易出现的问题是爬取到的url大多为相对路径,如果直接将爬取到的url进行二次爬取就会出现以下报错: raise ValueError('Missing scheme in request ur ...

  5. C# 遇到 which has a higher version than referenced assembly

    当C#遇到这种提示: which has a higher version than referenced assembly, 说明有两个或多个工程引用的dll的版本有出现不一样, 如: A工程引用l ...

  6. Java类加载机制及自定义加载器

    转载:https://www.cnblogs.com/gdpuzxs/p/7044963.html Java类加载机制及自定义加载器 一:ClassLoader类加载器,主要的作用是将class文件加 ...

  7. Cantor表(NOIP1999)

    题目链接:Cantor表 这道题很水,但有的人没看懂题意,这不怪大家,怪题目没说清楚. 给张图: 看到这,你应该明白题目意思了. 先看看有什么规律. 我把这个数列写出来: 1/1,1/2,2/1,3/ ...

  8. Windows AD域管理软件

  9. Rest架构风格的实践(使用通用Mapper技术)

    1.根据用户 id 查询用户数据 1.1 controll控制器 @RequestMapping("restful/user") @Controller public class ...

  10. python使用Fabric模块实现自动化运维

    简介:Fabric是基于Python实现的SSH命令行工具,简化了SSH的应用程序部署及系统管理任务,它提供了系统基础的操作组件,可以实现本地或远程shell命令,包括:命令执行.文件上传.下载及完整 ...