10.30 afternoon
P76
竞赛时间: ????年??月??日??:??-??:??
题目名称 | 他 | 她 | 它 |
名称 | he | she | it |
输入 | he.in | she.in | it.in |
输出 | he.out | she.out | it.out |
每个测试点时限 | 1 秒 | 1 秒 | 1 秒 |
内存限制 | 512MB | 512MB | 512MB |
测试点数目 | 10 | 10 | 10 |
每个测试点分值 | 10 | 10 | 10 |
是否有部分分 | 无 | 无 | 无 |
题目类型 | 传统 | 传统 | 传统 |
他
【问题描述】
一张长度为N的纸带, 我们可以从左至右编号为0 − N( 纸带最左端标号为
0)。 现在有M次操作, 每次将纸带沿着某个位置进行折叠, 问所有操作之后纸带
的长度是多少。
【输入格式】
第一行两个数字N, M如题意所述。
接下来一行M个整数代表每次折叠的位置。
【输出格式】
一行一个整数代表答案。
【样例输入】
5 2
3 5
【样例输出】
2
【样例解释】
树上有只鸟。
【数据规模与约定】
对于60%的数据, N, M ≤ 3000。
对于100%的数据, N ≤ 10^18, M ≤ 3000。
暴力60
- /*暴力60 似乎离散化一下好的多...考试的时候没时间了23333*/
- #include<cstdio>
- #define maxn 3010
- using namespace std;
- int n,m,a[maxn],x,P[maxn],c[maxn][maxn],f[maxn][maxn];
- int init(){
- int x=,f=;char s=getchar();
- while(s<''||s>''){if(s=='-')f=-;s=getchar();}
- while(s>=''&&s<=''){x=x*+s-'';s=getchar();}
- return x*f;
- }
- int max(int x,int y){
- return x>y?x:y;
- }
- int main()
- {
- freopen("he.in","r",stdin);
- freopen("he.out","w",stdout);
- n=init();m=init();
- for(int i=;i<=n;i++)
- c[i][++c[i][]]=i,P[i]=i;
- int p,s1,s2,len=n;
- while(m--){
- x=init();p=P[x];
- s1=p;s2=len-p;
- if(s1<s2){
- for(int i=p+,k=p-;k>=;i++,k--)
- for(int j=;j<=c[k][];j++)
- c[i][++c[i][]]=c[k][j];
- for(int i=p,k=;i<=len;i++,k++){
- c[k][]=;
- for(int j=;j<=c[i][];j++){
- c[k][++c[k][]]=c[i][j];
- P[c[i][j]]=k;
- }
- }
- }
- else{
- for(int i=p+,k=p-;i<=len;i++,k--)
- for(int j=;j<=c[i][];j++){
- c[k][++c[k][]]=c[i][j];
- P[c[i][j]]=k;
- }
- }
- len=max(s1,s2);
- }
- printf("%d\n",len);
- return ;
- }
离线就100....
- /*离散化.... 考试的时候脑抽拿n直接做的*/
- #include<cstdio>
- #define ll long long
- #define maxn 3010
- #ifdef unix
- #define LL "%lld\n"
- #else
- #define LL "%I64d\n"
- #endif
- using namespace std;
- ll n,m,a[maxn],c[maxn];
- ll init(){
- ll x=,f=;char s=getchar();
- while(s<''||s>''){if(s=='-')f=-;s=getchar();}
- while(s>=''&&s<=''){x=x*+s-'';s=getchar();}
- return x*f;
- }
- ll max(ll x,ll y){
- return x>y?x:y;
- }
- ll min(ll x,ll y){
- return x<y?x:y;
- }
- int main()
- {
- freopen("he.in","r",stdin);
- freopen("he.out","w",stdout);
- n=init();m=init();
- for(int i=;i<=m;i++)
- c[i]=init();
- for(int p=;p<=m;p++){
- ll P=c[p],mi=P*-n;//这个才是右端点 不是P*2-c[m]233s
- ll s1=P,s2=n-P;n=max(s1,s2);
- for(int i=;i<=m;i++)
- if(c[i]>P)c[i]=*P-c[i];
- if(mi<)for(int i=;i<=m;i++)
- c[i]-=mi;
- }
- printf(LL,n);
- return ;
- }
她
【问题描述】
给你M, S, L, R, 求满足L ≤ (S × x) mod M ≤ R最小的正整数x。
【输入格式】
第一行一个数T代表数据组数。
接下来T行每行四个数代表该组数据的M, S, L, R。
【输出格式】
对于每组数据, 输出一行代表答案。 如果不存在解, 输出“ −1”。
【样例输入】
1
5 4 2 3
【 样例输出】
2
【 样例解释】
叫南小鸟。
【数据规模与约定】
对于30%的数据, 保证有解且答案不超过10^6。
对于另外20%的数据, L = R。
对于100%的数据, 1 ≤ T ≤ 100,0 ≤ M, S, L,R ≤ 10^9。
暴力50
- /*这题无了语了 本来50来 想了想 嗯都用gcd搞吧 可能快点 然后就20了*/
- #include<iostream>
- #include<cstdio>
- #define maxn 1000000
- #define ll long long
- #define inf 1e9+10
- using namespace std;
- ll T,M,S,L,R,x,y,gcd,ans;
- ll init(){
- ll x=,f=;char s=getchar();
- while(s<''||s>''){if(s=='-')f=-;s=getchar();}
- while(s>=''&&s<=''){x=x*+s-'';s=getchar();}
- return x*f;
- }
- ll min(ll x,ll y){
- return x<y?x:y;
- }
- void Cl(){
- ans=inf;x=;y=;gcd=;
- }
- void Gcd(ll a,ll b){
- if(b==){x=;y=;gcd=a;}
- else{
- Gcd(b,a%b);
- ll tmp=x;x=y;y=tmp-a/b*y;
- }
- }
- void Solve1(){
- if(S%M==){
- ans=-;return;
- }
- Gcd(S,M);int r=,falg=;
- for(int c=L;c<=R;c++){
- if(c%gcd)continue;
- ll tmp=x*c/gcd;r=M/gcd;
- tmp=(tmp%r+r)%r;falg=;
- if(tmp==)tmp+=r;
- ans=min(ans,tmp);
- }
- if(falg==)ans=-;
- }
- void Solve2(){
- if(S%M==){
- ans=-;return;
- }
- int falg=;
- for(x=;x<=;x++){
- ll r=(S*x)%M;
- if(r>=L&&r<=R){
- falg=;break;
- }
- }
- if(falg)ans=x;
- else ans=-;
- }
- int main()
- {
- freopen("she.in","r",stdin);
- freopen("she.out","w",stdout);
- T=init();
- while(T--){
- M=init();S=init();
- L=init();R=init();
- Cl();
- if(R==L)Solve1();
- else Solve2();
- cout<<ans<<endl;
- }
- return ;
- }
正解嘛 你猜
它
【问题描述】
N个人坐成一圈, 其中第K个人拿着一个球。 每次每个人会以一定的概率向
左边的人和右边的人传球。 当所有人都拿到过球之后, 最后一个拿到球的人即为
胜者。 求第N个人获胜的概率。( 所有人按照编号逆时针坐成一圈)
【输入格式】
第一行一个数T代表数据组数。
对于每组数据, 第一行两个整数N, K如题意所述。
接下来每行一个实数p代表该人将球传给右边的人的概率。
【输出格式】
对于每组数据, 一行一个实数代表答案, 保留9位小数。
【样例输入】
1
5 1
0.10
0.20
0.30
0.40
0.50
【 样例输出】
0.007692308
【 样例解释】
然后鸟是我的。
【数据规模与约定】
对于20%的数据, N ≤ 3。
对于70%的数据, T, N ≤ 100。
对于100%的数据, T ≤ 10000,1 ≤ N ≤ 100。
Orz...
- /*还有待研究2333*/
- #include<cstdio>
- #define maxn 110
- #define ld long double
- using namespace std;
- int T,n,k,a[maxn],b[maxn];
- ld p[maxn],q[maxn],P,Q,ans;
- void Cal(int m){
- /*int l=a[m],r=b[m];
- q[l]=(q[m]*q[l])/(1-q[m]*p[l]);
- p[l]=1-q[l];
- p[r]=(p[m]*p[r])/(1-p[m]*q[r]);
- q[r]=1-p[r];
- b[l]=r;a[r]=l;*/
- int l=a[m],r=b[m];
- long double pa=p[l],pb=p[m],pc=p[r];
- p[l]=pa*pb/(-pa*(-pb));q[l]=-p[l];
- q[r]=(-pc)*(-pb)/(-pb*(-pc));p[r]=-q[r];
- b[l]=r;a[r]=l;
- }
- int main()
- {
- freopen("it.in","r",stdin);
- freopen("it.out","w",stdout);
- scanf("%d",&T);
- while(T--){
- scanf("%d%d",&n,&k);
- for(int i=;i<=n;i++){
- scanf("%llf",&p[i]);
- q[i]=-p[i];
- a[i]=i-;b[i]=i+;
- }
- a[]=n;b[n]=;
- if(n==)ans=;
- else if(n==)k==?-q[]:-p[];
- else if(k==){
- for(int i=;i<n-;i++)Cal(i);ans=-q[];
- }
- else if(k==n-){
- for(int i=;i<n-;i++)Cal(i);ans=-p[n-];
- }
- else {
- for(int i=;i<k;i++)Cal(i);
- for(int i=k+;i<n;i++)Cal(i);
- ans=q[k]*p[]+q[n-]*p[k];
- }
- printf("%.9f\n",double(ans));
- }
- return ;
- }
10.30 afternoon的更多相关文章
- gnuWin32-mini-2016.10.30
2016-10-28 04:48 1,017,856 awk.exe ver 4.1.4 2016-10-29 00:26 77,312 bc.exe ver 1.06 2016-10-30 01:4 ...
- 背水一战 Windows 10 (30) - 控件(文本类): AutoSuggestBox
[源码下载] 背水一战 Windows 10 (30) - 控件(文本类): AutoSuggestBox 作者:webabcd 介绍背水一战 Windows 10 之 控件(文本类) AutoSug ...
- 2016.10.30 NOIP模拟赛 day2 PM 整理
满分:300分 直接全部爆零,真的是很坑啊! 10.30的题目+数据:链接:http://pan.baidu.com/s/1jHXLace 密码:i784 T1: 题目中的难点就是每次折叠的点可能应经 ...
- 10.30 正睿停课训练 Day12
目录 2018.10.30 正睿停课训练 Day12 A 强军战歌(DP 树状数组 容斥) B 当那一天来临(思路) C 假如战争今天爆发(贪心) 考试代码 B C 2018.10.30 正睿停课训练 ...
- 第18次Scrum会议(10/30)【欢迎来怼】
一.小组信息 队名:欢迎来怼小组成员队长:田继平成员:李圆圆,葛美义,王伟东,姜珊,邵朔,冉华 小组照片 二.开会信息 时间:2017/10/30 17:19~17:38,总计19min.地点:东北师 ...
- 2016.10.30 NOIP模拟赛 day2 AM 整理
题目+数据:链接:http://pan.baidu.com/s/1gfBg4h1 密码:ho7o 总共得了:130分, 1:100分 2:30分(只会这30分的暴力) 3:0(毫无思路) 虽然不高, ...
- [软件工程基础]2017.10.30 第三次 Scrum 会议
决议 游心与李煦通沟通生成报告脚本问题,并调试相应代码 李煦通部署服务器,并做一定安全检查 石奇川设计实验流程和题库前端页面 王嘉睿爵测试网站基本流程,提出关于用户体验方面的建议 刘子渊阅读代码,为机 ...
- sql 从未连续的Id中选择10~30条数据
select * from(select *,row_number()over(order by ProductID) as num from Products) as t where t.num&g ...
- Fifth scrum meeting - 2015/10/30
概述 从昨天开始,我们的开发工作终于进入了正轨,由于之前没有mooc服务器API接口,一些工作无法进行. 因为我们团队开始开发较晚,因此我们将开发阶段的截至时间定为了下周五,测试阶段则压缩为下周周六和 ...
随机推荐
- property测试代码:
// // main.m // TestVar2 // // Created by lishujun on 14-9-4. // Copyright (c) 2014年 lishujun. All r ...
- spoj gss2 : Can you answer these queries II 离线&&线段树
1557. Can you answer these queries II Problem code: GSS2 Being a completist and a simplist, kid Yang ...
- UIWebView 自定义网页中的alert和confirm提示框风格
.h #import <UIKit/UIKit.h> @interface UIWebView (JavaScriptAlert) -(void)webView:(UIWebView *) ...
- Java语言基础(一) 标识符
Java标识符的问题: ①不可以以数字开头 int 123number = 0; //错误 ②可以使用任意的货币符号(¥和$等等)中文也可以 int $i = 0; //正确 int ¥i = 1; ...
- Silicon Labs电容式触摸感应按键技术原理及应用
市场上的消费电子产品已经开始逐步采用触摸感应按键,以取代传统的机械式按键.针对此趋势,Silicon Labs公司推出了内置微控制器(MCU)功能的电容式触摸感应按键(Capacitive Touch ...
- Delphi的Owner与Parent可以不一致,而且Owner不是必须存在(一共7个问题) good
问题1:Owner与Parent不一致:新建一个Form,上面放一个Button1,一个Panel1,然后在Panel1上再放一个Button2,测试结果:procedure TForm1.Butto ...
- 在前台运行Service
一个前台的 service是被用户强烈关注的从而不会在内存低时被系统杀死.前台 service必须在状态栏上提供一个通知,这个通知被放在"正在进行"区域中,这表示这个通知不能被解除,除非服务停止了或者 ...
- Python 入门教程 10 ---- Student Becomes the Teacher
第一节 1 练习 1 设置三个的字典分别为lloyd,alice,tyler 2 对每一个的字典的key都设置为"name","homework" , &quo ...
- rt: Unknown command 'PATH='
- C++中new和malloc
1.malloc的工作原理: malloc使用一个数据结构(链表)来维护分配空间链表的构成:分配的空间/上一个空间的数据/下一个空间/空间大小等信息. 对malloc分配的空间不要越界访问,因为 ...