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\),可加 ...
随机推荐
- 一些Android手机的平台信息
1.OPPO A83 (2018-04-16) A83:/ $ cat /system/build.prop | grep "product"# ro.product.cpu.ab ...
- dagger2 重点笔记
官方架构例子,里面有个dagger2的结合的例子 https://github.com/googlesamples/android-architecture https://google.github ...
- 【C#】C#线程_基元线程的同步构造
目录结构: contents structure [+] 简介 为什么需要使用线程同步 线程同步的缺点 基元线程同步 什么是基元线程 基元用户模式构造和内核模式构造的比较 用户模式构造 易变构造(Vo ...
- React Native 从入门到原理一
React Native 从入门到原理一 React Native 是最近非常火的一个话题,介绍如何利用 React Native 进行开发的文章和书籍多如牛毛,但面向入门水平并介绍它工作原理的文章却 ...
- ffmpeg中AVBuffer的实现分析
[时间:2017-10] [状态:Open] [关键词:ffmpeg,avutil,avbuffer, 引用计数] 0 引言 AVBuffer是ffmpeg提供的基于引用计数的智能指针的一个实现版本. ...
- poi操作Excel的封装类
这是一个简单的对poi的封装,只能简单的取值,设值,拷贝行,插入行等. 针对读取Excel模板后,填值再保存的应用,比较方便. poi版本:3.13 贴代码: package cn.com.gtmc. ...
- Spring Boot 调用 MongoRepository时报org.springframework.beans.factory.NoSuchBeanDefinitionException错误的解决办法
这个问题整整折腾了我两天,现在记录下来,希望可以帮助和我一样,遇到相同问题的小伙伴. 项目是分层的(Intellij IDEA中的模块Module),有API(Core)层,Service&D ...
- mac 上使用 zip 版的mysql
1. 下载: 2. 解压,然后复制到需要的目录下 3. 修改 /usr/local/mysql的所有者为mysql: chown -R mysql:mysql mysql (这一步我是没做,爱做不做. ...
- java生成zip压缩文件,解压缩文件
1.生成zip public static void main(String[] args) { try { // testZip("c:\\temp.txt", "c: ...
- 算法-KMP
KMP算法的作用在于在一个主串中查找一个主串. 传统查找子串的方法是一个字符一个字符的比较,代码如下: public static int notKMP(String main,String sub) ...