Codeforces 1100 - A/B/C/D/E/F - (Undone)
链接: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)的更多相关文章
- Codeforces 1132 - A/B/C/D/E/F - (Undone)
链接:http://codeforces.com/contest/1132 A - Regular Bracket Sequence - [水] 题解:首先 "()" 这个的数量多 ...
- Codeforces 1114 - A/B/C/D/E/F - (Undone)
链接:http://codeforces.com/contest/1114 A - Got Any Grapes? 题意:甲乙丙三个人吃葡萄,总共有三种葡萄:绿葡萄.紫葡萄和黑葡萄,甲乙丙三个人至少要 ...
- Codeforces 1043 - A/B/C/D/E/F - (Undone)
链接:http://codeforces.com/contest/1043 A - Elections - [水水水水题] 题意: 我和另一个人竞争选举,共有 $n$ 个人投票,每个人手上有 $k$ ...
- 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 ...
- Educational Codeforces Round 71 (Rated for Div. 2)-F. Remainder Problem-技巧分块
Educational Codeforces Round 71 (Rated for Div. 2)-F. Remainder Problem-技巧分块 [Problem Description] ...
- Codeforces 1100 F - Ivan and Burgers
F - Ivan and Burgers 思路:线性基+贪心,保存线性基中每一位的最后一个 代码: #pragma GCC optimize(2) #pragma GCC optimize(3) #p ...
- 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 ...
- Codeforces 1154 - A/B/C/D/E/F/G - (Undone)
链接:https://codeforces.com/contest/1154 A - Restoring Three Numbers - [水] #include<bits/stdc++.h&g ...
- 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\),可加 ...
随机推荐
- 安装了 R2 Integration Servic 之后,SQL Server 2008 Management Studio报错
问题产生 IM数据库服务器未安装Integration Servic,影响备份.在安装了安装了 SQL Server 2008 R2 Integration Servic 之后,SQL Server ...
- 阿里云物联网平台体验(树莓派+Python篇)
阿里云物联网平台体验(树莓派+Python篇) 虽然对阿里云物联网平台比较熟悉了,从一开始就有幸参与了飞凤平台(Link Develop 一站式开发平台的前身)的一些偏硬件接入的工作.但是同时也见证了 ...
- 发现一个强大的可视化第三方库pyecharts
pyecharts 目前尚在不断的更新中,值得重点研究和学习的图表库
- SpringBoot乱码
第一步: 第一步,约定好传参编码格式 不管是运用httpclient,还是原生http,都要设置传参的编码,为了统一,这儿全部设置为utf-8 第二步,修正application.properties ...
- Delphi提取PDF文本
生成PDF的控件很多,但解析的不是太多,pdf Toolkit可以,但测试的第一个复杂的pdf就报告错误,并且汉字乱码,可能使用的版本或使用方法不对. 想起之前使用java调用的Apache名下的pd ...
- SQL Server 性能优化实战系列(二)
SQL Server datetime数据类型设计.优化误区 一.场景 在SQL Server 2005中,有一个表TestDatetime,其中Dates这个字段的数据类型是datetime,如果你 ...
- 【20180409】IT管理之IT十二条令
团队越来越大,靠人管几乎有力无心,只能靠制度管理了. 前段时间对部门颁布了12条令,效果明显. 特此Mark. 汇报: 三条总结:汇报讲究精简,一个事情最多一句话概括. 一页报告:内容精简,报告一页w ...
- 基础008_定浮点转化[floating point IP]
作者:桂. 时间:2018-05-15 21:55:50 链接:http://www.cnblogs.com/xingshansi/p/9042564.html 前言 本文为Xilinx float ...
- animate.css做点赞效果
花了一晚上研究出来的,感觉还行吧... 代码: 源码下载: http://image.niunan.net/animatedemo.zip
- golang:iconv
最近在做邮件解析的工作,遇到需要转字符集编码的情况,go官方好像没有提供这样的库,于是从github上找了一下. https://github.com/qiniu/iconv 开发环境: linux ...