130 条题解

  • 7
    @ 2008-11-04 21:39:42

    额...转下别人的证明,的确很弱....

    最少步数的前提

    1:在任何一步中,两族青蛙的状态或不动或向对方运动

    2:任何一步都是可逆的

    设n为每族青蛙的“蛙”数

    A:先不考虑‘借助前面青蛙的背,跳到前面青蛙的前面一格’的情况,即每次只能跳1格(此时假设多只青蛙可以站在同一格),那么任何一族的所有青蛙共需要跳n*(n+1)次(平均思想,即平均每只都跳n+1次),所以两族一共要跳2*n*(n+1)次;

    B:但是由于‘多只青蛙可以站在同一格’是有悖与题目的,所以再来考虑‘借助前面青蛙的背,跳到前面青蛙的前面一格’的情况。这种情况每发生一次,有一只青蛙就可以跳2个,即可以比A少跳1次。又因为两族的青蛙都会一对一的挡在对方前面,所以共有n*n次情况发生,即可以比A少跳n*n次。同时,这种情况不会多于n*n,原因如下:

    若有一只青蛙跳了n次后,还要跳一次,那么他有2种选择:

    1.跳过对方青蛙:这样,就不满足前提1

    2.跳过对方青蛙:这样,就不满足前提2(况且他的前面是不会有空位的,因为无法产生这种空位,例:00_xx ---|> _xx00 是不可能的~~~)

    综上所述,最少步数m=2*n*(n+1)-n*n=n*n+2*n

  • 6
    @ 2015-01-10 13:55:22

    高中里的数列。

    首先粗看题目。毫无头绪。但是隐约知道应该是有公式。
    弄几个硬币,正反,容易走出分别是1 2 3个硬币的时候是3 8 15,而且你发现似乎只有这一种答案,因为一旦2个一样的棋子在
    中间遇到,就走不出了,得回退,肯定不是最优解。

    所以玩的方法就是中间这个空地上任何时刻有棋子在的时候,它旁边必定要么没棋子,要么是另一种棋子!
    虽然不知道这个结论有什么用,但至少你可以很快走出3 8 15.

    然后我们对其观察,粗看是看不出,但是全部+1呢?
    4 9 16
    哇,这太TM明显了有没有?

    因此很容易得出通项公式
    An=(n+1)^2-1;

    好像曾经是看过这个游戏的一些解释的。但是忘记了,记得隐约以前玩过。

    当然上面那个结论可以用来搜索的时候剪枝,就是麻烦了- -

    ###blcok code
    program ex;
    var n:longint;
    begin //main
    read(n);
    inc(n); n:=n*n-1;
    write(n);
    end.

  • 3
    @ 2017-10-04 00:37:51

    公式无敌。
    #include<iostream>
    using namespace std;

    int n;

    int main(){
    cin>>n;
    cout<<n*n+2*n;
    return 0;
    }

    • @ 2022-08-28 21:14:56

      Wrong Answer
      Hydro提供评测服务

      状态 耗时 内存占用

      #1 Wrong Answer Read 3410, expect 8. 3ms 256.0 KiB
      #2 Wrong Answer Read 12506, expect 120. 2ms 384.0 KiB
      #3 Wrong Answer Read 114836, expect 10200. 1ms 256.0 KiB
      #4 Wrong Answer Read 569636, expect 251000. 2ms 256.0 KiB
      #5 Wrong Answer Read 1138136, expect 1002000. 2ms 368.0 KiB
      #6

      请你解释一下

  • 1
    @ 2025-12-07 11:33:59
    #include<bits/stdc++.h>
    using namespace std;
    long long n;
    int main(){
      cin>>n;
        cout<<n*n+2*n;
    }
    
  • 1
    @ 2021-02-05 19:38:03

    (来这吐槽一句。。)
    看过物理书都知道,任何携带能量或信息的物体都无法超过光速。。。。(不是常识吗)

  • 0
    @ 2017-11-23 13:41:33

    #include<stdio.h>
    int main(){
    int n;
    scanf("%d", &n);
    printf("%d", n*n+2*n);
    return 0;
    }

  • 0
    @ 2017-10-31 21:49:21

    2*n*(n+1)-1*n*n

  • 0
    @ 2017-07-23 11:01:45

    #include <iostream>
    #include <iomanip>
    #include <cmath>
    #include <cstdio>
    #include <cstring>
    #include <cstdlib>
    #include <algorithm>
    #include <cctype>
    #include <vector>
    #include <queue>
    #include <set>
    #include <bitset>
    #include <cassert>
    #include <map>
    #include <string>
    #include <sstream>
    #include <ctime>
    using namespace std;
    int main()
    {
    int n;
    scanf("%d",&n);
    printf("%d",n*(n+2));
    return 0;
    }

    • @ 2018-08-18 15:48:02

      这个头文件给满分。。。

    • @ 2024-07-11 22:20:58

      #include<bits/stdc++.h>

  • 0
    @ 2017-07-14 10:45:01

    星际青蛙SSSSSSSSSSSSSS
    (弱弱版)
    var
    n:longint;
    begin
    readln(n);
    writeln((n+1)*(n+1)-1);
    end.
    //公式:(n+1)2-1或n2+2n.
    (木木板)
    var
    a,b:qword;//要开int64或qword。
    begin
    readln(a,b);
    writeln((a+1)*(b+1)-1);
    end.
    //公式:(a+1)(b+1)-1或ab+a+b.

  • 0
    @ 2017-07-14 10:44:45

    星际青蛙SSSSSSSSSSSSSS
    (弱弱版)
    var
    n:longint;
    begin
    readln(n);
    writeln((n+1)*(n+1)-1);
    end.
    //公式:(n+1)2-1或n2+2n.
    (木木板)
    var
    a,b:qword;//要开int64或qword。
    begin
    readln(a,b);
    writeln((a+1)*(b+1)-1);
    end.
    //公式:(a+1)(b+1)-1或ab+a+b.

  • 0
    @ 2017-01-12 15:58:50

    #include<stdio.h>
    int main()
    {
    int n,m=0,a;
    scanf("%d",&n);
    a=2*n*(n+1);
    m+=2*n;
    a-=2*n;
    m+=a/2;
    printf("%d",m);
    return 0;
    }
    答案正确,但怎么证明?

  • 0
    @ 2016-08-13 14:38:22

    Pascal Code

    var
      n:longint;
    begin
      readln(n);
      writeln(sqr(n+1)-1);
    end.
    

    纯 净 水 !

  • 0
    @ 2016-04-03 19:50:46

    var n:longint;
    begin read(n); write(n*n+n*2); end.

  • 0
    @ 2016-03-22 07:28:25

    编译成功

    foo.cpp:3:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    main()
    ^

    测试数据 #0: Accepted, time = 0 ms, mem = 552 KiB, score = 5

    测试数据 #1: Accepted, time = 0 ms, mem = 552 KiB, score = 15

    测试数据 #2: Accepted, time = 0 ms, mem = 556 KiB, score = 15

    测试数据 #3: Accepted, time = 0 ms, mem = 556 KiB, score = 20

    测试数据 #4: Accepted, time = 0 ms, mem = 556 KiB, score = 20

    测试数据 #5: Accepted, time = 0 ms, mem = 556 KiB, score = 25

    Accepted, time = 0 ms, mem = 556 KiB, score = 100

  • 0
    @ 2016-02-17 18:17:48

    Pascal AC
    var n:longint;
    begin
    read(n);
    n:=sqr(n+1)-1;
    write(n);
    end.

  • 0
    @ 2014-10-28 14:49:57

    Compiling

  • 0
    @ 2014-08-04 15:43:47

    #include<iostream>
    using namespace std;
    main()
    {
    int x;
    cin>>x;
    cout<<x*(x+2);
    }

  • 0
    @ 2014-03-19 20:15:08

    水水水 真的是弱弱版
    纪念第vijos四道不用数组的题

    var x:longint;
    begin readln(x);writeln(x*(x+2));end.

  • 0
    @ 2013-10-07 13:27:57

    var x:longint;
    begin
    read(x);x:=x*(x+2);
    write(x);
    end.
    It's very water!
    纯净水!

  • 0
    @ 2013-10-02 16:33:34

    #in

信息

ID
1182
难度
1
分类
其他 | 数学 点击显示
标签
递交数
2641
已通过
1749
通过率
66%
被复制
17
上传者