链接:https://codeforces.com/contest/1100


A - Roman and Browser - [暴力枚举]

题意:浏览器有 $n$ 个网页,编号 $1 \sim n$,选择一个整数 $b$,则关掉所有编号为 $b + i \cdot k$ 的网页,其中 $k$ 为给定的整数,$i$ 为任意整数。然后,留下的网页有两种类型,计算两种类型的网页数目差,要求你给出这个差最大可以是多少。

题解:$n$ 的范围很小,可以直接纯暴力做即可。

AC代码:

#include<bits/stdc++.h>
using namespace std;
const int maxn=;
int n,k;
int type[maxn],del[maxn];
int main()
{
ios::sync_with_stdio();
cin.tie(), cout.tie(); cin>>n>>k;
for(int i=;i<=n;i++) cin>>type[i];
int ans=;
for(int b=;b<=k;b++)
{
memset(del,,sizeof(int)*(n+));
for(int i=b;i<=n;i+=k) del[i]=;
int c1=, c2=;
for(int i=;i<=n;i++) if(!del[i]) c1+=(type[i]==), c2+=(type[i]==-);
ans=max(ans,abs(c1-c2));
}
cout<<ans<<endl;
}

B - Build a Contest - [计数+简单维护][线段树]

题意:有一个“问题池”,每次都想一个新问题,估计其难度为 $x (1 \le x \le n)$,把这个问题扔进问题池,如果问题池内的问题正好能搞出一套难度系数为 $1 \sim n$ 的 $n$ 道题,就把他们全部取出来。对每次想出来的新问题,确定其扔进池中后,能否产生一套题。

题解1:不难知道,用一个数组 $c[1:n]$ 存储每个难度的题目数,再用一个变量 $cnt$ 记录有多少个难度上是有题目的。如果产生了一套题目,必然是某一个难度的题的数目从 $0$ 变成了 $1$。这样做是 $O(m)$ 的时间复杂度。

AC代码:

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+;
int n,m;
int cnt,c[maxn];
int main()
{
ios::sync_with_stdio();
cin.tie(), cout.tie(); cin>>n>>m;
cnt=;
for(int i=,p;i<=m;i++)
{
cin>>p;
c[p]++;
if(c[p]==)
{
cnt++;
if(cnt==n)
{
cout<<;
for(int k=;k<=n;k++) if((--c[k])==) cnt--;
}
else cout<<;
}
else cout<<;
}
}

题解2:无脑上线段树,单点修改、区间查询,如果产生了一套题目,就暴力的对每个难度点上都减去 $1$,时间复杂度是 $O(mlogn)$(因为最多产生 $O(m/n)$ 套题目)。

AC代码:

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+;
int n,m;
int cnt; #define ls (rt<<1)
#define rs (rt<<1|1)
struct Node{
int l,r;
int val,ok;
}o[maxn<<];
void pushup(int rt)
{
o[rt].val=o[ls].val+o[rs].val;
o[rt].ok=o[ls].ok&o[rs].ok;
}
void build(int rt,int l,int r)
{
o[rt].l=l, o[rt].r=r;
if(l==r)
{
o[rt].val=o[rt].ok=;
return;
}
int mid=(l+r)>>;
build(ls,l,mid), build(rs,mid+,r);
pushup(rt);
}
void update(int rt,int pos,int val)
{
if(o[rt].l==o[rt].r)
{
o[rt].val+=val;
o[rt].ok=o[rt].val>;
return;
}
int mid=(o[rt].l+o[rt].r)>>;
pos<=mid?update(ls,pos,val):update(rs,pos,val);
pushup(rt);
} int main()
{
ios::sync_with_stdio();
cin.tie(), cout.tie(); cin>>n>>m;
build(,,n); cnt=;
for(int i=,p;i<=m;i++)
{
cin>>p;
update(,p,);
if(o[].ok)
{
cout<<;
for(int k=;k<=n;k++) update(,k,-);
}
else cout<<;
}
}

C - NN and the Optical Illusion - [很水的计算几何题]

题意:给出一个圆,半径为 $r$,其周围有 $n$ 个完全相同的圆将其包围,这 $n$ 个圆分别和中心圆互相紧贴,且这 $n$ 个圆构成一个环,环上任意两个相邻的圆也都是紧贴的。要求你求出这 $n$ 个圆的半径 $R$。

题解:$\sin(\frac{\pi}{n}) \cdot (R+r) = R$。

AC代码:

#include<bits/stdc++.h>
using namespace std;
const double pi=acos(-);
int n;
double r,R;
int main()
{
cin>>n>>r;
R=sin(pi/n)*r;
R/=(-sin(pi/n));
printf("%.8f\n",R);
}

D - Dasha and Chess - []

题意:

