zoukankan      html  css  js  c++  java
  • Luogu3090 [USACO13NOV]空荡荡的摊位Empty Stalls (动态规划)

    #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 Max(a,b) ((a) > (b) ? (a) : (b))
    #define Min(a,b) ((a) < (b) ? (a) : (b))
    #define Fill(a,b) memset(a, b, sizeof(a))
    #define Swap(a,b) a^=b^=a^=b
    #define ll long long
    #define ON_DEBUG
    
    #ifdef ON_DEBUG
    
    #define D_e_Line printf("
    
    ----------
    
    ")
    #define D_e(x)  cout << #x << " = " << x << endl
    #define Pause() system("pause")
    
    #else
    
    #define D_e_Line ;
    
    #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;
    
    int f[3000007];
    
    int main(){
    	int n, m;
    	io >> n >> m;
    	R(i,1,m){
    		int x, y, a, b;
    		io >> x >> y >> a >> b;
    		R(j,1,y)
    			f[1ll * (1ll * a * j + b) % n] += x;
    	}
    	
    	int flag = false;
    	while(!flag || f[0] > 1){
    		R(i,0,n - 1){
    			if(f[i] > 1){
    				f[(i + 1) % n] += f[i] - 1;
    				f[i] = 1;
    			}	
    		}
    		flag = true;
    	}
    	
    	R(i,0,n){
    		if(f[i] == 0){
    			printf("%d", i);
    			return 0;
    		}
    	}
    	
    	return 0;
    }
    

  • 相关阅读:
    chrome 浏览器设置useragent为微信浏览器
    js 16进制颜色和RGBA颜色互转
    json parse 大数精度丢失
    taro 小程序react 搜索高亮关键字
    sourcetree 配置 openssh
    一次性卸载npm本地包(node_modules)依赖
    微信小程序订阅消息开发总结
    微信小程序请求设置权限
    taro
    浅谈JS之AJAX
  • 原文地址:https://www.cnblogs.com/bingoyes/p/11206370.html
Copyright © 2011-2022 走看看