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 tang123456 at 2009-11-01 22:24:52 on Problem 2719
In Reply To:我用的不是九进制,我用的是递归的思路,也ac了 Posted by:ccyjava at 2009-08-03 23:08:41
#include <iostream>
using namespace std;
int main()
{
	int n;
	while (cin>>n&&n)
	{
		int n_temp=n;
		int q=0;
		int sum=0;
		int s=1;
		int temp;
		while (n)
		{
			temp=n%10;
			if (temp>=4)
			{
				temp=1;
			}
			else
			{
				temp=0;
			}
			temp+=n/10;
			sum+=temp*(s-q);
			q=q*9+s;
			s=s*10;
			n=n/10;
		}
		cout<<n_temp<<": "<<n_temp-sum<<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