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 ...
随机推荐
- UVA-1599 Ideal Path(双向BFS)
题目: 给一个n个点m条边(2≤m≤100000, 1≤m≤200000)的无向图,每条边上都涂有一种颜色(用1到1000000000表示).求从结点1到结点n的一条路径, 使得经过的边数尽量少,在此 ...
- uva-122 Trees on the level(树的遍历)
题目: 给出一棵树的表示,判断这棵树是否输入正确,如果正确就按层次遍历输出所有的结点,错误的话就输出not complete. 思路: 根据字符串中树的路径先将树建起来,在增加结点和层次遍历树的时候判 ...
- IDLE in Python (Ubuntu)
To lauch IDLE in the Current Woking Directory >>> usr/bin/idle3 Alt + n # next command Alt ...
- SQL Server 机考,用T-SQL编写 简单实例
使用T-SQL实现以下要求: 要求如下: 1,添加数据库:MySchool 2,添加学生基础表:Student 3,添加学生成绩表:ScoreInfo 4,两张表结构分别如下 Student表结构:( ...
- UVALive 6510 Stickers
Stickers Time Limit: 3000ms Memory Limit: 131072KB This problem will be judged on UVALive. Original ...
- noip模拟赛 第K小数
[问题描述]有两个正整数数列,元素个数分别为N和M.从两个数列中分别任取一个数相乘,这样一共可以得到N*M个数,询问这N*M个数中第K小数是多少.[输入格式]输入文件名为number.in.输入文件包 ...
- poj 2112
#include <cstdio> #include <cstring> ;//点数的最大值 ;//边数的最大值 const int INF=0x3fffffff; struc ...
- QT .pro文件的学习收获
1. 载pro文件预定义宏: CONFIG(debug,debug|release){ DEFINES+=__DEBUG__ }else{ DEFINES+=__RELEASE__ macx:DEST ...
- - > 贪心基础入门讲解四——独木舟问题
n个人,已知每个人体重,独木舟承重固定,每只独木舟最多坐两个人,可以坐一个人或者两个人.显然要求总重量不超过独木舟承重,假设每个人体重也不超过独木舟承重,问最少需要几只独木舟? 分析: 一个显然的策略 ...
- BP神经网络及其在教学质量评价中 的应用
本文学习笔记是自己的理解,如有错误的地方,请大家指正批评.共同进步.谢谢! 之前的教学质量评价,仅仅是通过对教学指标的简单处理.如求平均值或人为的给出各指标的权值来加权求和,其评价结果带有非常大主观性 ...