5030. A

题目大意

给定长度为1,2,3,4的砖块 a,b,c,d 个,两个人轮流操作。
每次可以选择一个长度大于1的砖头分成两个砖头,或者选择 n 个长度为n的砖头粉碎。
无法操作的人数。询问先手是否必胜。

Data Constraint
a,b,c,d1010000

题解

打表可以发现,先手必败当且仅当 (a+c)%2=(b+d)%3
然后就没了。

SRC

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<map>
using namespace std ;

#define N 10000 + 10

char s[N] ;

int a[N] , b[N] , c[N] , d[N] ;
int Case ;

void Read( int *t ) {
    scanf( "%s" , s + 1 ) ;
    t[0] = strlen( s + 1 ) ;
    for (int i = 1 ; i <= t[0] ; i ++ ) t[i] = s[i] - '0' ;
}

int Modular( int *a , int MO ) {
    if ( a[0] == 1 ) return a[1] % MO ;
    for (int i = 1 ; i <= a[0] ; i ++ ) {
        if ( a[i] < MO ) a[i+1] += a[i] * 10 ;
        else {
            a[i+1] += a[i] % MO * 10 ;
            a[i] /= MO ;
        }
    }
    return a[a[0]+1] / 10 ;
}

int main() {
    freopen( "a.in" , "r" , stdin ) ;
    freopen( "a.out" , "w" , stdout ) ;
    scanf( "%d" , &Case ) ;
    for (int i = 1 ; i <= Case ; i ++ ) {
        memset( a , 0 , sizeof(a) ) ;
        memset( b , 0 , sizeof(b) ) ;
        memset( c , 0 , sizeof(c) ) ;
        memset( d , 0 , sizeof(d) ) ;
        Read( a ) , Read( b ) , Read( c ) , Read( d ) ;
        int a1 = Modular( a , 2 ) ;
        int b1 = Modular( b , 3 ) ;
        int c1 = Modular( c , 2 ) ;
        int d1 = Modular( d , 3 ) ;
        if ( (a1 + c1) % 2 == (b1 + d1) % 3 ) printf( "0\n" ) ;
        else printf( "1\n" ) ;
    }
    return 0 ;
}

以上.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值