Codeforces 1100 - A/B/C/D/E/F - (Undone)的更多相关文章

  1. Codeforces 1132 - A/B/C/D/E/F - (Undone)

    链接:http://codeforces.com/contest/1132 A - Regular Bracket Sequence - [水] 题解:首先 "()" 这个的数量多 ...

  2. Codeforces 1114 - A/B/C/D/E/F - (Undone)

    链接:http://codeforces.com/contest/1114 A - Got Any Grapes? 题意:甲乙丙三个人吃葡萄,总共有三种葡萄:绿葡萄.紫葡萄和黑葡萄,甲乙丙三个人至少要 ...

  3. Codeforces 1043 - A/B/C/D/E/F - (Undone)

    链接:http://codeforces.com/contest/1043 A - Elections - [水水水水题] 题意: 我和另一个人竞争选举,共有 $n$ 个人投票,每个人手上有 $k$ ...

  4. Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings

    Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings 题目连接: http://cod ...

  5. Educational Codeforces Round 71 (Rated for Div. 2)-F. Remainder Problem-技巧分块

    Educational Codeforces Round 71 (Rated for Div. 2)-F. Remainder Problem-技巧分块 [Problem Description] ​ ...

  6. Codeforces 1100 F - Ivan and Burgers

    F - Ivan and Burgers 思路:线性基+贪心,保存线性基中每一位的最后一个 代码: #pragma GCC optimize(2) #pragma GCC optimize(3) #p ...

  7. Codeforces Bubble Cup 8 - Finals [Online Mirror] F. Bulbo DP

    F. Bulbo Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/575/problem/F Des ...

  8. Codeforces 1154 - A/B/C/D/E/F/G - (Undone)

    链接:https://codeforces.com/contest/1154 A - Restoring Three Numbers - [水] #include<bits/stdc++.h&g ...

  9. Educational Codeforces Round 58 (Rated for Div. 2) F dp + 优化(新坑) + 离线处理

    https://codeforces.com/contest/1101/problem/F 题意 有n个城市,m辆卡车,每辆卡车有起点\(s_i\),终点\(f_i\),每公里油耗\(c_i\),可加 ...

随机推荐

  1. JDBC告警系列(一)The server time zone value 'ÖÐ' is unrecognized or represents more than one time zone.

    一.现象 java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents ...

  2. 生成建表脚本up_CreateTable

    已经很久没用使用这个脚本了,今天用到,并做修改,增加了生成扩展属性功能. Go if object_ID('[up_CreateTable]') is not null Drop Procedure ...

  3. 转 Java虚拟机5:Java垃圾回收(GC)机制详解

    转 Java虚拟机5:Java垃圾回收(GC)机制详解 Java虚拟机5:Java垃圾回收(GC)机制详解 哪些内存需要回收? 哪些内存需要回收是垃圾回收机制第一个要考虑的问题,所谓“要回收的垃圾”无 ...

  4. CNN(卷积神经网络)、RNN(循环神经网络)、DNN,LSTM

    http://cs231n.github.io/neural-networks-1 https://arxiv.org/pdf/1603.07285.pdf https://adeshpande3.g ...

  5. 【原创 Hadoop&Spark 动手实践 4】Hadoop2.7.3 YARN原理与动手实践

    简介 Apache Hadoop 2.0 包含 YARN,它将资源管理和处理组件分开.基于 YARN 的架构不受 MapReduce 约束.本文将介绍 YARN,以及它相对于 Hadoop 中以前的分 ...

  6. 流媒体之HLS——综述

    [时间:2018-01] [状态:Open] [关键词:流媒体,stream,HLS] 0 HLS背景及初衷 HLS是由苹果公司发起的流媒体网络传输协议,可参考rfc8261 HTTP Live St ...

  7. Intellij 高亮显示与选中字符串相同的内容

    如下图所示,我的是 2018,不同版本,Schema 可能要 Save As一下

  8. SparkStreaming基本架构及使用

    1.简介 Spark Streaming处理的数据流图: Spark Streaming在内部的处理机制是,接收实时流的数据,并根据一定的时间间隔拆分成一批批的数据,然后通过Spark Engine处 ...

  9. flume的安装部署

    系统环境:centos7.5  64位系统 1.下载安装包 官网下载离线安装包:apache-flume-1.8.0-bin.tar.gz 也可以使用linux命令下载: wget -c http:/ ...

  10. 自己动手在win2003系统中添加虚拟网卡

    运用虚拟网卡我们可以更好地使用我们的网络,那么在win2003中该怎么操作呢?下面就为大家介绍下具体的步骤   虚拟网卡是用软件来实现虚拟的网卡,通过运用虚拟网卡我们可以更好地使用我们的网络.但是虚拟 ...