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 abc 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: abc. 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 109.

Examples

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 

s(x)表示x的每个位数的和

#include <bits/stdc++.h>
using namespace std;
long long ksm(long long a, long long b) {long long ans = 1, base = a;while(b != 0) {if(b & 1 != 0) {ans *= base;}base *= base;b >>= 1;}return ans;
}
int cou(int x)  //计算s(x)
{int res = 0;while(x > 0){res += x % 10;x /= 10;}return res;
}
int main()
{vector<int> v;int a,b,c,cnt = 0;cin >> a >> b >> c;for(int i = 1;i <= 81; i++){long long result = ksm(i,a)*b + c;if(result > 1e9 || result < 0) continue;else{if(i == cou(result)){v.push_back(result);}}}if(v.size() == 0) cout << 0;else{cout << v.size() << "\n";for(int i = 0;i < v.size(); i++){if(i) cout << " ";cout << v[i];}}return 0;} 

Little Dima and Equation相关推荐

  1. Codeforces Round #262 (Div. 2)-A,B,C,D

    A. Vasya and Socks 水题就不用多说了,直接暴力枚举就完事了. #include <iostream> #include<stdio.h> #include&l ...

  2. 创建此对象的程序是quation_MathType出现此对象创建于Equation中的处理教程

    有那么一部份多朋友还不熟悉MathType出现此对象创建于Equation中怎么处理?下面小编就讲解MathType出现此对象创建于Equation中的处理教程,希望对你们有所帮助哦. MathTyp ...

  3. Codeforces 358 D. Dima and Hares

    dp[i][0]表示i号兔子先于i-1号兔子喂食,dp[i][1]反过来. 倒着DP D. Dima and Hares time limit per test 2 seconds memory li ...

  4. 河南省第七届省赛 问题 F: Turing equation 水题

    **题目描述 The fight goes on, whether to store numbers starting with their most significant digit or the ...

  5. 机器人(机械臂)动力学建模方法(Newton-Euler equation)

    牛顿-欧拉公式(Newton-Euler equation)根据中间连杆上的力.力矩平衡关系上推断出来的.它的解具有递归的形式,前向递归用于连杆的速度.加速度的传递,后向递归用于力的传递. 参数定义 ...

  6. UA OPTI544 量子光学8 2-level system approximation的population rate equation模型

    UA OPTI544 量子光学8 2-level system approximation的population rate equation模型 Density Matrix的稳态(假设无非弹性碰撞) ...

  7. partial equation lecture first order pde lecture 1

    核心思想就是尝试 尝试出来就成了 reduce differencial equation to the algerbia equations dx/dt=ax assume x=e^(at) m-a ...

  8. Codeforces Round #167 (Div. 1) C. Dima and Horses(BFS+贪心)

    题目大意 有 n(1≤n≤3*105) 匹马,每条马都有几个敌人(不超过 3 个),现在要求把这些马分成两部分(允许一部分中没有一条马),使得对于每条马,和它在同一部分中的敌人的数量不超过1个 给出了 ...

  9. leetcode 640. Solve the Equation | 640. 求解方程(字符串处理)

    题目 https://leetcode.com/problems/solve-the-equation/ 题解 本题重点在字符串的处理. 先用 tokenize 函数,整理出每一项,用 X 表示,记录 ...

  10. 【机器学习】线性回归之Normal Equation(矩阵求导与线性代数视角)

    Normal Equation 之前我们用梯度下降来求解线性回归问题的最优参数,除此之外我们还可以用正规方程法(Normal Equation)来求解其最优参数. Normal Equation方法的 ...

最新文章

  1. CV之NS之ME/LF:图像风格迁移中常用的模型评估指标/损失函数(内容损失、风格损失)简介、使用方法之详细攻略
  2. 利用Spring的Aop实现项目的日志监控
  3. Java的@Serial批注
  4. mysql 定期备份策略,MySQL--3--mysqldump备份策略
  5. CSS 渐进增强与优雅降级
  6. ELF(Executable Linkable Format)文件存储格式
  7. java 指向同一地址,Sring a和String b的值相同,是不是指向同一个地址呢
  8. Atitit.自然语言处理--摘要算法---圣经章节旧约39卷概览bible overview v2 qa1.docx
  9. 大数据简历(项目部分)
  10. 计算机一级excel建立数据透视表,excel中插入数据透视表的方法
  11. 备战数学建模14-熵权法确定指标权重系数
  12. windows电脑版便签工具哪款好用?
  13. idea更新git报错master has no tracked branch
  14. 一文教会你导出微信聊天记录
  15. 尚硅谷数据结构与算法(Java)--14--插入排序
  16. (06) Apache Felix 入门 - 06
  17. wPDF v5支持并改进旋转文本的逻辑
  18. 复化梯形公式c语言实验,实验4_数值积分与数值微分(完成版).doc
  19. DS18B20温度传感器——测试环境温度及代码
  20. vscode无法跳转定义

热门文章

  1. java获取当天是周几
  2. 摇滚bono_摇滚,Paper弹枪对尼古拉斯·弗朗西斯的采访
  3. Linux misc设备(二)蜂鸣器驱动
  4. Eclipse连接Github出现not authorized
  5. Java考试题(精华版附答案)-语言基础(FUNDAMENTAL)
  6. 好用到爆的桌面电子教鞭zoomit
  7. linux驱动学习二---driver
  8. matlab将z域变为s域,时域、S域、Z域转换
  9. 运行xgboost 时出现的问题 from scipy.misc import comb ImportError: cannot import name 'comb'的
  10. Scrapy 2.6 Requests and Responses 请求和响应使用指南