Mister B and Book Reading 

O(n)暴力即可

#include<bits/stdc++.h>
using namespace std;
typedef long long int LL;
const LL N=1,M=1,MOD=1; int main()
{//freopen("t.txt","r",stdin);
int c,v0,v1,a,l;
scanf("%d%d%d%d%d",&c,&v0,&v1,&a,&l);
int nv=0,nr=v0;
int ans=0;
while(nv<c)
{
nv+=v0;
ans++;
if(nv>=c){printf("%d\n",ans);return 0;}
v0+=a;
v0=min(v0,v1);
nv-=l;
nv=max(0,nv);
}
return 0;
}

Mister B and Angle in Polygon

把正n边形放到圆内看,每个边的圆周角是相等的。剩下的,大家都懂。

做了这么多年题第一次碰到考平面几何的。。。。

#include <iostream>

int main(){
int N,A;
std::cin>>N>>A;
std::cout<<"2 1 "<<std::max(3,std::min(N,(N*A+90)/180+2))<<std::endl;
return 0;
}

  

Mister B and Boring Game

又是一道BUG题 老哥走点心吧。。 略过

#include <stdio.h>
#include <algorithm>
using namespace std; int a, b, st, en; int tag(int k) {
int rlt = (k - 1) / (a + b);
if ((k - 1) % (a + b) < a) return rlt * 2 + 1;
return rlt * 2 + 2;
} int solve(int st, int en) {
int u = tag(st), v = tag(en);
if (v > u + 4) return max(a + 1, 2 * a - b);
if (v == u) return u & 1 ? en - st + 1 : 1;
if (v == u + 1) return u & 1 ? a - ((st - 1) % (a + b)) : ((en - 1) % (a + b)) + 2;
if (v == u + 2) {
int x = a - ((st - 1) % (a + b)), y = (en - 1) % (a + b) + 1;
return u & 1 ? max(min(x + y, a), max(x, y + min(x, a - b))) : a + 1;
}
return max(solve(a * (tag(st) & 1) + 1 + (a + b) * (tag(st) >> 1), en), solve(st, (a + b) * ((tag(en) - 1) >> 1) + a * ((tag(en) - 1) & 1)));
} int main() {
scanf("%d %d %d %d", &a, &b, &st, &en);
printf("%d\n", solve(st, en));
return 0;
}

  

Mister B and PR Shifts

考虑对于每一个数可以预知在右移某些步数的范围内使答案变好,其余范围使答案不变或者变差,于是可以用线段树维护,然后求和。

但是n有100w  时限只有2s O(nlogn)可能超时 应该有O(n)的算法。

由于在询问之前给出了所有数值信息,即不需动态维护线段。

所以用线段树是大材小用了,直接维护即可。复杂度O(n)注意边界情况要特殊判断。

#include <bits/stdc++.h>

using namespace std;

int n, ta, tb, md;
long long mi = LLONG_MAX, cur, cs, dx[2000005], add[2000005]; int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d", &ta);
cur += abs(ta - i);
dx[(ta - i + n) % n] += 2;
dx[(1 - i + n) % n] -= 2;
add[n-i] += abs(ta - 1) - (abs(ta - n) + 1);
if ((1 - i + n) % n <= (ta - i + n) % n)
cs++;
else
cs--;
}
for (int i = 0; i < n; i++) {
if (cur < mi)
mi = cur, md = i;
cs += dx[i];
cur += cs + add[i];
}
printf("%lld %d\n", mi, md);
return 0;
}

  

Mister B and Beacons on Field

