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. 转:Linux字符编码方式

    首先,解释一下字符集: 汉字编码: * GB2312字集是简体字集,全称为GB2312(80)字集,共包括国标简体汉字6763个. * BIG5字集是台湾繁体字集,共包括国标繁体汉字13053个. * ...

  2. 4.JAVA语言基础部分—枚举与泛型

    枚举 //定义枚举 enum MyEnum{ ITEM_A, ITEM_B } public static void main(String[] args) { //values()获取所枚举项的集合 ...

  3. Linux出现cannot create temp file for here-document: No space left on device的问题解决

    在终端输入:cd /ho 按tab键时,显示错误: bash: cannot create temp file for here-document: No space left on device 这 ...

  4. LucaCanali--SystemTap_Linux_IO

    https://github.com/LucaCanali/Linux_tracing_scripts/tree/master/SystemTap_Linux_IO

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

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

  6. scrapy的自动限速(AutoThrottle)扩展

    该扩展能根据Scrapy服务器及您爬取的网站的负载自动限制爬取速度. 设计目标 更友好的对待网站,而不使用默认的下载延迟0. 自动调整scrapy来优化下载速度,使得用户不用调节下载延迟及并发请求数来 ...

  7. Apdex——衡量服务器性能的标准

    Apdex 全称是 Application Performance Index,是由 Apdex 联盟开放的用于评估应用性能的工业标准.Apdex 联盟起源于 2004 年,由 Peter Sevci ...

  8. 79.iOS 设备的UI规范和iOS各控件默认高度

    iOS设备的UI 规范 iPhone界面尺寸 iPhone图标尺寸 iPad的设计尺寸 iPad图标尺寸 iPhone设备尺寸分辨率比例 iPhone各设备 launch image iOS 各种控件 ...

  9. linux下ndk编译命令行程序及配置

    1.在http://developer.android.com/tools/sdk/ndk/index.html下载Android-ndk-r8e-linux-x86.tar.bz2,解压后把andr ...

  10. 怎样求结构体成员的偏移地址 || 结构体的 sizeof 总结

    C 语言中同意将值为 0 的变量强制转换成任一类型的指针,转换结果是一个NULL指针. (type*)0 // 一个 type 类型的NULL指针 用这个指针訪问结构体内的成员是非法的,可是 & ...