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 ld2rxt at 2014-09-26 11:24:19 on Problem 3286
#include<stdio.h>

__int64 init(__int64 m)
{
	__int64 sum=0,k=10,k1=1;

	while(m/k)
	{
		sum+=(m/k*k1);
     if((m/k1)%10 == 0)
		sum -= (k1 - 1 - m%k1);
		k*=10;
		k1*=10;
	}
	return sum;
}

int main()
{
	__int64 m,n,m1,n1;
	while(scanf("%I64d %I64d",&m,&n)!=EOF)
	{
		if(m<0||n<0) break;
		m--;
		if(m<0) m1 = -1;
		else m1 = init(m);
		n1 = init(n);
		printf("%I64d\n",n1-m1);
		
	}

	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