Codeforces 460B Little Dima and Equation(暴力)
2014-08-31 15:55
309 查看
题目链接:Codeforces 460B Little Dima and Equation
题目大意:给定a,b,c,求有多少x满足公式x=b∗s(x)a+c(s(x)为x的各个位数的累加和)
解题思路:枚举,因为x很大,所以直接枚举s(x)。
题目大意:给定a,b,c,求有多少x满足公式x=b∗s(x)a+c(s(x)为x的各个位数的累加和)
解题思路:枚举,因为x很大,所以直接枚举s(x)。
#include <cstdio> #include <cstring> #include <vector> #include <algorithm> using namespace std; typedef long long ll; int a, b, c; ll f (int x) { ll ret = 1; for (int i = 0; i < a; i++) ret *= x; return ret * b + c; } bool judge (int s, int x) { int ret = 0; while (x) { ret += x % 10; x /= 10; } return ret == s; } int main () { vector<int> vec; scanf("%d%d%d", &a, &b, &c); for (int i = 1; i <= 81; i++) { ll u = f(i); if (u < 1e9 && judge(i, u)) vec.push_back((int)u); } sort(vec.begin(), vec.end()); printf("%lu\n", vec.size()); for (int i = 0; i < vec.size(); i++) printf("%d%c", vec[i], i == vec.size() - 1 ? '\n' : ' '); return 0; }
相关文章推荐
- codeforces 814 C. An impassioned circulation of affection(暴力)
- Codeforces 677E Vanya and Balloons(暴力+转换) category:
- Codeforces1063D Candies for Children 【分类讨论】【暴力】
- Codeforces 245G Suggested Friends 暴力乱搞
- Codeforces 490C Hacking Cypher 暴力
- Codeforces 57C Array dp暴力找到规律
- [Codeforces 292C] Beautiful IP Addresses (暴力+构造)
- COdeforces 479A - Expression (暴力枚举即可)
- Codeforces 779B(暴力)
- codeforces 691F Couple Cover 暴力预处理
- CodeForces 398A Cards 贪心 暴力 瞎搞
- Codeforces 666B World Tour 暴力最短路
- 暴力 + 贪心 --- Codeforces 558C : Amr and Chemistry
- Codeforces 143A Help Vasilisa the Wise 2(暴力)
- codeforces 903B(暴力)
- Codeforces 579D "Or" Game【贪心+暴力按位处理】
- CodeForces 681B Economy Game (暴力)
- Codeforces 526C - Om Nom and Candies(贪心,暴力)
- Codeforces 626D 暴力
- Codeforces 425A Sereja and Swaps(暴力+贪心)