• 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;
    }
                
    

      

  • 相关阅读:
    2019牛客多校第二场H题(悬线法)
    hdu6212 Zuma(区间dp)
    uva1428树状数组
    UVA1395 (最苗条的最小生成树)
    牛客练习赛53 C题bitset
    Love Live!
    Princess principal
    New Game!- 牛客
    P3311 [SDOI2014]数数
    [HNOI2008]GT考试
  • 原文地址:https://www.cnblogs.com/zero-begin/p/4715305.html
Copyright © 2020-2023  润新知