首页 > 代码库 > codevs 3943 数学奇才琪露诺
codevs 3943 数学奇才琪露诺
二次联通门 : codevs 3943 数学奇才琪露诺
/* codevs 3943 数学奇才琪露诺 一眼看过去 感觉这道题是个神题。。。不可做 后来打了个暴力, 0分 再后来仔细想了想 既然L,R<=10^9 那么数位之和最大就到81 (999999999) 那么直接枚举数位和来分解就好了。。。 */ #include <cstdio> #define Limit 81 void read (int &now) { register char word = getchar (); bool temp = false; for (now = 0; word < ‘0‘ || word > ‘9‘; word = getchar ()) if (word == ‘-‘) temp = true; for (; word <= ‘9‘ && word >= ‘0‘; now = now * 10 + word - ‘0‘, word = getchar ()); if (temp) now = -now; } int K, P, Q; int L, R; long long Fast_Pow (long long x, int p) { long long res = 1; for (; p; p >>= 1) { if (p & 1) res = res * x; x = x * x; } return res; } long long Carculate (int x) { return (long long) Fast_Pow ((long long) x, K) * P; } #define Max 10000000 int data[Max]; int Cur; int Need; int main (int argc, char *argv[]) { read (K); read (P); read (Q); read (L); read (R); register long long now, res; for (register int i = 1; i <= Limit; i ++) { now = Carculate (i) + Q; int key = 0; res = now; if (now <= R && now >= L) { for (; now; key += now % 10, now /= 10); if (key == i) data[++ Cur] = res; } } printf ("%d\n", Cur); for (int i = 1; i <= Cur; i ++) printf ("%d ", data[i]); return 0; }
codevs 3943 数学奇才琪露诺
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。