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\),可加 ...
随机推荐
- WPF宝典Url
https://sourceforge.net/directory/os:windows/https://archive.codeplex.com/ https://code.msdn.microso ...
- 抓包神器 tcpdump 使用介绍
tcpdump 命令使用简介 简单介绍 tcpdump 是一款强大的网络抓包工具,运行在 linux 平台上.熟悉 tcpdump 的使用能够帮助你分析.调试网络数据. 要想使用很好地掌握 tcpdu ...
- /linux-command-line-bash-shortcut-keys/
https://www.howtogeek.com/howto/ubuntu/keyboard-shortcuts-for-bash-command-shell-for-ubuntu-debian-s ...
- 【转载】MapReduce编程 Intellij Idea配置MapReduce编程环境
目录(?)[-] 一软件环境 二创建maven工程 三添加maven依赖 四配置log4j 五启动Hadoop 六运行WordCount从本地读取文件 七运行WordCount从HDFS读取文件 八代 ...
- 【转载】Hadoop官方文档翻译——HDFS Architecture 2.7.3
HDFS Architecture HDFS Architecture(HDFS 架构) Introduction(简介) Assumptions and Goals(假设和目标) Hardware ...
- zookeeper入门及使用(一)- 安装及操作
zookeeper是什么? highly reliable distributed coordination,用来做高可靠的分布式协调者,可用来: 业务发现(service discovery)找到分 ...
- FasterRCNN原理(转)
在介绍Faster R-CNN之前,先来介绍一些前验知识,为Faster R-CNN做铺垫. 一.基于Region Proposal(候选区域)的深度学习目标检测算法 Region Proposal( ...
- USB2.0学习笔记连载(一):CY7C68013特性简介
上一篇博客已经给出了整个视频板卡架构,那么对于USB接口部分需要着重理解和学习. 对于目前来说,若是利用FPGA去模拟USB2.0内核,难度还是挺大的,整个状态的收发都不好控制.现在目前都在使用桥接芯 ...
- php curl post josn + header
<meta charset="utf8"> <?php ini_set("max_execution_time",1800000); $arr ...
- MySQL 表中添加 时间戳 字段
场景: 有张表的数据需要用同步工具同步至其他库,需要 update_time 时间戳字段 来做增量同步. 解决方法: alter table quant_stk_calc_d_wxcp add upd ...