Codeforces Round #262 (Div. 2)解题报告
详见:http://robotcator.logdown.com/posts/221514-codeforces-round-262-div-2
1:A. Vasya and Socks http://codeforces.com/contest/460/problem/A
有n双袜子,每天穿一双然后扔掉。每隔m天买一双新袜子,问最多少天后没有袜子穿。
。
简单思维题:曾经不注重这方面的训练,结果做了比較久。这样的题自己边模拟边想。只是要多考虑trick
```c++
int main(){
int n, m;
long long ans = 0;
scanf("%d%d", &n, &m);
ans = n/m*m;
int tmp = n/m;
int left = tmp + n%m;
while(true){
ans += left/m*m;
tmp = left/m;
left = tmp+left%m;
if(left < m) break;
}
ans += left;
printf("%I64d\n", ans);
return 0;
}
```
2:B. Little Dima and Equation http://codeforces.com/contest/460/problem/B
题意:
```mathjax
求满足方程 x = b*S(x)^{a}+c方程解 \\
0 \lt x \lt 10^{9} ,\ \ 1 \le a \le 5 ,\ \ 1 \le b \le 10000 ,\ \ -10000 \le c \le 10000\\
s(x) 为x每位数的和
```
题解:假设简单枚举x肯定超时,可是我们能够换个角度,枚举S(x)。这样就简单多了。由于依据右边就能够算出x..
```c++
int get_sum(long long x){
int ans = 0;
while(x){
ans += x%10;
x /= 10;
}
return ans;
}
int main(){
int a, b, c;
scanf("%d%d%d", &a, &b, &c);
long long ans[maxn];
int num = 0;
for(int i = 1; i <= 81; i ++){
long long tmp = 1;
for(int j = 1; j <= a; j ++) tmp *= i;
long long temp = b*tmp + c;
if(temp > 1e9) continue;
if(get_sum(temp) == i) {
ans[num++] = temp;
}
}
printf("%d\n", num);
if(num > 0) {
for(int i = 0; i < num; i ++)
printf("%I64d ", ans[i]);
printf("\n");
}
return 0;
}
```
3: C. Present http://codeforces.com/contest/460/problem/C
题意:有n朵花,给出初始高度。然后能够浇m次水,每次浇水能够浇连续的w朵,每次浇水后花都会长高1个单位。
问最后最矮的那朵花最大值为多少。
题解:刚開始想,首先要贪心选出最矮的花和其相邻的花浇水。然后是a_(i) 到a_(i+w-1)加一个单位。当时没想到什么好的办法。于是我就想用线段树维护区间最小值,每次找出最小值的下界。然后往右w多花都浇水。刚開始在求下界时想了好久,只是联系一维情况还是写出来了。
```c++
long long a[maxn];
long long mm[4*maxn];
int setv[4*maxn];
void build(int root, int l, int r){
int lc = 2*root, rc = 2*root+1;
if(l < r){
int mid = (l+r)/2;
build(2*root, l, mid);
build(2*root+1, mid+1, r);
mm[root] = min(mm[lc], mm[rc]);
}else{
mm[root] = a[l];
}
}
void pushdown(int root, int l, int r){
int lc = 2*root, rc = 2*root+1;
if(setv[root] > 0){
setv[lc] += setv[root];
setv[rc] += setv[root];
mm[lc] += setv[root];
mm[rc] += setv[root];
setv[root] = 0;
}
}
void pushup(int root, int l, int r){
int lc = 2*root, rc = 2*root+1;
mm[root] = min(mm[lc], mm[rc]);
}
void modify(int root, int l, int r, int x, int y, int s){
if(x <= l && r <= y){
mm[root] += s;
setv[root] += s;
}else{
pushdown(root, l, r);
int mid = (l+r)/2;
if(x <= mid) modify(2*root, l, mid, x, y, s);
if(y > mid) modify(2*root+1, mid+1, r, x, y, s);
pushup(root, l, r);
}
}
int minn;
void query(int root, int l, int r, int z){
int lc = 2*root, rc = 2*root+1 , mid = (l+r)/2;
if(l == r){
if(l < minn) minn = l;
}else{
pushdown(root, l, r);
if(mm[lc] <= z) query(lc, l, mid, z);
else query(rc, mid+1, r, z);
pushup(root, l, r);
}
}
void print(int root, int l, int r){
printf("%d %d\n", root, mm[root]);
if(l < r){
int mid = (l+r)/2;
print(2*root, l, mid);
print(2*root+1, mid+1, r);
}
}
int main(){
int w, n, m;
scanf("%d%d%d", &n, &m, &w);
for(int i = 1; i <= n; i ++)
scanf("%d", &a[i]);
memset(setv, 0, sizeof(setv));
build(1, 1, n);
// print(1, 1, n);
for(int i = 1; i <= m; i ++){
minn = inf;
query(1, 1, n, mm[1]);
//cout << minn << endl;
if(n-minn+1 < w) modify(1, 1, n, n-w+1, n, 1);
else modify(1, 1, n, minn, minn+w-1, 1);
}
printf("%I64d\n", mm[1]);
return 0;
}
```
昨晚上面两题时间还有15分钟左右,后两题没想出什么好办法。
下次再补上。
Codeforces Round #262 (Div. 2)解题报告的更多相关文章
- Codeforces Round #324 (Div. 2)解题报告
---恢复内容开始--- Codeforces Round #324 (Div. 2) Problem A 题目大意:给二个数n.t,求一个n位数能够被t整除,存在多组解时输出任意一组,不存在时输出“ ...
- Codeforces Round #382 (Div. 2) 解题报告
CF一如既往在深夜举行,我也一如既往在周三上午的C++课上进行了virtual participation.这次div2的题目除了E题都水的一塌糊涂,参赛时的E题最后也没有几个参赛者AC,排名又成为了 ...
- Codeforces Round #380 (Div. 2) 解题报告
第一次全程参加的CF比赛(虽然过了D题之后就开始干别的去了),人生第一次codeforces上分--(或许之前的比赛如果都参加全程也不会那么惨吧),终于回到了specialist的行列,感动~.虽然最 ...
- Codeforces Round #216 (Div. 2)解题报告
又范低级错误! 只做了两题!一道还被HACK了,囧! A:看了很久!应该是到语文题: 代码:#include<iostream> #include<]; ,m2=; ;i ...
- Codeforces Round #281 (Div. 2) 解题报告
题目地址:http://codeforces.com/contest/493 A题 写完后就交了,然后WA了,又读了一遍题,没找出错误后就开始搞B题了,后来回头重做的时候才发现,球员被红牌罚下场后还可 ...
- Codeforces Round #277 (Div. 2) 解题报告
题目地址:http://codeforces.com/contest/486 A题.Calculating Function 奇偶性判断,简单推导公式. #include<cstdio> ...
- Codeforces Round #276 (Div. 2) 解题报告
题目地址:http://codeforces.com/contest/485 A题.Factory 模拟.判断是否出现循环,如果出现,肯定不可能. 代码: #include<cstdio> ...
- Codeforces Round #350 (Div. 2)解题报告
codeforces 670A. Holidays 题目链接: http://codeforces.com/contest/670/problem/A 题意: A. Holidays On the p ...
- Codeforces Round #479 (Div. 3)解题报告
题目链接: http://codeforces.com/contest/977 A. Wrong Subtraction 题意 给定一个数x,求n次操作输出.操作规则:10的倍数则除10,否则减1 直 ...
随机推荐
- 斗地主(NOIP2015)
原题传送门 神奇的题目.. 一开始我准备打暴力直接搜答案. 然后发现.. 无限TLE.. 因为O((logN)^14*T)BOOM.. 然后Zxyer告诉可以只DFS顺子...其他的可以一步搞出来.. ...
- (未解决)WIN8下使用POWERSHELL安装python easy_install无法成功
按照https://pypi.python.org/pypi/setuptools#windows-8-powershell介绍的方法, 安装未成功.安装似乎没有启动, 也未安装成功. Windows ...
- F28379D烧写双核程序(在线&离线)
烧写双核程序前需知在分别对F28379D的CPU1和CPU2两个核进行烧写程序时,需要在CCS中建立两个工程,独立编写两个核的程序.如controlSUITE中提供的双核程序例程: 1. 在线1.1 ...
- (九)经典_STM32_ADC多通道采样的例子
STM32 ADC多通道转换描述:用ADC连续采集11路模拟信号,并由DMA传输到内存.ADC配置为扫描并且连续转换模式,ADC的时钟配置为12MHZ.在每次转换结束后,由DMA循环将转换的数据传输到 ...
- C++ 图像处理类库
GIFLIB是一个 C 语言的 Gif 图像处理库.支持 Gif 图像读写. 如果需要单独处理某类图片格式,以上类库是比较好的选择,如果处理的格式种类比较多,下面的类库是比较好的选择. ImageMa ...
- jquery导出Excel表格
1.引用js插件 <script src="tableExport.js"></script> <script src="jquery.ba ...
- 理解Java垃圾回收
stop-the-world 原文链接:http://www.cubrid.org/blog/de... 了解Java的垃圾回收(GC)原理能给我们带来什么好处?对于软件工程师来说,满足技术好奇心可算 ...
- HDU 3966 Aragorn's Story(树链剖分)(线段树区间修改)
Aragorn's Story Time Limit: 10000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- [Usaco2010 Feb]Chocolate Buying
题目描述 贝西和其他奶牛们都喜欢巧克力,所以约翰准备买一些送给她们.奶牛巧克力专卖店里 有N种巧克力,每种巧克力的数量都是无限多的.每头奶牛只喜欢一种巧克力,调查显示, 有Ci头奶牛喜欢第i种 ...
- sql server mvp 發糞塗牆
http://blog.csdn.net/dba_huangzj/article/details/38295753