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 |
为什么不是这样呢,我这样过啦//============================================================================ // 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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator