Codeforces Round #262 (Div. 2) B
题目:
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
题意分析:

2 100 cha到一个人挽回点损失~
代码:
- #include <cstdio>
- #include <cmath>
- #include <algorithm>
- #include <cstring>
- #include <iostream>
- using namespace std;
- int d[100000];
- int main()
- {
- int a,b,c,sum,cou;
- long long temp,flag;
- while(cin>>a>>b>>c)
- {
- memset(d,0,sizeof(d));
- cou=0;
- for(int i=1;i<=81;i++)
- {
- sum=0;
- temp=1;
- for(int j=0;j<a;j++)
- {
- temp*=i;
- }
- temp=b*temp;
- temp=c+temp;
- //printf("%d ",temp);
- flag=temp;
- while(temp)
- {
- sum+=temp%10;
- temp/=10;
- }
- if(sum==i&&flag>0&&flag<(1e9))
- d[cou++]=flag;
- }
- if(cou==0)
- printf("0\n");
- else
- {
- printf("%d\n%d",cou,d[0]);
- for(int i=1;i<cou;i++)
- {
- printf(" %d",d[i]);
- }
- printf("\n");
- }
- }
- }
Codeforces Round #262 (Div. 2) B的更多相关文章
- 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 #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) 460C. Present(二分)
题目链接:http://codeforces.com/problemset/problem/460/C C. Present time limit per test 2 seconds memory ...
- codeforces水题100道 第十五题 Codeforces Round #262 (Div. 2) A. Vasya and Socks (brute force)
题目链接:http://www.codeforces.com/problemset/problem/460/A题意:Vasya每天用掉一双袜子,她妈妈每m天给他送一双袜子,Vasya一开始有n双袜子, ...
- Codeforces Round #262 (Div. 2) E. Roland and Rose 暴力
E. Roland and Rose Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset/pro ...
- Codeforces Round #262 (Div. 2)解题报告
详见:http://robotcator.logdown.com/posts/221514-codeforces-round-262-div-2 1:A. Vasya and Socks http ...
- Codeforces Round #262 (Div. 2)460A. Vasya and Socks(简单数学题)
题目链接:http://codeforces.com/contest/460/problem/A A. Vasya and Socks time limit per test 1 second mem ...
- Codeforces Round #262 (Div. 2)
A #include <iostream> #include<cstdio> #include<cstring> #include<algorithm> ...
- Codeforces Round #262 (Div. 2) A B C
题目链接 A. Vasya and Socks time limit per test:2 secondsmemory limit per test:256 megabytesinput:standa ...
- Codeforces Round #262 (Div. 2) 二分+贪心
题目链接 B Little Dima and Equation 题意:给a, b,c 给一个公式,s(x)为x的各个位上的数字和,求有多少个x. 分析:直接枚举x肯定超时,会发现s(x)范围只有只有1 ...
随机推荐
- delphi 读网页线程TReadHtmlThread
读网页,通常是一个耗时操作.故把读网页放入线程是显得比较重要了. 本例用改进后的 TIdhttpEx 加上线程来实现读网页. 它的父类TSimpleThread 在此 本例程源码在此 源码中包含了所有 ...
- 如何修改被编译后DLL文件
原文 http://www.cnblogs.com/wujy/p/3275855.html 我们平时在工作中经常会遇到一些已经被编译后的DLL,而且更加麻烦是没有源代码可以进行修改,只能针对这个DLL ...
- 开源语音识别系统 Simon
http://www.lupaworld.com/proj.php?mod=view&cid=&id=824 语音识别系统 Simon:Simon 是一个开源的语音识别系统,它不仅可以 ...
- C语言入门(16)——C语言的数组
和结构体类似,数组也是一种复合数据类型,它由一系列相同类型的元素组成.C语言支持一维数组和多维数组.如果一个数组的所有元素都不是数组,那么该数组称为一维数组. 一维数组的定义方式 在C语言中使用数组必 ...
- kubuntu添加windows字体
1.选取字体 在/usr/share/fonts/truetype中新建一个目录,命名为ms,然后将Windows\fonts 目录下的tahoma.ttf.tahomabd.ttf(Tahoma的粗 ...
- 用python处理文本数据 学到的一些东西
最近写了一个python脚本,用TagMe的api标注文本,并解析返回的json数据.在这个过程中遇到了很多问题,学到了一些新东西,总结一下. 1. csv文件处理 csv是一种格式化的文件,由行和列 ...
- IEnumerable和IEnumerator 详解 【转】
初学C#的时候,老是被IEnumerable.IEnumerator.ICollection等这样的接口弄的糊里糊涂,我觉得有必要切底的弄清楚IEnumerable和IEnumerator的本质. 下 ...
- WinEdt7.0 初试
刚刚开始学的时候,安装就出了些问题(关于安装的问题,请看我之前的文章)不知道如何点击运行,编译.看了些博客论坛.终于成功了. 首先先写一个小代码: \documentclass[UTF8]{ctexa ...
- uva 10306 - e-Coins(完全背包)
题目链接:10306 - e-Coins 题目大意:给出m和s, 再给出m种电子硬币,每种硬币有两种金额xi,yi.现在要在m种硬币种选若干个硬币,可以重复选同一种硬币, 使得(x1 + x2 + . ...
- python 网页爬虫+保存图片+多线程+网络代理
今天,又算是浪费了一天了.python爬虫,之前写过简单的版本,那个时候还不懂原理,现在算是收尾吧. 以前对网页爬虫不了解,感觉非常神奇,但是解开这面面纱,似乎里面的原理并不是很难掌握.首先,明白一个 ...