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. 51 NOD 1325 两棵树的问题

    Discription 对于 100% 的数据, N<=50. solution: 发现N比较小,所以我们可以花O(N^2)的代价枚举两颗树的联通块的LCA分别是哪个点,然后现在问题就变成了:选 ...

  2. Go -- 实现二叉搜索树

    树: https://suanfa.herokuapp.com/3%E6%A0%91/binarytree/ 数据结构 首先我们定义需要的数据结构.注意,TreeNode的左右节点都是*TreeNod ...

  3. JavaScript 层

    代码Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--& ...

  4. iOS10你掉坑了吗?

    坑1: 系统导航栏上按键消失问题 坑2: canOpenURL 调用返回NO问题 坑3: iOS10 权限崩溃问题 坑4: xib不好用了?别怕看这里! 坑5: command +/注释失效 坑6: ...

  5. vim中末行去掉^M

    在Ubuntu系统中打开文件,发现文件中每一个末行都有^M,我们要做的是知道这一个无关的字符是什么作用,然后删除掉这一个无关的字符. 工具/原料   ubuntu操作系统 Vim编辑器 方法/步骤   ...

  6. 基于社交网络的情绪化分析IV

    基于社交网络的情绪化分析IV By 白熊花田(http://blog.csdn.net/whiterbear) 转载需注明出处,谢谢. 前面进行了微博数据的抓取,简单的处理,类似度分析.后面两篇进行学 ...

  7. Linux C++的多线程编程(转)

    1. 引言 线程(thread)技术早在60年代就被提出,但真正应用多线程到操作系统中去,是在80年代中期,solaris是这方面的佼佼者.传统的Unix也支持线程的概念,但是在一个进程(proces ...

  8. HDU 2317 Nasty Hacks

    Nasty Hacks Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Tota ...

  9. js 类继承extends

    先看例子: <!DOCTYPE html><html> <head> <meta charset="UTF-8"> <titl ...

  10. wamp配置虚拟域名

    1.打开apache下httpd.conf 我的目录是在F:\wamp\bin\apache\apache2.2.22\conf\httpd.conf 2.去掉这两行前面的#注释 LoadModule ...