Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

2196水题求问大神为什么总是Wrong Answer。多谢多谢!!

Posted by miyanopku at 2011-12-27 10:53:52
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator