题解

133 条题解

  • 3
    @ 2017-09-14 23:38:54
    #include <iostream>
    #include <cstdio>
    #include <cstdlib>
    #include <cstring>
    #include <cmath>
    using namespace std;
    //先取的人可以比较所有奇数位置数之和与所有偶数位置之和,哪个大就一直取相应的位置上的数....注意N为整数
    //
    //比如,6 1000 564 48 400 2
    //
    //奇数位置和为6+564+400=970 偶数位置和为1000+48+2=1050>970
    //
    //故先去的人可以先取2 后取的必定在奇数位置上取数(他只能取奇数位置的了)
    //
    //PS:先取的不一定是当前最优.......
    int main()
    {
        int k,q;
        scanf("%d",&k);
        for(q=1;q<=k;q++)
        {
            int n,who;
            int a;
            scanf("%d\n%d\n",&n,&who);
            for(int i=1;i<=n;i++)
            {
                scanf("%d",&a);
            }
            if(who==0)
                printf("wind\n");
            else
                printf("lolanv\n");
        }
        return 0;
    }
    
  • 0
    @ 2018-03-11 08:48:00

    搞不明白为什么java总是超时,即使用nextLine(),整个代码的时间才O(k),但是过不了,而用c的话要两层嵌套,却能过。难道是底层的机制问题?不知道有没有人能够讲解!!!!

    
    #include <stdio.h>
    int main(int argc, char const *argv[])
    {
        int k,q;
        scanf("%d",&k);
        while(k != 0)
        {
            int n,who;
            int a;
            scanf("%d\n%d\n",&n,&who);
            for(int i=1;i<=n;i++)
            {
                scanf("%d",&a);
            }
            if(who==0)
                printf("wind\n");
            else
                printf("lolanv\n");
            k--;
        }
        return 0;
    }
    
  • 0
    @ 2017-09-17 18:41:52
    //注意不要超时就好
    #include<cstdio>
    using namespace std;
    int ans[11];
    int main()
    {
        int i,n,k,j,a;
        scanf("%d",&k);
        for(j=1;j<=k;j++)
        {
            scanf("%d",&n);
            scanf("%d",&ans[j]);
            for(i=1;i<=n;i++)
             scanf("%d",&a);
        }
        for(i=1;i<=k;i++)
         if(!ans[i])
          printf("wind\n");
         else
          printf("lolanv\n");
        return 0;
    }
    
  • 0
    @ 2016-02-26 22:10:30

    var i,m,k:longint;
    begin
    readln(k);
    for i:=1 to k do
    begin
    readln;
    readln(m);
    readln;
    if m=1 then writeln('lolanv') else writeln('wind');
    end;
    end.

  • 0
    @ 2015-07-31 16:00:20

    测试数据 #0: Accepted, time = 3 ms, mem = 500 KiB, score = 10
    测试数据 #1: Accepted, time = 0 ms, mem = 504 KiB, score = 10
    测试数据 #2: Accepted, time = 1 ms, mem = 496 KiB, score = 10
    测试数据 #3: Accepted, time = 0 ms, mem = 504 KiB, score = 10
    测试数据 #4: Accepted, time = 1 ms, mem = 500 KiB, score = 10
    测试数据 #5: Accepted, time = 15 ms, mem = 496 KiB, score = 10
    测试数据 #6: Accepted, time = 50 ms, mem = 500 KiB, score = 10
    测试数据 #7: Accepted, time = 31 ms, mem = 500 KiB, score = 10
    测试数据 #8: Accepted, time = 312 ms, mem = 500 KiB, score = 10
    测试数据 #9: Accepted, time = 328 ms, mem = 500 KiB, score = 10
    Accepted, time = 741 ms, mem = 504 KiB, score = 100
    代码
    #include<cstdio>
    #include<cmath>
    using namespace std;
    int main()
    {
    int k,n,m,i,s=0,ans=0,a;
    scanf("%d",&k);
    while(k--)
    {
    scanf("%d",&n);
    scanf("%d",&m);
    for(i=1;i<=n;i++)scanf("%d",&a);
    if(m==1)printf("lolanv\n");
    else printf("wind\n");
    }
    return 0;
    }

    谁先取,谁就赢。

  • 0
    @ 2015-02-02 14:16:31

    1.必须用scanf才能过。
    2.让后手取奇数还是偶数的权力掌握在先手的手中。
    3.这道题说明我缺乏一种整体思考的观念。只善于微观分析、不善于整体把握。
    #include<iostream>
    #include<stdio.h>
    using namespace std;

    int main(){
    char name[][10] = { "wind", "lolanv" };
    int t;
    cin >> t;
    int size, who;
    while (t-- > 0){
    cin >> size >> who;
    int i,j;
    for (i = 0; i < size; i++)
    scanf("%d", &j);
    cout << name[who] << endl;
    }
    return 0;
    }

  • 0
    @ 2013-08-24 13:30:45

    一遍AC
    var i,j,k,l,b,n,shou,mo:longint;
    wind,lolanv:int64;
    a:array[1..100000] of longint;
    begin
    readln(k);
    for i:=1 to k do
    begin
    wind:=0;
    lolanv:=0;
    shou:=1;
    readln(n);
    mo:=n;
    readln(b);
    for j:=1 to n do read(a[i]);
    for l:=1 to n do
    begin
    if a[shou]<a[mo] then begin
    if ((l mod 2=1) and (b=0)) or ((l mod 2=0) and (b=1)) then begin wind:=wind+a[mo]; dec(mo); end;
    if ((l mod 2=1) and (b=1)) or ((l mod 2=0) and (b=0)) then begin lolanv:=lolanv+a[mo]; dec(mo); end;
    end
    else begin
    if ((l mod 2=1) and (b=0)) or ((l mod 2=0) and (b=1)) then begin wind:=wind+a[shou]; inc(shou); end;
    if ((l mod 2=1) and (b=1)) or ((l mod 2=0) and (b=0)) then begin lolanv:=lolanv+a[shou]; inc(shou); end;
    end;
    end;
    if wind<lolanv then writeln('lolanv')
    else writeln('wind');
    end;
    end.

  • 0
    @ 2010-04-09 19:40:26

    n 为偶数,先取数的人可以保证对方只能拿到奇数编号或是偶数编号的数

    先手必胜

    之前是 Vijos Mini 评测,最后两个数据超时

  • 0
    @ 2009-10-08 20:06:51

    把所有数分成奇数和偶数 那么总和总有一个是大的

    所以第一个人选择取最后一个(偶数组)或者第一个(奇数组)肯定获胜

    数相等也是一样

  • 0
    @ 2009-09-23 20:06:07

    OTL lolanv的题解,果然有理

    博弈论真是简单

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

    var

    n,k,i:longint;

    begin

    assign(input,filename+'.in');reset(input);

    assign(output,filename+'.out');rewrite(output);

    readln(k);

    for i:=1 to k do

    begin

    readln(n);

    readln(n);

    if odd(n)then writeln('lolanv')else writeln('wind');

    readln;

    end;

    close(input);close(output);

    end.

  • 0
    @ 2009-09-20 09:32:00

    额。。。。。。。。

    我晕。。。。

    编译通过...

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

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

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

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

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

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

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

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

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

    ├ 测试数据 10:运行超时...

  • 0
    @ 2009-09-16 12:44:56

    编译通过...

    ├ 测试数据 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-13 11:02:23

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

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

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

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

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

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

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

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

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

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

    最后两组很大?

  • 0
    @ 2009-09-12 23:15:03

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

    iostream超两个点

    cstdio.....

    O(1)还超时,囧

  • 0
    @ 2009-09-10 17:50:55

    先取的一定赢!

    不在free pascal上编译都能一次性AC

  • 0
    @ 2009-08-18 15:36:33

    简直太失败了!

    我无视了“如果两人的和一样多,先取者胜”这句话!

    其实先取的一定赢!(道理自己想)

    =======================晒程序===================================

    var

    k,n,i,l,j,a:longint;

    begin

    readln(k);

    for i:=1 to k do begin

    readln(n);

    readln(l);

    for j:=1 to n do read(a);

    if l=1 then writeln('lolanv') else writeln('wind');

    end;

    end.

  • 0
    @ 2009-08-11 21:49:47

    输入格式 Input Format

    第一行为一个数k(k

  • 0
    @ 2009-08-08 14:45:59

    var a,w,x:array[1..1000] of longint;

    k,v,gs,hm,o,p,i:longint;

    begin

    readln(k);

    for v:=1 to k do

    begin

    readln(gs);

    readln(hm);

    for i:=1 to gs do

    read(a[i]);

    o:=1; p:=i;

    if hm=0 then

    begin

    for i:=1 to gs do

    begin

    if i mod 20 then

    begin

    if a[o]>a[p] then w[v]:=w[v]+a[o]

    else w[v]:=w[v]+a[p];

    if a[o]>a[p] then o:=o+1

    else p:=p-1;

    end;

    if i mod 2=0 then

    begin

    if a[o]>a[p] then x[v]:=x[v]+a[o]

    else x[v]:=x[v]+a[p];

    if a[o]>a[p] then o:=o+1

    else p:=p-1;

    end;

    end;

    end;

    if hm=1 then

    begin

    for i:=1 to gs do

    begin

    if i mod 20 then

    begin

    if a[o]>a[p] then x[v]:=x[v]+a[o]

    else x[v]:=x[v]+a[p];

    if a[o]>a[p] then o:=o+1

    else p:=p-1;

    end;

    if i mod 2=0 then

    begin

    if a[o]>a[p] then w[v]:=w[v]+a[o]

    else w[v]:=w[v]+a[p];

    if a[o]>a[p] then o:=o+1

    else p:=p-1;

    end;

    end;

    end;

    end;

    for v:=1 to k do

    if x[v]>w[v] then writeln('lolanv')

    else writeln('wind');

    end.

  • 0
    @ 2009-07-31 13:55:19

    因为先取者可以取到所有奇数位上的或所有偶数位上的数,

    所以,当奇数位的所有数的和大时,取奇数位,偶数位大取偶数位,

    若相等,还是先取者胜,所以。。。

    当然,因为N是偶数才有这样的贪心策略,否则,得用DP了。。

  • 0
    @ 2009-07-26 15:57:10

    I love 水题!

信息

ID
1281
难度
3
分类
博弈论 点击显示
标签
(无)
递交数
1764
已通过
900
通过率
51%
被复制
4
上传者