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

Re:小学的除法知识可以解决

Posted by huanghaoxiang at 2009-08-04 21:22:00 on Problem 2551
In Reply To:小学的除法知识可以解决 Posted by:peterdi at 2009-05-26 19:22:33
> 除法的步骤是能够除就得到余数+后一位继续除,题目中的意思被除数是无限长的,所以一直可以在低位添1。
我一直超时 看了你的这个 水过了!
#include <stdio.h>

int main()
{
	long k;
	while ( scanf ( "%ld",&k ) != EOF )
	{
		long j = 1;
		long i = 1,n = 1;
		while ( j < k )
		{
			j = j * 10 + 1;
			++n;
		}
		while ( j % k != 0 )
		{
			j = j % k * 10 + 1;
			++n;
		}
		printf ( "%d\n",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