题目链接:Codeforces 460B Little Dima and Equation
题目大意:给定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 1105B - Zuhair and Strings 测试点37个(全)
Codeforces - 1107B. Digital root & 1107C. Brutality(规律 & 贪心)Codeforces - 1107B.
Codeforces 题库 101-200 共~500题 codeforces.com版权所有。 程序可提交至该网站评测。
Codeforces 题库 001-100 共~500题 codeforces.com版权所有。 程序可提交至该网站评测。
codeforces编程网站预测分数插件
codeforces每日一题。 题意: 给出一个数组,让你挑选出能组成任意pair差值为2的幂的序列,并且使这个序列长度尽可能大。 思路: 针对于挑选出来的序列,任意pair对的差值为2的幂数。 假设有多个pair对,设dis(a,b)=2...
使用于Google Chrome的Codeforces Enhancer 1.1.2插件安装包。 版本:codeforces enhancer 1.1.2 使用浏览器:Google Chrome
暴枚最长桌脚的长度$l$,然后长度比$l$长的桌脚全部都要砍掉长度比$l$短的桌脚选择代价前$k$小的砍掉用线段树维护;示例程序 :typedef long l
Codeforces 185A - Plant 全测试点49个
codeforces 19 E Fairy 一道比较难的题目的解题报告 推荐阅读
Codeforces global round 10 codes
Codeforces round 678 division 2 codes
题目大意:给出一个由 n 个点组成的树,现在可以询问 n/2 次(向下取整)LCA,确定根节点是哪个节点 题目分析:因为最多只能求 n/2 次lca,每次需要两个节点作为参数,也就是说每个点我们至多遍历一遍,读完题后没什么...
Some of the Codeforces problems codes
题意: 给出 nnn 个点,n−1n-1n−1 条边,最多询问 n2\frac{n}{2}2n 次,每次询问 u,vu,vu,v,会给出 uvuvuv的最近公共祖先,求树的根。 ...操作就是一个删除叶子节点的过程。 AC代码: const int N = 1010;...
lucifer1004大佬的博客cf上分攻略故里大佬的githubcf思维题刷题数:44- (1421)codeforces 676 div2 A,B done
如果a嘲讽b,b嘲讽c,那么(a,b,c)是一个三元组 问每次操作之后一共有多少对三元组 数据范围:n,m<=1e5,q<=1e5 三元组图例(未修改工资时): 图中三元组一共4组: 4->3->1 4->3->2 4->2->1 3->2->1 解法...
Codeforces Round #632 (Div. 2) C. Eugene and an array 题意: 求出一个数列中子区间满足 此区间的任意子区间之和 不为0的区间个数。 思路: 考虑用dp[x]dp[x]dp[x]记录前缀和为xxx的区间右端点。 那么这道题其实...
Codeforces round 678 D2_Codeforces_源码
打codeforces的神器