zoukankan      html  css  js  c++  java
  • LuoguP2953 [USACO09OPEN]牛的数字游戏Cow Digit Game(博弈论)

    1~9显然,后面平(A)过去

    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <algorithm>
    #include <cmath>
    #define R(a,b,c) for(register int a = (b); a <= (c); ++a)
    #define nR(a,b,c) for(register int a = (b); a >= (c); --a)
    #define Fill(a,b) memset(a, b, sizeof(a))
    #define Swap(a,b) ((a) ^= (b) ^= (a) ^= (b))
    
    #define ON_DEBUGG
    
    #ifdef ON_DEBUGG
    
    #define D_e_Line printf("-----------
    ")
    #define D_e(x) std::cout << (#x) << " : " <<x << "
    "
    #define FileOpen() freopen("in.txt", "r", stdin)
    #define FileSave() freopen("out2.txt", "w", stdout)
    #define Pause() system("pause")
    #include <ctime>
    #define TIME() fprintf(stderr, "
    TIME : %.3lfms
    ", clock() * 1000.0 / CLOCKS_PER_SEC)
    
    #else
    
    #define D_e_Line ;
    #define D_e(x) ;
    #define FileOpen() ;
    #define FilSave ;
    #define Pause() ;
    #define TIME() ;
    
    #endif
    
    struct ios {
    	template<typename ATP> ios& operator >> (ATP &x) {
    		x = 0; int f = 1; char c;
    		for(c = getchar(); c < '0' || c > '9'; c = getchar()) if(c == '-') f = -1;
    		while(c >= '0' && c <= '9') x = x * 10 + (c ^ '0'), c = getchar();
    		x *= f;
    		return *this;
    	}
    }io;
    
    using namespace std;
    
    template<typename ATP> inline ATP Min(ATP a, ATP b) {
    	return a < b ? a : b;
    }
    template<typename ATP> inline ATP Max(ATP a, ATP b) {
    	return a > b ? a : b;
    }
    template<typename ATP> inline ATP Abs(ATP a) {
    	return a < 0 ? -a : a;
    }
    
    const int N = 1000007;
    
    int maxx, minn;
    inline void Calc(int n) {
    	while(n){
    		int tmp = n % 10;
    		maxx = Max(maxx, tmp);
    		if(tmp) minn = Min(minn, tmp);
    		n /= 10;
    	}
    }
    
    int f[N];
    
    int main() {
    	R(i,1,9) f[i] = true; 
    	R(i,10,N - 5){
    		maxx = 0, minn = 10;
    		Calc(i);
    		if(!(f[i - maxx] && f[i - minn]))
    			f[i] = true;
    	}
    	int Tasks;
    	io >> Tasks;
    	while(Tasks--){
    		int n;
    		io >> n;
    		if(f[n])
    			printf("YES
    ");
    		else
    			printf("NO
    ");
    	}
    	return 0;
    }
    

  • 相关阅读:
    python基础 2
    python基础 1
    进程
    进程作业
    上海python14期第二次阶段性考试
    面向对向之元类
    面向对向
    笔试题
    模块(2)
    模块作业
  • 原文地址:https://www.cnblogs.com/bingoyes/p/11710823.html
Copyright © 2011-2022 走看看