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

这样找不好么?但是超时,求解

Posted by sdjzuLH at 2011-08-10 09:51:50 on Problem 2282
#include <iostream>
#include <math.h>
#include<stdio.h>
#include <memory.h>
using namespace std;
int x[10]= {0};
int y;
int main()
{
    int a,b;
    while(1)
    {
        cin>>a>>b;
        memset(x,0,sizeof(x));
        if(a==0&&b==0)
            break;
        if(a<b)
        {
            for(int j=a; j<=b; j++)
            {
                int l=(int)log10((double)j)+1;
                y=j;
                for(int i=1; i<=l; i++)
                {
                    x[y%10]++;
                    y=y/10;
                }
            }
        }
        else
        {
            for(int j=b; j<=a; j++)
            {
                int l=(int)log10((double)j)+1;
                y=j;
                for(int i=1; i<=l; i++)
                {
                    x[y%10]++;
                    y=y/10;
                }
            }
        }
        for(int i=0; i<=9; i++)
        {
            cout<<x[i]<<"  ";
        }
        cout<<endl;
    }
    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