Codeforces #262 DIV2 B Question Little Dima and Equation,
Address: http://codeforces.com/contest/460/problem/ B
There is no idea at first glance, but after careful analysis, we will find that s (x) is a number ranging from 1 to 81, No matter what x is. Therefore, we can enumerate 1 to 81, which is converted into a one-dimensional equation. Then we can solve x directly. At this time, we need to determine whether x is between 1 and 10 ^ 9, and the sum of all its numbers is s (x ).
This question has left my head dead twice... The first time is written as <= 10 ^ 9 .. After finding the error, I changed it back .. But it is impossible to find 10 ^ 9 ,....
The Code is as follows:
#include <iostream>#include <stdio.h>#include <string.h>#include <stdlib.h>#include <math.h>#include <ctype.h>#include <algorithm>#include <queue>using namespace std;#define LL __int64LL aa[100];int main(){ LL n, a, b, c, ans=0, i, y, zz, j; LL x, z; scanf("%I64d%I64d%I64d",&a,&b,&c); for(i=1;i<=81;i++) { zz=1; for(j=1;j<=a;j++) zz*=i; x=zz*b+c; y=0; z=x; while(z) { y+=z%10; z/=10; } if(y==i&&x>=1&&x<1e9) { aa[ans++]=x; } } printf("%I64d\n",ans); for(i=0;i<ans;i++) { printf("%I64d ",aa[i]); } return 0;}
Codeforces question: How can I attack others in codeforces?
For a question, you must first pass TEST. Then return to the PROBLEM list of the game, lock the lock behind the question (the lock won't be submitted again, so don't lock it if you're unsure), and then go to the ROOM, you can check other people's Code. There is a HACK button below. Click it and enter the example that you think is wrong.
How to view test data on codeforces
Enter the competition, click my submissions, and then click the RUN number under # To view the test data.