zoukankan      html  css  js  c++  java
  • POJ1426——DFS——Find The Multiple

    http://poj.org/problem?id=1426

    /*
    暴力发现最大数目不超过19位,开unsigned long long 水过
    */
    /************************************************
    * Author        :Powatr
    * Created Time  :2015-8-9 15:30:37
    * File Name     :E.cpp
     ************************************************/
    
    #include <cstdio>
    #include <algorithm>
    #include <iostream>
    #include <sstream>
    #include <cstring>
    #include <cmath>
    #include <string>
    #include <vector>
    #include <queue>
    #include <deque>
    #include <stack>
    #include <list>
    #include <map>
    #include <set>
    #include <bitset>
    #include <cstdlib>
    #include <ctime>
    using namespace std;
    
    #define lson l, mid, rt << 1
    #define rson mid + 1, r, rt << 1 | 1
    typedef long long ll;
    const int MAXN = 1e5 + 10;
    const int INF = 0x3f3f3f3f;
    const int MOD = 1e9 + 7;
    int n;
    queue <unsigned long long > q;
    unsigned long long  bfs(){
        while(!q.empty()) q.pop();
        q.push(1);
        while(!q.empty()){
            unsigned long long x = q.front();
            q.pop();
            if(x % n == 0)  return x;
            q.push(x*10);
            q.push(x*10 + 1);
        }
    }
    int main(){
        while(~scanf("%d", &n) && n){
            printf("%llu
    ", bfs());
        }
        return 0;
    }
                
    

      

  • 相关阅读:
    condition精准控制
    Juc(上)
    算法和空间复杂度分析
    ReentrantLock
    死锁
    互斥锁
    线程常用方法
    多线程售票与同步机制
    线程的7种状态
    selenium 自动刷司法课
  • 原文地址:https://www.cnblogs.com/zero-begin/p/4715305.html
Copyright © 2011-2022 走看看