noip模拟赛#42
T1:给len=1e5的数字串,操作为将某个位置起始的后缀搬到最前面。求有多少个不重复的比原串大和多少个小。
=>maya这铁定可以找出些什么规律来。然后就over 了。
=>字符串hash一下就可以了。
//map的常数还是很大的。hash的时候o->to一定要ll!!! 23333 999983
#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,s,t) for(int i=s;i<=t;i++)
#define dwn(i,s,t) for(int i=s;i>=t;i--)
#define clr(x,c) memset(x,c,sizeof(x))
#define ll unsigned long long
#define qwq(x) for(edge *o=head[x];o;o=o->next)
int read(){
int x=0;char c=getchar();
while(!isdigit(c)) c=getchar();
while(isdigit(c)) x=x*10+c-'0',c=getchar();
return x;
}
const int nmax=2e5+5;
const int inf=0x7f7f7f7f;
const int mod=999983;
char s[nmax];ll p[nmax],eo[nmax];
ll cal(int l,int r){
return p[r]-p[l-1]*eo[r-l+1];
}
int find(int tl,int tr){
int ans=0,mid,l=1,r=tr-tl+1;
while(l<=r){
mid=l+r>>1;
if(cal(1,mid)==cal(tl,tl+mid-1)) ans=mid,l=mid+1;
else r=mid-1;
}
return ans;
}
struct edge{
ll to;edge *next;
};edge es[mod<<1],*pt=es,*head[mod<<1];
bool check(ll x){
int t=x%mod;
qwq(t) if(o->to==x) return 1;return 0;
}
void add(ll x){
int t=x%mod;
pt->to=x;pt->next=head[t];head[t]=pt++;
}
int main(){
freopen("number.in","r",stdin);freopen("number.out","w",stdout);
scanf("%s",s+1);int n=strlen(s+1);
rep(i,1,n) s[i+n]=s[i];
eo[0]=1;rep(i,1,n+n) eo[i]=eo[i-1]*233ll;
p[0]=1;rep(i,1,n+n) p[i]=p[i-1]*233ll+s[i]-'0';
int ans=0,res=0,cur;ll ts;
rep(i,2,n){
ts=cal(i,i+n-1);cur=find(i,i+n-1);
if(cur==n||check(ts)) continue;
if(s[i+cur]>s[cur+1]) res++,add(ts);else ans++,add(ts);
}
printf("%d 1 %d\n",ans,res);
fclose(stdin);fclose(stdout);
return 0;
}
T2:每次可以捞出一条任意品种的鱼或者捞不出什么鱼。n个品种。给出每一次捞出某个品种的鱼的概率。求捞出全部品种的鱼的期望次数。
=>http://blog.csdn.net/u011787119/article/details/40151201 里的题差不多。。。然而我最后/tm我一开始总是写成(1-tm)。。。
#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
using namespace std;
#define rep(i,s,t) for(int i=s;i<=t;i++)
#define dwn(i,s,t) for(int i=s;i>=t;i--)
#define clr(x,c) memset(x,c,sizeof(x))
int read(){
int x=0,f=1;char c=getchar();
while(!isdigit(c)){
if(c=='-') f=-1;c=getchar();
}
while(isdigit(c)) x=x*10+c-'0',c=getchar();
return x*f;
}
const int nmax=3050000;
const int inf=0x7f7f7f7f;
double p[nmax],dp[nmax];int t[26];
int main(){
freopen("fish.in","r",stdin);freopen("fish.out","w",stdout);
int n=read();p[n+1]=1.0;
rep(i,1,n) scanf("%lf",&p[i]),p[n+1]-=p[i];
int st=(1<<n)-1;dp[st]=0.0;double tm=0;
dwn(i,st-1,0){
rep(j,1,n) t[j]=0;t[0]=0;tm=0;
for(int tp=i;tp;tp>>=1) t[++t[0]]=tp&1;
rep(j,1,n) if(t[j]==0) dp[i]+=dp[i+(1<<(j-1))]*p[j],tm+=p[j];
dp[i]+=1.0;dp[i]/=tm;
}
printf("%.2lf\n",dp[0]);
fclose(stdin);fclose(stdout);
return 0;
}
T3:????不懂。。。
noip模拟赛#42的更多相关文章
- NOIP模拟赛20161022
NOIP模拟赛2016-10-22 题目名 东风谷早苗 西行寺幽幽子 琪露诺 上白泽慧音 源文件 robot.cpp/c/pas spring.cpp/c/pas iceroad.cpp/c/pas ...
- contesthunter暑假NOIP模拟赛第一场题解
contesthunter暑假NOIP模拟赛#1题解: 第一题:杯具大派送 水题.枚举A,B的公约数即可. #include <algorithm> #include <cmath& ...
- NOIP模拟赛 by hzwer
2015年10月04日NOIP模拟赛 by hzwer (这是小奇=> 小奇挖矿2(mining) [题目背景] 小奇飞船的钻头开启了无限耐久+精准采集模式!这次它要将原矿运到泛光之源的矿 ...
- 大家AK杯 灰天飞雁NOIP模拟赛题解/数据/标程
数据 http://files.cnblogs.com/htfy/data.zip 简要题解 桌球碰撞 纯模拟,注意一开始就在袋口和v=0的情况.v和坐标可以是小数.为保险起见最好用extended/ ...
- 队爷的讲学计划 CH Round #59 - OrzCC杯NOIP模拟赛day1
题目:http://ch.ezoj.tk/contest/CH%20Round%20%2359%20-%20OrzCC杯NOIP模拟赛day1/队爷的讲学计划 题解:刚开始理解题意理解了好半天,然后发 ...
- 队爷的Au Plan CH Round #59 - OrzCC杯NOIP模拟赛day1
题目:http://ch.ezoj.tk/contest/CH%20Round%20%2359%20-%20OrzCC杯NOIP模拟赛day1/队爷的Au%20Plan 题解:看了题之后觉得肯定是DP ...
- 队爷的新书 CH Round #59 - OrzCC杯NOIP模拟赛day1
题目:http://ch.ezoj.tk/contest/CH%20Round%20%2359%20-%20OrzCC杯NOIP模拟赛day1/队爷的新书 题解:看到这题就想到了 poetize 的封 ...
- CH Round #58 - OrzCC杯noip模拟赛day2
A:颜色问题 题目:http://ch.ezoj.tk/contest/CH%20Round%20%2358%20-%20OrzCC杯noip模拟赛day2/颜色问题 题解:算一下每个仆人到它的目的地 ...
- CH Round #52 - Thinking Bear #1 (NOIP模拟赛)
A.拆地毯 题目:http://www.contesthunter.org/contest/CH%20Round%20%2352%20-%20Thinking%20Bear%20%231%20(NOI ...
随机推荐
- 消息队列RabbitMQ、缓存数据库Redis
1.RabbitMQ消息队列 1.1 RabbitMQ简介 AMQP,即Advanced Message Queuing Protocol,高级消息队列协议,是应用层协议的一个开放标准,为面向消息的中 ...
- Java: 面向对象程序设计(上)
1. 类 类主要包含3个部分: 类属性:用来描述类本身所抽象出的事物的属性 类方法:用来描述这个被抽象出的事物可以做什么 构造方法:每个类都至少会有一个特殊的方法,该方法提供了创建类对象的初始化机制 ...
- Shell操作相关的快捷键 --Linux
一.shell和bash shell --unix --Bourne shell ,bash --linux --Bourne again shell.bash (GNU Bourne-Again S ...
- npm install 权限问题
npm ERR! Error: EACCES: permission denied, access '/Users/Lobin/work/note-vue/node_modules/@babel/hi ...
- 025 Reverse Nodes in k-Group 每k个一组翻转链表
给出一个链表,一次翻转 k 个指针节点,并返回修改后的链表.k 是一个正整数,并且小于等于链表的长度.如果指针节点的数量不是 k 的整数倍,那么最后剩余的节点应当保持原来的样子.你不应该改变节点的值, ...
- Storm概念学习系列之事务
不多说,直接上干货! 事务 这里的事务是专门针对Topology提出来的,是为了解决元组在处理失败重新发送后的一系列问题的.简而言之,事务拓扑(transactional topology)就是指St ...
- 了解【Docker】从这里开始
一.环境配置的难题 软件开发最大的难题之一就是环境配置的问题.现在用户环境纷乱复杂,并且由于开源社区的进一步推广和许多开源项目不停地迭代更新,项目可能会有越来越多的依赖以及越来越难管理的依赖版本,如何 ...
- 汇编语言版本的HelloWorld
平台 macOS 工具 nasm clang 文件 main.asm extern _printf ; 这里调用系统的一个系统调用函数, _printf, 使用extern告诉链接器该label在其他 ...
- Freetype 安装时提示 make: Nothing to be done for `unix'
[Software-Freetype] Freetype 安装时提示 make: Nothing to be done for `unix' 官网下载的第三方软件包,编译安装会报以下错误,解决办法如下 ...
- Timer控制开始、停止例子【转】
public partial class Form1 : Form { static public bool flag; public Form1() ...