zoukankan      html  css  js  c++  java
  • CodeForces1209B

    CodeForces1209B

    水题,枚举就好了,我枚举到了129个周期.
    别忘了一个灯如果亮了就会一直亮着除非到下次改变状态.

    #include <algorithm>
    #include <iostream>
    #include <cstdlib>
    #include <cstring>
    #include <cstdio>
    #include <string>
    #include <vector>
    #include <queue>
    #include <cmath>
    #include <ctime>
    #include <map>
    #include <set>
    #define MEM(x,y) memset ( x , y , sizeof ( x ) )
    #define rep(i,a,b) for (int i = (a) ; i <= (b) ; ++ i)
    #define per(i,a,b) for (int i = (a) ; i >= (b) ; -- i)
    #define pii pair < int , int >
    #define one first
    #define two second
    #define rint read<int>
    #define int long long
    #define pb push_back
    
    using std::queue ;
    using std::set ;
    using std::pair ;
    using std::max ;
    using std::min ;
    using std::priority_queue ;
    using std::vector ;
    using std::swap ;
    using std::sort ;
    using std::unique ;
    using std::greater ;
    
    template < class T >
        inline T read () {
            T x = 0 , f = 1 ; char ch = getchar () ;
            while ( ch < '0' || ch > '9' ) {
                if ( ch == '-' ) f = - 1 ;
                ch = getchar () ;
            }
           while ( ch >= '0' && ch <= '9' ) {
                x = ( x << 3 ) + ( x << 1 ) + ( ch - 48 ) ;
                ch = getchar () ;
           }
       return f * x ;
    }
    
    const int N = 1e2 + 10 ;
    const int M = 5e3 + 10 ;
    int on[M] , ans ;
    int n , p[N][2] ;
    char s[N] ;
    
    signed main (int argc , char * argv[]) {
        n = rint () ; scanf ("%s" , s + 1 ) ;
        rep ( i , 1 , n ) { p[i][0] = rint () ; p[i][1] = rint () ; }
        rep ( i , 1 , n ) if ( s[i] == '1' ) rep ( j , 0 , p[i][1] - 1 ) ++ on[j] ;
        rep ( i , 1 , n ) {
            bool f = ( s[i] == '1' ) ; int tot = 0 ;
            for (int j = p[i][1] ; tot <= 129 ; j += p[i][0]) {
                f ^= 1 ; ++ tot ;
                if ( f ) rep ( k , j , j + p[i][0] - 1 ) ++ on[k] ;
            }
        }
        rep ( i , 0 , M - 1 ) ans = max ( ans , on[i] ) ;
        printf ("%lld
    " , ans ) ;
        return 0 ;
    }
    
    May you return with a young heart after years of fighting.
  • 相关阅读:
    数据结构第二篇——线性表的顺序存储
    数据结构第一篇——线性表的逻辑结构
    面向对象之工资管理系统
    #ifndef三件套与#pragma once
    i++与++i的区别
    struct与class的区别(分别在c和c++中)
    浅析数据结构
    K60
    更新整理本人所有博文中提供的代码与工具(Java,2013.08)
    [置顶] cocos2d实现CCLabelTTF真正字体描边效果
  • 原文地址:https://www.cnblogs.com/Equinox-Flower/p/11536029.html
Copyright © 2011-2022 走看看