Little Dima and Equation CodeForces
来源:互联网 发布:java 配置中心 编辑:程序博客网 时间:2024/05/22 00:06
Little Dima and Equation CodeForces - 460B
题目描述
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment.
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.
Input
The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000; - 10000 ≤ c ≤ 10000).
Output
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 10^9.
Example
Input
3 2 8
Output
3
10 2008 13726
Input
1 2 -18
Output
0
Input
2 2 -1
Output
4
1 31 337 967
大致题意
给你一个公式然后让你求所有满足条件的x的个数,并从小到大输出x的值。
思路 : s(x)表示的是x的十进制表示中所有的数字和,又因为x<10^9,所以x最多有9位,当每一位上都是9时s(x)有最大值81,所以s(x)的取值范围为1到81.暴力即可。
注意 x的取值范围是x>0&&x<10^9,超过这个范围的x不记录。
#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>#include<queue>#include<vector>#include<cmath>#include<string>#define ll long long #define maxn 100005using namespace std;ll p(int x,int y){ ll n=1; for(int i=1;i<=y;i++){ n*=x; } return n;}int f[100];int main(){ int a,b,c,k=0; scanf("%d %d %d",&a,&b,&c); for(int i=1;i<=81;i++) { long long int sum,num=0,sum1; sum1=sum=p(i,a)*b+c; while(sum){ num+=sum%10; sum/=10; } if(num==i&&sum1>0&&sum1<1e9) f[k++]=sum1; } printf("%d\n",k); for(int i=0;i<k;i++) printf("%d ",f[i]); return 0;}
- Little Dima and Equation CodeForces
- Codeforces Little Dima and Equation 数学题解
- codeforces-#460B Little Dima and Equation
- [Codeforces] 460B - Little Dima and Equation
- Codeforces 460B Little Dima and Equation
- codeforces #262 DIV2 B题 Little Dima and Equation
- Codeforces Round #262 (Div. 2)B. Little Dima and Equation
- Codeforces Round #262(div2) B. Little Dima and Equation
- Codeforces Round #262 (Div. 2) B. Little Dima and Equation
- Codeforces 460B Little Dima and Equation(暴力)
- Codeforces Round #262 (Div. 2) B. Little Dima and Equation
- ACM篇:Codeforces 460 B -- Little Dima and Equation
- Codeforces 460B Little Dima and Equation【思维+暴力】
- B. Little Dima and Equation
- B. Little Dima and Equation
- B. Little Dima and Equation
- B. Little Dima and Equation
- CF 460B Little Dima and Equation
- linux操作系统基本介绍
- 变量及其作用域
- 骰子点数分布概率问题
- Java import单类引入与包引入的区别
- STM32F4 系统时钟
- Little Dima and Equation CodeForces
- Unity3D 游戏开发之内存优化
- Webpack2 完整踩坑教程(十三)
- 读懂Netty的高性能架构之道
- 事务隔离级别
- linux运维笔记
- 第一章 必须了解的JavaScript知识
- 点击cell具备和按钮一样的点击效果
- python 字符串的split()函数详解