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. Codeforces 123 E Maze

    Discription A maze is represented by a tree (an undirected graph, where exactly one way exists betwe ...

  2. BUPT复试专题—比较奇偶数(2010)

    https://www.nowcoder.com/practice/188472f474d5421cb8218b8ad561023b?tpId=67&tqId=29636&rp=0&a ...

  3. zedboard中OLED源码

    #include <stdio.h> #include "platform.h" #include "xil_types.h" #include & ...

  4. HDU 1312 Red and Black 第一题搜索!

    Red and Black Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tot ...

  5. RecyclerViewDemo

    https://github.com/eltld/RecyclerViewDemo

  6. VUE清除组件内部定时器

    定时器如果不手动清除,只会在离开当前页面或者F5刷新后才会清除.由于vue项目是SPA应用,离开当前组件后并不会清除定时器,所以需要我们手动去清除定时器.但当我们将清除定时器clearInterval ...

  7. startActivity、 startActivityForResult 、广播的使用

    前言 近期忙着跟项目.好久没有写文字了.今天一个群里面的童鞋问到一个关于不同界面间传值的问题,借这个背景,写一段关于" startActivity. startActivityForResu ...

  8. 项目Beta冲刺(团队4/7)

    项目Beta冲刺(团队4/7) 团队名称: 云打印 作业要求: 项目Beta冲刺(团队) 作业目标: 完成项目Beta版本 团队队员 队员学号 队员姓名 个人博客地址 备注 221600412 陈宇 ...

  9. Comparing Random and Sequential Access in Disk and Memory

    The Pathologies of Big Data - ACM Queue https://queue.acm.org/detail.cfm?id=1563874

  10. Spring Boot 访问静态资源

    方法1一: 在resources目录下建立static的目录,将静态资源放到此处,可以直接访问 访问:127.0.0.1:9010/img/123.png