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:史上最短的搜索代码!bfs和dfs都很简单!

Posted by 2011550321 at 2013-02-09 01:14:45 on Problem 1426
In Reply To:史上最短的搜索代码!bfs和dfs都很简单! Posted by:chenxuan123456789 at 2012-11-04 11:36:43
> #include <iostream>
> #include <queue>
> using namespace std;
> int n;
> long long bfs()
> {
>      queue<long long> p;
>      while(!p.empty())
>      p.pop();
>      p.push(1);
>      while(1)
>      {
>              long long sum=p.front();
>              if(sum%n==0)
>              return sum;
>              p.pop();
>              p.push(10*sum);
>              p.push(10*sum+1);
>      }
> }
> int main()
> {
>     while(cin>>n,n)
>     {
>                    cout<<bfs()<<endl;
>     }
>     return 1;
> }

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