| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
2196水题求问大神为什么总是Wrong Answer。多谢多谢!!#include <stdio.h>
#include <stdlib.h>
int ans,q[3]={0};
int f(int x)
{
if (x==0) return 1;
else return 16*f(x-1);
}
int check(int step,int x,int y,int z)
{
int sum;
if (step>2)
{
ans=x;
sum=q[0]+q[1]+q[2]+ans;
if (sum==y) printf ("%d\n",z);
return 0;
}
q[step]=x/f(3-step);
check(step+1,x-q[step]*f(3-step),y,z);
return 0;
}
int main ()
{
int n,num;
for (n=2992;n<10000;n++)
{
num=n/1000+(n%1000)/100+(n%100)/10+(n%10);
check(0,n,num,n);
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator