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 ...
随机推荐
- 55.fielddata内存控制以及circuit breaker断路器
课程大纲 fielddata加载 fielddata内存限制 监控fielddata内存使用 circuit breaker 一.fielddata加载 fielddata加载到内存的过程是lazy加 ...
- Django-REST-Framework JWT 实现SSO认证(下)
在上一篇博客中,我已经对JSON Web 认证做了简单的解释,这篇博客是续篇,若不了解,请看上一篇博客:https://www.cnblogs.com/yushenglin/p/10863184.ht ...
- Python基础之函数参数与返回值进阶
参数作用:如果外界希望在函数内部处理数据,就可以将数据作为参数传入函数内部: 返回值作用:如果希望一个函数函数执行完成后,向外界报告函数的执行结果,就可以使用函数的返回值. 函数的返回值 进阶 利用元 ...
- Java8-如何将List转变为逗号分隔的字符串--https://blog.csdn.net/benjaminlee1/article/details/72860845
Java8-如何将List转变为逗号分隔的字符串 https://blog.csdn.net/benjaminlee1/article/details/72860845
- Spring的发展【一】
1.1. Spring1.x 时代 在Spring1.x时代,都是通过xml文件配置bean,随着项目的不断扩大,需要将xml配置分放到不同的配置文件中,需要频繁的在java类和xml配置文件中切换. ...
- 如何高效读写百万级的Excel?
高效读取百万级数据 接上一篇介绍的高效写文件之后,最近抽时间研究了下Excel文件的读取.概括来讲,poi读取excel有两种方式:用户模式和事件模式. 然而很多业务场景中的读取Excel仍然采用用户 ...
- Holedox Eating HDU4302 模拟
Problem Description Holedox is a small animal which can be considered as one point. It lives in a st ...
- HashMap源码分析2:扩容
本文源码基于JDK1.8.0_45. final Node<K,V>[] resize() { Node<K,V>[] oldTab = table; int oldCap = ...
- css3的高级而有用且很少人知道的属性和样式
1.-webkit-mask 概属性可以给一个元素添加蒙层,蒙层可以是一个渐变或者半透明的png图片,这张png图片的 alpha 为 0 的位置会不显示元素这部分,alpha 为 1 的位置会显示元 ...
- Oracle Multitenant Environment (四) Create One or More CDBs
Using the CREATE DATABASE Statement to Create a CDB This section describes creating a CDB using the ...