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 |
Re:小学的除法知识可以解决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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator