ACM篇:Codeforces 460 B -- Little Dima and Equation
来源:互联网 发布:华为云计算部门北京 编辑:程序博客网 时间:2024/05/01 10:23
枚举
#include <iostream>#include <cstdio>#include <vector>const int MAX_SUM = 81;const int MAX_ANS = 999999999;using namespace std;long long _pow(int x, int n);bool is_equal_sum_of_digits(long long x, int sum);int main(){ long long a, b, c; long long x; vector<long long> ans; scanf("%lld%lld%lld", &a, &b, &c); for (int sum = 1; sum <= MAX_SUM; sum++) { x = b * _pow(sum, a) + c; if (x > MAX_ANS) break; if (x >= 1 && is_equal_sum_of_digits(x, sum)) { ans.push_back(x); } } printf("%d\n", ans.size()); for (vector<long long>::iterator it = ans.begin(); it != ans.end(); it++) { printf("%lld ", *it); } return 0;}long long _pow(int x, int n){ int v = 1; for (int i = 1; i <= n; i++) v *= x; return v;}bool is_equal_sum_of_digits(long long x, int sum){ int sum_of_digits = 0; while (x) { sum_of_digits += x % 10; x /= 10; } return (sum_of_digits == sum);}
0 0
- ACM篇:Codeforces 460 B -- Little Dima and Equation
- codeforces-#460B Little Dima and Equation
- [Codeforces] 460B - Little Dima and Equation
- Codeforces 460B Little Dima and Equation
- Codeforces 460B Little Dima and Equation(暴力)
- Codeforces 460B Little Dima and Equation【思维+暴力】
- CF 460B Little Dima and Equation
- codeforce 460B Little Dima and Equation
- 460B. Little Dima and Equation
- 460 B. Little Dima and Equation
- CF 460B .Little Dima and Equation
- CF 460B Little Dima and Equation
- Little Dima and Equation CodeForces
- B. Little Dima and Equation
- B. Little Dima and Equation
- B. Little Dima and Equation
- B. Little Dima and Equation
- codeforces #262 DIV2 B题 Little Dima and Equation
- SpannableStringBuilder实现图文混排
- Android中的DrawRect()参数解析
- 16进制、10进制、字符串、中文、byte[]相互转换--->java版
- Sublime text3 搭建python环境进行数据处理
- 查看手机是否安装微信客户端
- ACM篇:Codeforces 460 B -- Little Dima and Equation
- 关于iOS全面https,2017年1月1日开启ATS审核
- [iOS 启动图不显示] Launch Image和Launch Screen [转]
- 【原创】【风扬密图1.0】自己开发的图片照片加密软件-安卓版
- 同步与异步的概念
- C#读取Excel的方法
- 域用户usb禁用
- golang数组去重 去空
- 将web前端JS错误日志合并到logback中再一起汇总到mysql或其他