9.28NOIP模拟题
9.28NOIP模拟题
|
题目 |
哈 |
哈哈 |
哈哈哈 |
|
英文题目与子目录名 |
ha |
haha |
hahaha |
|
单个测试点时间限制 |
1秒 |
1秒 |
1秒 |
|
内存限制 |
256M |
128M |
64M |
|
测试点数目 |
10 |
10 |
10 |
|
每个测试点分值 |
10 |
10 |
10 |
|
比较方式 |
全文比较(过滤行末空格及文末回车) |
||
|
题目类型 |
传统 |
传统 |
传统 |
哈
Description
求字符串的所有前缀在字符串中出现的次数和
Input
第一行一个整数L,表示字符串长度
一个字符串
Output
一行表示答案,答案对1000007取模
Example
Input:
4
abab
Output:
4
Hint
对于20%的数据,L<=50
对于50%的数据,L<=4000
对于70%的数据,L<=100000
对于100%的数据,L<=10000000
/*
假设两串字符完全相等,next[j]=i,代表s[1...i]==sum[j-i+1....j],这一段其实就是前缀
i~j之间已经不可能有以j结尾的子串是前缀了,不然next【j】就不是 i 了
设dp【i】:以string[i]结尾的子串总共含前缀的数量
所以dp[j]=dp[i]+1,即以i结尾的子串中含前缀的数量加上前j个字符这一前缀
*/
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <iostream>
using namespace std;
const int N = ;
char a[N];
int next[N],d[N];
void get_next(char *b)
{
int i = -, j = ;
next[] = -;
int len = strlen(b);
while(j < len)
{
if(i == - || b[i] == b[j])
next[++j] = ++i;
else
i = next[i];
}
}
int main()
{
int T,i,n;
scanf("%d",&T);
while(T--)
{
scanf("%d%s",&n,a);
get_next(a);
for(i = ; i <= n; i ++)
d[i] = ;
d[] = ;
int sum = ;
for(i = ; i <= n; i ++)
{
d[i] = d[next[i]] + ;
sum += d[i]%;
}
printf("%d\n",sum%);
}
return ;
}
哈哈
Description
有n个人准备去逛超市,其中第i个人买东西的概率是Pi 。逛完以后你得知有r个人买了东西,但不知道是哪r个人。请计算每个人实际买了东西的概率。输入n(1≤n≤20)和r(0≤r≤n),
输出每个人实际买了东西的概率。
Input
第一行两个整数n,r
接下来n行,每行一个实数,表示第i个人买东西的概率
Output
N行表示答案,保留3为小数,你的答案必须与标准输出完全一样才能得分
Example
Input
3 2
0.10
0.20
0.30
5 1
0.10
0.10
0.10
0.10
0.10
Output
0.413
0.739
0.848
0.200
0.200
0.200
0.200
0.200
Hint
对于20%的数据,n=2
对于另外30%的数据,n<=20,r=1
对于另外20%的数据,n<=10
对于100%的数据,n<=20,r<=n
你的答案必须与标准输出完全一致才能得分
/*
条件概率额计算
一道条件概率的题:条件概率公式:P(A|B)=P(AUB)/P(B)
简单来说,A在B发生的前提下发生的概率为2个都发生的概率除以B发生的概率。
所以这道题就是每个点发生的概率除以tot(m个人买的概率,不论是哪m个人)的值了。
枚举每个人买不买,把每种情况的概率记录下来,如果刚好m个人买了,那就让tot加这个值,然后这种情况每个买了的人的概率加这个值。
*/
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<iostream> using namespace std;
int n,m;
double bri[],ans[],tot;
int vis[]; void dfs(int i,int use_,double p)
{
if(i>n)
{
if(use_==m)
{
tot+=p;
for(int i=;i<=n;i++)
if(vis[i]) ans[i]+=p;
}
return;
}
vis[i]=;dfs(i+,use_+,p*bri[i]);
vis[i]=;dfs(i+,use_,p*(-bri[i]));
} int main()
{
freopen("haha.in","r",stdin);
freopen("haha.out","w",stdout);
scanf("%d%d",&n,&m);
for(int i=;i<=n;i++) scanf("%lf",&bri[i]);
dfs(,,);
for(int i=;i<=n;i++) printf("%.3lf\n",ans[i]/tot);
fclose(stdin);fclose(stdout);
return ;
}
哈哈哈
Description
有两个长度为 N 的序列 A 和 B,在 A 和 B 中各任取一个数可以得到 N^2 个和,求这N^2 个和中最小的 N个。
Input
一行一个整数n
第二行n个整数ai
第三行n个整数bi
Output
N行表示答案
Example
input
5
1 3 2 4 5
6 3 4 1 7
Output
2 3 4 4 5
Hint
20%的数据,n<=1000
50%的数据,n<=50000
70%的数据,n<=100000
100%的数据,n<=600000
保证答案<max_int
/*
优先队列维护最大的n个和
第一个数组从个头到位扫,动态维护
具体看代码
*/
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue> #define N 200007 using namespace std;
int a[N],b[N],ans[N];
int n,m,cnt,sum;
priority_queue<int>que; inline int read()
{
int x=,f=;char ans=getchar();
while(ans>''||ans<''){if(ans=='-')f=-;ans=getchar();}
while(ans>=''&&ans<=''){x=x*+ans-'';ans=getchar();}
return x*f;
} int main()
{
freopen("hahaha.in","r",stdin);
freopen("hahaha.out","w",stdout);
n=read();
for(int i=;i<=n;i++) a[i]=read();
for(int i=;i<=n;i++) b[i]=read();
sort(a+,a+n+);sort(b+,b+n+);
for(int i=;i<=n;i++)
{
int now_=a[]+b[i];
que.push(now_);
}
for(int i=;i<=n;i++)
for(int j=;j<=n;j++)
{
sum=a[i]+b[j];
if(sum>=que.top()) break;
else
{
que.pop();
que.push(sum);
}
}
for(int i=;i<=n;i++)
{
ans[i]=que.top();
que.pop();
}
for(int i=n;i>=;i--) printf("%d\n",ans[i]);
fclose(stdin);fclose(stdout);
return ;
}
9.28NOIP模拟题的更多相关文章
- poj 1008:Maya Calendar(模拟题,玛雅日历转换)
Maya Calendar Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 64795 Accepted: 19978 D ...
- poj 1888 Crossword Answers 模拟题
Crossword Answers Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 869 Accepted: 405 D ...
- CodeForces - 427B (模拟题)
Prison Transfer Time Limit: 1000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64u Sub ...
- sdut 2162:The Android University ACM Team Selection Contest(第二届山东省省赛原题,模拟题)
The Android University ACM Team Selection Contest Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里 ...
- 全国信息学奥林匹克联赛 ( NOIP2014) 复赛 模拟题 Day1 长乐一中
题目名称 正确答案 序列问题 长途旅行 英文名称 answer sequence travel 输入文件名 answer.in sequence.in travel.in 输出文件名 answer. ...
- UVALive 4222 Dance 模拟题
Dance 题目连接: https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&pag ...
- cdoj 25 点球大战(penalty) 模拟题
点球大战(penalty) Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/problem/show/2 ...
- Educational Codeforces Round 2 A. Extract Numbers 模拟题
A. Extract Numbers Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/600/pr ...
- URAL 2046 A - The First Day at School 模拟题
A - The First Day at SchoolTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudg ...
随机推荐
- 数列分块入门1-9 By hzwer
声明 持续更新,因为博主也是正在学习分块的知识,我很菜的,菜的抠$jio$ 写在前面 分块是个很暴力的算法,但却比暴力优秀的多,分块算法的时间复杂度一般是根号的,他的主要思想是将一个长度是$n$的数列 ...
- 微信小程序支付全问题解决
这几天在做小程序的支付,没有用官方的SDK,这里就纯用官方的文档搞一发. * 注作者使用的PHP,不过支付流程都是这样 开发前必读 主要流程 小程序前端发送求参请求 接受请求封装 "统一下单 ...
- 第十二节:Web爬虫之MongoDB数据库安装与数据存储
MongoDB是一个基于分布式文件存储的数据库.由C++语言编写.旨在为WEB应用提供可扩展的高性能数据存储解决方案. MongoDB是一个介于关系数据库和非关系数据库之间的产品,是非关系数据库当中功 ...
- dstat系统分析工具的使用
1.安装 方法一:yum #yum install -y dstat 方法二:rpm 官网下载地址: http://dag.wieers.com/rpm/packages/dstat #wget ht ...
- opengl 对投影变化函数的理解
投影变化分两种: 1 . 平行投影 2 . 透视投影 投影变化的设置一般放在reshape函数当中调用 每次要对投影变化进行操作的时候我们需要修改矩阵的变化模式,指定它为投影变化 glMa ...
- sdibt 1244类似于拓扑排序
博客:http://blog.csdn.net/mypsq/article/details/39005991 #include<stdio.h> #include<string.h& ...
- tyvj3737 逐个击破
描述 三大战役的平津战场上,傅作义集团在以北平.天津为中心,东起唐山西至张家口的铁路线上摆起子一字长蛇阵,并企图在溃败时从海上南逃或向西逃窜.为了就地歼敌不让其逃走,mzd制定了先切断敌人东洒两头退路 ...
- Self Centos + Windows server 2016
Set up by Derek: 2019-1-25 登陆个人物理机: license 60天Free , 如果过期,就在 VMware ESXI 6.5.0的黑屏界面去reset. https:/ ...
- 使用 IAsyncResult 调用异步方法
.NET Framework 和第三方类库中的类型可以提供允许应用程序在主应用程序线程之外的线程中执行异步操作的同时继续执行的方法.下面几部分介绍了在调用使用 IAsyncResult 设计模式的异步 ...
- HDU1026 Ignatius and the Princess I 【BFS】+【路径记录】
Ignatius and the Princess I Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (J ...