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 wjwjw at 2011-07-17 15:32:36 on Problem 1426
//============================================================================
// Name        : hello.cpp
// Author      : key
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

int n;

void bfs()
{
	long long x;
	queue < long long > q;
	q.push(1);
	while(!q.empty())
	{
		x = q.front();
		q.pop();
		if(x%n==0)
		{
			printf("%lld\n",x);
			return ;
		}
		x*=10;
		q.push(x);
		x+=1;
		q.push(x);
	}
}
int main()
{
	while(scanf("%d",&n)!=EOF&&n)
	{
		bfs();
	}
	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