zoukankan      html  css  js  c++  java
  • toj 2829 cow counting

    一开始想多了,以为应该做个数位dp的,后来想了想也不过100W的数据,直接暴力好像也不慢,于是暴力就过了,还挺快。

     1 #include <iostream>
     2 using namespace std;
     3 
     4 bool judge( int x, int d )
     5 {
     6     while ( x )
     7     {
     8         int r = x % 10;
     9         if ( r == d ) return false;
    10         x = x / 10;
    11     }
    12     return true;
    13 }
    14 
    15 int main ()
    16 {
    17     int n, d;
    18     while ( cin >> n >> d )
    19     {
    20         int cnt = 1;
    21         for ( int i = 1; i <= n; i++ )
    22         {
    23             while ( !judge( cnt, d ) )
    24             {
    25                 cnt++;
    26             }
    27             cnt++;
    28         }
    29         cout << cnt - 1 << endl;
    30     }
    31     return 0;
    32 }
  • 相关阅读:
    POJ1704 Georgia and Bob
    BZOJ1299 巧克力棒
    IPSec
    GRE协议
    L2TP协议
    AAA及Radius
    网络安全概论
    路由策略与引入
    BGP协议
    路由协议
  • 原文地址:https://www.cnblogs.com/huoxiayu/p/4433409.html
Copyright © 2011-2022 走看看