codeforces round 421 div2 补题 CF 820 A-E的更多相关文章

  1. codeforces round 422 div2 补题 CF 822 A-F

    A I'm bored with life 水题 #include<bits/stdc++.h> using namespace std; typedef long long int LL ...

  2. Codeforces round 419 div2 补题 CF 816 A-E

    A Karen and Morning 水题 注意进位即可 #include<bits/stdc++.h> using namespace std; typedef long long i ...

  3. codeforces round 418 div2 补题 CF 814 A-E

    A An abandoned sentiment from past 水题 #include<bits/stdc++.h> using namespace std; int a[300], ...

  4. codeforces round 417 div2 补题 CF 812 A-E

    A Sagheer and Crossroads 水题略过(然而被Hack了 以后要更加谨慎) #include<bits/stdc++.h> using namespace std; i ...

  5. codeforces round 416 div2 补题 CF 811 A B C D E

    A. Vladik and Courtesy 水题略过 #include<cstdio> #include<cstdlib> #include<cmath> usi ...

  6. codeforces round 420 div2 补题 CF 821 A-E

    A Okabe and Future Gadget Laboratory 暴力 #include<bits/stdc++.h> using namespace std; typedef l ...

  7. Educational Codeforces Round 23 A-F 补题

    A Treasure Hunt 注意负数和0的特殊处理.. 水题.. 然而又被Hack了 吗的智障 #include<bits/stdc++.h> using namespace std; ...

  8. codeforces 447 A-E div2 补题

    A DZY Loves Hash 水题 #include<iostream> #include<cstdio> #include<cstdlib> #include ...

  9. 【前行】◇第3站◇ Codeforces Round #512 Div2

    [第3站]Codeforces Round #512 Div2 第三题莫名卡半天……一堆细节没处理,改一个发现还有一个……然后就炸了,罚了一啪啦时间 Rating又掉了……但是没什么,比上一次好多了: ...

随机推荐

  1. python3.x对python2.x变动

    原文地址:http://rookiedong.iteye.com/blog/1185403 python 2.4 与 python 3.0 的比较 一. print 从语句变为函数 原:     pr ...

  2. noip2013华容道

    题目描述 [问题描述] 小 B 最近迷上了华容道,可是他总是要花很长的时间才能完成一次.于是,他想到用编程来完成华容道:给定一种局面, 华容道是否根本就无法完成,如果能完成, 最少需要多少时间. 小 ...

  3. IntelliJ IDEA常用统一设置(Linux/Mac/Windows)

    前言:如果说VS是宇宙超级无敌第一大开发工具,那么IDEA是当之无愧的第二大开发工具,将来有机会把VS干掉. 说明:除了以下说明的配置地方外,其它尽量保持默认,这样有利于团队代码风格的统一. 运行VM ...

  4. UNIDAC如何驱动MSSQL2000

    UNIDAC如何驱动MSSQL2000 如下图,PROVIDER必须设置为PRSQL.默认的PRAUTO,如果操作系统是XP可以,如果是WIN7以上的,不可以. 原因是MSSQL NATIVE 11已 ...

  5. 【c专家编程】分析c语言的声明

    联合: 在结构中,每个成员依次存储,而在联合中,所有成员都从偏移地址零开始存储,联合一般被用来节省空间,用法和struct相同. union bits32_tag { int whole; // 一个 ...

  6. [转]文件IO详解(二)---文件描述符(fd)和inode号的关系

    原文:https://www.cnblogs.com/frank-yxs/p/5925563.html 文件IO详解(二)---文件描述符(fd)和inode号的关系 ---------------- ...

  7. Solidworks工程图 如何绘制向视图,辅助视图

    先画一条垂直于视野方向的中心线   点击辅助视图,然后点选刚才的中心线即可生成向视图   对向视图的标准可以得到一些用其他方法不好标注的尺寸            

  8. vmware下安装mac os虚拟机问题,最后还是最终攻克了被一个小失误给陷害了

    今天决定来体验一下苹果系统.虚拟机文件大概用了一天半时间才下载完毕,解压后是39G大小,赶紧安装VMWARE.然后载入虚拟机文件体验.開始当我苹果标志出来的时候,我以为成功了.但是那个小齿轮一直在转, ...

  9. 《Deep Learning》全书已完稿_附全书电子版

    Deep Learning第一篇书籍最终问世了.站点链接: http://www.deeplearningbook.org/ Bengio大神的<Deep Learning>全书电子版在百 ...

  10. DW 表格与表单

    CSS样式表