Codeforces Round #262 (Div. 2) 题解

传送门:点击打开链接

解题思路:

水题,,简单模拟。

代码:

#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;}

B. Little Dima and Equation

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

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 solutionsx(0<x<109)of the equation:

x=b·s(x)a+c,

wherea,b,care some predetermined constant values and functions(x)determines the sum of all digits in the decimal representation of numberx.

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.

Input

The first line contains three space-separated integers:a,b,c(1≤a≤5;1≤b≤10000;-10000≤c≤10000).

Output

Print integern— the number of the solutions that you’ve found. Next printnintegers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than109.

Sample test(s)

input

3 2 8

output

310 2008 13726

input

1 2 -18

output

0

input

2 2 -1

output

41 31 337 967

传送门:点击打开链接

解题思路:

S(X)的取值从1到81,我们可以通过枚举S(x)的值得到x的值,检验是否符合。

代码:

#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;}

C. Present

time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

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 plantednflowers 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 aremdays left to the birthday. The height of thei-th flower (assume that the flowers in the row are numbered from1tonfrom left to right) is equal toaiat the moment. At each of the remainingmdays the beaver can take a special watering and waterwcontiguous 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?

Input

The first line contains space-separated integersn,mandw(1≤w≤n≤105;1≤m≤105). The second line contains space-separated integersa1,a2,…,an(1≤ai≤109).

Output

Print a single integer — the maximum final height of the smallest flower.

Sample test(s)

input

6 2 322 2 2 1 1

output

2

input

2 5 15 8

output

9

传送门:点击打开链接

解题思路:

对所求解的值进行二分。ps:这里的b数组大小是n+w。

代码:

流过泪的眼睛更明亮,滴过血的心灵更坚强!

Codeforces Round #262 (Div. 2) 题解

相关文章:

你感兴趣的文章:

标签云: