zoukankan      html  css  js  c++  java
  • L1-033 出生年

    不难,代码:

    #include <queue>  
    #include <functional>  
    #include <stdio.h>  
    #include <string.h>  
    #include <iostream>  
    #include <algorithm>  
    #include <stack>  
    #include <vector>  
    #include <set>  
    #include <map>  
    #include <string>  
    #include <cmath>  
    #include <cstdlib>  
    #include <ctime>  
    #include <assert.h>  
    using namespace std;  
    /*题意: 
      当前年份为a,求当前和未来最近的某一年,年份各位数字的不同个数等于b 
    */  
    #define N 1005  
    inline int f(int a)  
    {  
       int aa = a % 10;  
       a /=10;  
       int bb = a % 10;  
       a /=10;  
       int cc = a % 10;  
       a /= 10;  
       int dd = a;  
      
       int ans = 1;  
       if(aa!=bb && aa != cc && aa != dd) ans++;  
       if(bb!=cc && bb != dd) ans++;  
       if(cc != dd) ans++;  
       return ans;  
    }  
    int main()  
    {  
          int a,b;  
          scanf("%d%d",&a,&b);  
          int cot = 0;  
          while(1){  
             if(f(a) == b) break;  
             a++;  
             cot++;  
          }  
          printf("%d %04d",cot,a);  
          return 0;  
    }  
  • 相关阅读:
    凸包模板
    1060E Sergey and Subway(思维题,dfs)
    1060D Social Circles(贪心)
    D
    牛客国庆集训派对Day2
    网络流
    Tarjan算法(缩点)
    莫队分块算法
    计算几何
    hdu5943素数间隙与二分匹配
  • 原文地址:https://www.cnblogs.com/nr1999/p/8604281.html
Copyright © 2011-2022 走看看