题解

99 条题解

  • 8
    @ 2017-05-08 12:40:01
    /*
    我们看到数据可以达到10000位就知道肯定是有规律可行的
    所以如果实在想不到就多试几个数据找规律叭
    来看个正解
    当游戏状态属于前者时,
    Matrix67可以把糖果数被5除余1、4或正好除尽的那一堆分成糖果数被5除余数都是2或3的两堆
    (他总能做到这一点)
    而对方不得不把其中一堆糖果又分出新的糖果数被5除余1、4或正好除尽的一堆留给Matrix67操作。
    这样逼着对方总是面临必败的状态,使得最后对方不得不把2个糖果或者3个糖果分成两堆,
    从而使Matrix67赢得游戏。
    反过来,当Matrix67面临两堆糖果的数目被5除余数都是2或3的状态时,Shadow总可以取胜。
    所以就是如果两堆的个数的个位数都是2 3 7 8的一个的话
    就是Shadow取胜
    不然就是Matrix
    */
    #include <iostream>
    #include <cstdio>
    #include <algorithm>
    #include <cstring>
    using namespace std;
    
    const int MAXN=10005;
    char a[MAXN];
    char b[MAXN];
    
    int main()
    {
        while(scanf("%s%s",a,b)==2)
        {
            char x=a[strlen(a)-1];
            char y=b[strlen(b)-1];
            if((x=='2'||x=='3'||x=='7'||x=='8')&&(y=='2'||y=='3'||y=='7'||y=='8'))
                printf("Shadow\n");
            else
                printf("Matrix67\n");
        }
        return 0;
    }
    
    
  • 0
    @ 2018-10-16 20:16:01

    #include <iostream>
    using namespace std;

    int main()
    {
    string a;
    string b;
    int n=10;
    for(int i=0;i<n;i++){
    cin>> a >> b;
    int a_hat = (int)a[a.length()-1]-'0';
    int b_hat = (int)b[b.length()-1]-'0';
    if((a_hat % 5 == 2 || a_hat %5 == 3)&&(b_hat % 5 == 2 || b_hat % 5 == 3))
    cout << "Shadow"<<endl;
    else
    cout << "Matrix67"<<endl;
    }
    return 0;
    }

  • 0
    @ 2016-02-17 23:11:45

    Pascal AC
    var a,b,i:longint;
    s,x,c:char;
    begin
    for i:=1 to 10 do begin
    read(c);
    while c<>' ' do
    begin
    s:=c;
    read(c);
    end;
    while not eoln do
    begin
    read(c);
    x:=c;
    end;
    a:=(ord(s)-ord('0')) mod 5;
    b:=(ord(x)-ord('0')) mod 5;
    if ((a=2)or(a=3)) and ((b=2)or(b=3)) then writeln('Shadow')
    else writeln('Matrix67');
    end;
    end.

  • 0
    @ 2016-01-14 19:24:41

    测试数据 #0: Accepted, time = 15 ms, mem = 248 KiB, score = 10
    测试数据 #1: Accepted, time = 0 ms, mem = 252 KiB, score = 10
    测试数据 #2: Accepted, time = 7 ms, mem = 248 KiB, score = 10
    测试数据 #3: Accepted, time = 0 ms, mem = 248 KiB, score = 10
    测试数据 #4: Accepted, time = 0 ms, mem = 248 KiB, score = 10
    测试数据 #5: Accepted, time = 0 ms, mem = 248 KiB, score = 10
    测试数据 #6: Accepted, time = 0 ms, mem = 248 KiB, score = 10
    测试数据 #7: Accepted, time = 15 ms, mem = 252 KiB, score = 10
    测试数据 #8: Accepted, time = 0 ms, mem = 248 KiB, score = 10
    测试数据 #9: Accepted, time = 15 ms, mem = 252 KiB, score = 10
    Accepted, time = 52 ms, mem = 252 KiB, score = 100
    代码
    #include<stdio.h>
    #include<string.h>
    int main()
    {
    char r1,r2,s1[10002],s2[10002];
    while(scanf("%s%s",s1,s2)==2)
    {
    r1=s1[strlen(s1)-1],r2=s2[strlen(s2)-1];
    if((r1=='2'||r1=='3'||r1=='7'||r1=='8')&&(r2=='2'||r2=='3'||r2=='7'||r2=='8'))
    printf("Shadow\n");
    else printf("Matrix67\n");
    }
    }

    唉,这题能不能再水点

  • 0
    @ 2015-02-03 18:52:58

    打表啊打表...
    20
    1111111111111111111
    1001110011100111001
    1001110011100111001
    1111111111111111111
    1111111111111111111
    1111111111111111111
    1001110011100111001
    1001110011100111001
    1111111111111111111
    1111111111111111111
    1111111111111111111
    1001110011100111001
    1001110011100111001
    1111111111111111111
    1111111111111111111
    1111111111111111111
    1001110011100111001
    1001110011100111001
    1111111111111111111
    输入n,m,若 (n+1)%5>=3 且 (m+1)%5>=3 则Shadow赢
    否则Matrix67赢.
    默默地高精模板了....还因为套成高精除法T了一次....
    其实判一下个位就行了嘛.....
    大整数开到2W位过了....

  • 0
    @ 2014-02-02 12:04:23

    program tangguo;
    var
    s:array[1..10]of ansistring;
    a,b,c,d,e,f,g:longint;

    begin

    for g:=1 to 10 do

    begin
    readln(s[g]);
    a:=length(s[g]);
    for b:=1 to a do
    if s[g][b]=' '
    then
    begin
    if (s[g][b-1]='2') or (s[g][b-1]='3') or (s[g][b-1]='7') or (s[g][b-1]='8')
    then if (s[g][a]='2') or (s[g][a]='3') or (s[g][a]='7') or (s[g][a]='8')
    then
    begin
    writeln('Shadow');
    break;
    end
    else
    begin
    writeln('Matrix67');
    break;
    end
    else
    begin
    writeln('Matrix67');
    break;
    end;
    end;
    end;
    end.

    大神求助
    我为啥每次都只能读入一个数据?????

  • 0
    @ 2014-01-23 12:24:13

    打表发现规律了!
    以下是必败状态!
    {2,2} {2,3} {2,7} {2,8}
    {3,2} {3,3} {3,7} {3,8}
    {7,2} {7,3} {7,7} {7,8}
    {8,2} {8,3} {8,7} {8,8}
    {12,2} {12,3} {12,7} {12,8}
    {13,2} {13,3} {13,7} {13,8}
    {17,2} {17,3} {17,7} {17,8}
    {18,2} {18,3} {18,7} {18,8}
    不难发现个位是 2,3,7,8时是先手必败
    组合游戏就是打表找规律吧。

  • 0
    @ 2012-10-21 13:39:53

    ├ 测试数据 01:答案正确... (0ms, 616KB)

    ├ 测试数据 02:答案正确... (0ms, 616KB)

    ├ 测试数据 03:答案正确... (0ms, 616KB)

    ├ 测试数据 04:答案正确... (0ms, 616KB)

    ├ 测试数据 05:答案正确... (0ms, 616KB)

    ├ 测试数据 06:答案正确... (0ms, 616KB)

    ├ 测试数据 07:答案正确... (0ms, 616KB)

    ├ 测试数据 08:答案正确... (0ms, 1244KB)

    ├ 测试数据 09:答案正确... (0ms, 1244KB)

    ├ 测试数据 10:答案正确... (0ms, 1244KB)

    ---|---|---|---|---|---|---|---|-

    Accepted / 100 / 0ms / 1244KB

    改了三次,才发现 对于100%的数据,糖果小于10000“位”

    可怜我开的都是string……

    {

    ID:darkgod-z

    PROG:vijos P1196

    HANG:PASCAL

    }

    var

    a,b,i:integer;

    s1,s2:ansistring;

    ch:char;

    begin

    for i:=1 to 10 do begin

    read(ch);

    while ch' ' do begin

    s1:=s1+ch;

    read(ch);

    end;

    read(ch);

    while ord(ch)13 do begin

    s2:=s2+ch;

    read(ch);

    end;

    a:=(ord(s1[length(s1)])-ord('0')) mod 5;

    b:=(ord(s2[length(s2)])-ord('0')) mod 5;

    if ((a=2)or(a=3)) and ((b=2)or(b=3)) then writeln('Shadow')

    else writeln('Matrix67');

    s1:='';

    s2:='';

    end;

    end.

  • 0
    @ 2009-11-18 19:57:45

    以下是我第一次交的程序

    #include

    #include

    using namespace std;

    int main ()

    {

    int i,j;

    int i1,j1;

    string st1,st2;

    for (i=1;i>st1>>st2;

    i1=st1[st1.size()-1]-'0';j1=st2[st2.size()-2]-'0';

    if ((i1==2||i1==3||i1==7||i1==8)&&(j1==2||j1==3||j1==7||j1==8))

    cout

  • 0
    @ 2009-11-14 21:38:35

    本来是做1655的,做完看了题解,发现居然是盗版1196了,结果差点晕死,,,,,,,,,,

    超级Orz

  • 0
    @ 2009-11-07 20:39:13

    为什么要被5除啊

    谁能解释一下

  • 0
    @ 2009-11-06 21:53:21

    当游戏状态属于前者时,Matrix67可以把糖果数被5除余1、4或正好除尽的那一堆分成糖果数被5除余数都是2或3的两堆(他总能做到这一点),而对方不得不把其中一堆糖果又分出新的糖果数被5除余1、4或正好除尽的一堆留给Matrix67操作。这样逼着对方总是面临必败的状态,使得最后对方不得不把2个糖果或者3个糖果分成两堆,从而使Matrix67赢得游戏。反过来,当Matrix67面临两堆糖果的数目被5除余数都是2或3的状态时,Shadow总可以取胜。

    --不愧是Matrix67大牛,讲的很透彻!

  • 0
    @ 2009-11-06 17:18:11

    跟最小非负值解法差不多

  • 0
    @ 2009-11-01 15:37:11

    program t1196(input,output);

    var c,c1,c2:char;

    i:longint;

    ab:set of '0'..'9';

    begin

    ab:=['2','3','7','8'];

    for i:=1 to 10 do

    begin

    read(c);

    while c' ' do

    begin

    c1:=c;

    read(c);

    end;

    read(c);

    while ord(c)13 do

    begin

    c2:=c;

    read(c);

    end;

    if (c1 in ab) and (c2 in ab)

    then writeln('Shadow')

    else writeln('Matrix67');

    end;

    end.

    ……………………

  • 0
    @ 2009-11-01 12:33:52

    Flag   Accepted

    题号   P1196

    类型(?)   博弈论

    通过   2000人

    提交   3978次

    通过率   50%

    难度   1

    第2000个通过哈...

    要用字符串读入...

    否则只有70分...

  • 0
    @ 2009-10-13 21:08:25

    编译通过...

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ├ 测试数据 06:答案正确... 0ms

    ├ 测试数据 07:答案正确... 0ms

    ├ 测试数据 08:答案正确... 0ms

    ├ 测试数据 09:答案正确... 0ms

    ├ 测试数据 10:答案正确... 0ms

    ---|---|---|---|---|---|---|---|-

    Accepted 有效得分:100 有效耗时:0ms

    好水的题~~~~~~

  • 0
    @ 2009-10-01 22:25:19

    先考虑只有一堆

    显然如果该堆1,4,5胜利,2,3败

    对于任意较大的堆,只要能够分出2堆,满足两堆都会失败,那么就可以获胜

    于是就有了递推方法,但如果这样死推必然超时爆空间

    所以推前面的看,发现了规律。。

  • 0
    @ 2009-10-01 21:54:12

    AC>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

    var ch1,ch2,ch:char;

    num:set of char;

    i:longint;

    begin

    num:=['2','3','7','8'];

    for i:=1 to 10 do

    begin

    read(ch);

    ch1:=ch;

    while ch' ' do

    begin

    ch1:=ch;

    read(ch);

    end;

    read(ch2);

    while not(eoln) do read(ch2);

    if (ch1 in num)and(ch2 in num) then writeln('Shadow') else writeln('Matrix67');

    readln;

    end;

    end.

  • 0
    @ 2009-10-01 13:28:42

    编译通过...

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ├ 测试数据 06:答案正确... 0ms

    ├ 测试数据 07:答案正确... 0ms

    ├ 测试数据 08:答案正确... 0ms

    ├ 测试数据 09:答案正确... 0ms

    ├ 测试数据 10:答案正确... 0ms

    ---|---|---|---|---|---|---|---|-

    Accepted 有效得分:100 有效耗时:0ms

  • 0
    @ 2009-09-07 22:36:18

    编译通过...

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ├ 测试数据 06:答案正确... 0ms

    ├ 测试数据 07:答案正确... 0ms

    ├ 测试数据 08:答案正确... 72ms

    ├ 测试数据 09:答案正确... 72ms

    ├ 测试数据 10:答案正确... 56ms

    ---|---|---|---|---|---|---|---|-

    Accepted 有效得分:100 有效耗时:200ms

    Sunny ka!

信息

ID
1196
难度
4
分类
博弈论 点击显示
标签
(无)
递交数
2198
已通过
979
通过率
45%
被复制
6
上传者