1. 程式人生 > >codevs 3943 數學奇才琪露諾

codevs 3943 數學奇才琪露諾

main 。。 rcu argc == res target include ()

二次聯通門 : 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 數學奇才琪露諾