Codeforces Round #262 (Div. 2) 题解
1 second
256 megabytes
standard input
standard output
Vasya has n pairs of socks. In the morning of each day Vasya has to put on a pair of socks before he goes to school. When he comes home in the evening, Vasya
takes off the used socks and throws them away. Every m-th day (at days with numbers m, 2m, 3m, ...)
mom buys a pair of socks to Vasya. She does it late in the evening, so that Vasya cannot put on a new pair of socks before the next day. How many consecutive days pass until Vasya runs out of socks?
The single line contains two integers n and m (1 ≤ n ≤ 100; 2 ≤ m ≤ 100),
separated by a space.
Print a single integer — the answer to the problem.
2 2
3
9 3
13
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <algorithm>
using namespace std; typedef long long lint;
typedef double DB;
//const int MAXN = ; int main()
{
int n, m, t = 0;
scanf("%d%d", &n, &m);
while(n)
{
n--;
t++;
if(0 == t%m) n++;
}
printf("%d\n", t);
return 0;
}
1 second
256 megabytes
standard input
standard output
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment.
Find all integer solutions x (0 < x < 109) of
the equation:
x = b·s(x)a + c,
where a, b, c are
some predetermined constant values and function s(x) determines the sum of all digits in the decimal representation of number x.
The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c.
Dima got sick of getting bad marks and he asks you to help him solve this challenging problem.
The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000; - 10000 ≤ c ≤ 10000).
Print integer n — the number of the solutions that you've found. Next print n integers
in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 109.
3 2 8
3
10 2008 13726
1 2 -18
0
2 2 -1
4
1 31 337 967
传送门:点击打开链接
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <algorithm>
using namespace std; typedef long long lint;
typedef double DB;
const int MAX = 1e9;
const int MAXN = 100;
lint ans[100]; int fun(lint x)
{
int ret = 0;
while(x)
{
ret += x%10;
x /= 10;
}
return ret;
} int main()
{
int a, b, c, n, m = 0;
scanf("%d%d%d", &a, &b, &c);
for(int i=1; i<=81; ++i)
{
lint x = 1ll*b*pow(i*1.0,a) + 1ll*c;
if(x<MAX && x>0 && i==fun(x)) ans[m++] = x;
}
sort(ans, ans+m);
printf("%d\n", m);
for(int i=0; i<m; ++i)
{
if(i) printf(" ");
printf("%I64d", ans[i]);
}
printf("\n");
return 0;
}
2 seconds
256 megabytes
standard input
standard output
Little beaver is a beginner programmer, so informatics is his favorite subject. Soon his informatics teacher is going to have a birthday and the beaver has decided to prepare a present for her. He planted n flowers
in a row on his windowsill and started waiting for them to grow. However, after some time the beaver noticed that the flowers stopped growing. The beaver thinks it is bad manners to present little flowers. So he decided to come up with some solutions.
There are m days left to the birthday. The height of the i-th
flower (assume that the flowers in the row are numbered from 1 to n from
left to right) is equal to ai at
the moment. At each of the remaining m days the beaver can take a special watering and water w contiguous
flowers (he can do that only once at a day). At that each watered flower grows by one height unit on that day. The beaver wants the height of the smallest flower be as large as possible in the end. What maximum height of the smallest flower can he get?
The first line contains space-separated integers n, m and w (1 ≤ w ≤ n ≤ 105; 1 ≤ m ≤ 105).
The second line contains space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109).
Print a single integer — the maximum final height of the smallest flower.
6 2 3
2
2 2 2 1 1
2
2 5 1
5 8
9
传送门:点击打开链接
ps:这里的b数组大小是n+w。
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <algorithm>
using namespace std; typedef long long lint;
typedef double DB;
const int MAXN = 2e5+10;
const int INF = 2e9;
lint a[MAXN], b[MAXN], ans;
int n, m, w; bool check(lint k)
{
memset(b, 0, sizeof(b));
lint sum = 0, d = 0;
for(int i=1; i<=n; ++i)
{
sum += b[i];
lint tp = k - a[i] - sum;
if(tp > 0)
{
sum += tp;
b[i+w] -= tp;
d += tp;
// printf("%I64d %I64d\n", tp, d);
if(d > m) return false;
}
}
return true;
} int main()
{
scanf("%d%d%d", &n, &m, &w);
for(int i=1; i<=n; ++i)
scanf("%I64d", a+i);
lint l = 1, r = 1ll*INF;
while(l <= r)
{
lint mid = (l+r)>>1;
if(check(mid))
l = mid + 1, ans = mid;
else
r = mid - 1;
// printf("%I64d %I64d\n", l, r);
}
printf("%I64d\n", ans);
return 0;
}
Codeforces Round #262 (Div. 2) 题解的更多相关文章
- Codeforces Round #262 (Div. 2) 1004
Codeforces Round #262 (Div. 2) 1004 D. Little Victor and Set time limit per test 1 second memory lim ...
- Codeforces Round #262 (Div. 2) 1003
Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 2 ...
- Codeforces Round #182 (Div. 1)题解【ABCD】
Codeforces Round #182 (Div. 1)题解 A题:Yaroslav and Sequence1 题意: 给你\(2*n+1\)个元素,你每次可以进行无数种操作,每次操作必须选择其 ...
- Codeforces Round #608 (Div. 2) 题解
目录 Codeforces Round #608 (Div. 2) 题解 前言 A. Suits 题意 做法 程序 B. Blocks 题意 做法 程序 C. Shawarma Tent 题意 做法 ...
- Codeforces Round #525 (Div. 2)题解
Codeforces Round #525 (Div. 2)题解 题解 CF1088A [Ehab and another construction problem] 依据题意枚举即可 # inclu ...
- Codeforces Round #528 (Div. 2)题解
Codeforces Round #528 (Div. 2)题解 A. Right-Left Cipher 很明显这道题按题意逆序解码即可 Code: # include <bits/stdc+ ...
- Codeforces Round #466 (Div. 2) 题解940A 940B 940C 940D 940E 940F
Codeforces Round #466 (Div. 2) 题解 A.Points on the line 题目大意: 给你一个数列,定义数列的权值为最大值减去最小值,问最少删除几个数,使得数列的权 ...
- Codeforces Round #677 (Div. 3) 题解
Codeforces Round #677 (Div. 3) 题解 A. Boring Apartments 题目 题解 简单签到题,直接数,小于这个数的\(+10\). 代码 #include &l ...
- Codeforces Round #665 (Div. 2) 题解
Codeforces Round #665 (Div. 2) 题解 写得有点晚了,估计都官方题解看完切掉了,没人看我的了qaq. 目录 Codeforces Round #665 (Div. 2) 题 ...
随机推荐
- sql 的几种常用方法
第一个项目总结基类:database:主要是定义有关数据库的方法: 1.打开数据库 public static void Open() { ( "server=.\\sqlexpress;d ...
- 服务器TCP连接中 TIME_WAIT 状态过多
今天查看服务器的TCP连接数,发现其中 TIME_WAIT 状态的太多了: # netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a ...
- git rebase 的使用 (用于撤销某次commit)
Q: I wrote the wrong thing in a commit message. Alternatively, I've forgotten to include some files. ...
- 认识Vue组件
前言 Vue.js是一套构建用户界面的渐进式框架(官方说明).通俗点来说,Vue.js是一个轻量级的,易上手易使用的,便捷,灵活性强的前端MVVM框架.简洁的API,良好健全的中文文档,使开发者能够较 ...
- OpenJDK源码研究笔记(六)--观察者模式工具类(Observer和Observable)和应用示例
本文主要讲解OpenJDK观察者模式的2个工具类,java.util.Observer观察者接口,java.util.Observable被观察者基类. 然后,给出了一个常见的观察者应用示例. Obs ...
- django-xadmin使用之更改菜单url
环境:xadmin-for-python3 python3.5.2 django1.9.12 1. 在模块的adminx.py文件中增加以下代码: class AdminSettings(object ...
- ArcGIS api for javascript——创建地图
描述 这个示例显示ArcGIS Server的一个地图.ArcGIS Server地图是缓存的,意味着它有服务器管理员建来提升性能的一组预先渲染的切片.由于这个原因地图通过ArcGISTiledMap ...
- 【Hibernate步步为营】--(一对多映射)之单向关联
上篇文章讨论了双向关联的一对一映射,用了两个章节,主要是从主键和外键两种关联映射展开具体讨论.双向关联的映射须要在两个映射文件里分别加入相互的相应关系.斌刚在相应的类中加入相应的关联类的属性.这样在一 ...
- 关于App程序猿泡沫
前言 做开发快七年了,对于程序猿,外行人总有着数不完的讽刺和误解,可是我都懒得去解释.代码搬运工人也好,民工也罢,随他们去说吧.可是网上近期流传的程序猿泡沫,尤其是APP程序猿泡沫的文章导致非常多我们 ...
- IDEA中的maven web 项目中如何设置自己的本地仓库
我们在创建maven项目的时候如何不使用系统指定的本地仓库,而使用自己设置的仓库呢,这里小女子就来进行讲解一下吧! 讲解一:你要想找到settings.xml你就要自己我去官网上去下载apache-m ...