72 条题解

  • 4
    @ 2012-11-03 14:05:34

    表示最后一组貌似有问题

    关于 ans:=a*b+a+b

    :如果大家都只能一次移一格

    那么将所有的x要想右移(b+1)格 和将所有y 左移(a+1)格后 便得到目标状态

    这花费了 a*(b+1)+b*(a+1) 次

    而实际上是可以一次移两格的不需要这么多次的

    对于每一对x、y 要么x跳过y 要么y跳过x 所以一共跳了a*b次

    a*(b+1)+b*(a+1)-a*b=a*b+a+b

    表示像楼下(不 ,是往下数n楼)的同学所说 本弱菜智商低于50

    因为花了好长时间想出来的……如果有其他思路欢迎讨论

  • 2
    @ 2017-07-14 10:43:26

    星际青蛙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.

  • 2
    @ 2017-05-08 12:38:55
    /*
    水题啊 高精度都不用Orz
    longlong 就够了
    关于 ans:=a*b+a+b
    :如果大家都只能一次移一格
    那么将所有的x要想右移(b+1)格 和将所有y 左移(a+1)格后 便得到目标状态
    这花费了 a*(b+1)+b*(a+1) 次
    而实际上是可以一次移两格的不需要这么多次的 
    对于每一对x、y 要么x跳过y 要么y跳过x 所以一共跳了a*b次
    a*(b+1)+b*(a+1)-a*b=a*b+a+b
    */
    #include <iostream>
    using namespace std;
    
    int main()
    {
        long long a,b;
        cin>>a>>b;
        cout<<a*b+a+b;
        return 0;
    }
    
  • 1
    @ 2024-04-13 13:18:46
    #include <iostream>
    #define int long long
    using namespace std;
    signed main()
    {
        long long a,b;
        cin>>a>>b;
        cout<<a*b+a+b;
        return 0;
    }
    
  • 1
    @ 2016-11-12 10:31:54

    #include <iostream>
    using namespace std;

    int main()
    {
    long long a,b;
    cin>>a>>b;
    cout<<a*b+a+b;
    return 0;
    }

  • 0
    @ 2024-04-21 15:03:35
    #include<iostream>
    #include<cstring>
    #include<algorithm>
    #include<climits> 
    using namespace std;
    struct numbers
    {
        int len;/*长度*/
        int number[10000];/*高精度数组*/
        /*构造函数(Constructor)*/
        numbers()
        {
            len=1;
            for(int index=0;index<10000;index++)
            {
                number[index]=0;
            }
        }
        /*输入函数(Input)*/
        numbers input(numbers &num)
        {
            char str[10000];
            scanf("%s",str);
            num.len=strlen(str);
            for(int index=0;index<len;index++)
            {
                num.number[index]=str[len-index-1]-48;
            }
            return num;
        }
        /*输出函数(Output)*/
        numbers output(const numbers num,char end='\n')
        {
            for(int index=num.len-1;index>=0;index--)
            {
                printf("%d",num.number[index]);
            }
            printf("\n");
            return num;
        }
        /*"="运算符的重载*/
        numbers operator = (const char* num)
        {
            len=strlen(num);
            for(int index=0;index<len;index++)
            {
                number[index]=num[len-index-1]-48;
            }
            return *this;
        }
        numbers operator = (const numbers* num)
        {
            int lens;
            lens=num->len;
            for(int index=0;index<lens;index++)
            {
                number[index]=num->number[lens-index-1];
            }
            return *this;
        }
        /*"+"运算符的重载*/
        numbers operator + (const numbers &num2)
        {
            numbers num1;
            num1.len=max(len,num2.len)+1;
            for(int index=0,add_x=0;index<num1.len;index++)
            {
                num1.number[index]=number[index]+num2.number[index]+add_x;
                add_x=num1.number[index]/10;
                num1.number[index]%=10;
            }
            if(num1.number[num1.len-1]==0)
            {
                num1.len--;
            }
            return num1;
        }
        /*"-"运算符的重载*/
        numbers operator - (const numbers &num2)
        {
            numbers num1,num3;
            num1.len=max(len,num2.len)+1000;
            int index=0;
            while(index<=len||index<=num2.len)
            {
                if(number[index]<num2.number[index])
                {
                    number[index]+=10;
                    number[index+1]-=1;
                }
                num1.number[index]=number[index]-num2.number[index];
                index++;
            }
            while(num1.number[num1.len-1]==0&&num1.len!=1)num1.len-=1;
            return num1;
        }
        /*"*"运算符的重载*/
        numbers operator * (const numbers &num2)
        {
            numbers num1;
            num1.len=len+num2.len;
            for(int index1=0;index1<len;index1++)
            {
                for(int index2=0;index2<num2.len;index2++)
                {
                    num1.number[index1+index2]+=number[index1]*num2.number[index2];
                }
            }
            for(int index=0;index<num1.len;index++)
            {
                if(num1.number[index]>9)
                {
                    num1.number[index+1]+=num1.number[index]/10;
                    num1.number[index]%=10;
                    if(index==num1.len-1)
                    {
                        num1.len++;
                    }
                }
            }
            while(num1.number[num1.len-1]==0&&num1.len!=1)num1.len-=1;
            return num1;
        }
        /*"/"运算符的重载*/
        numbers operator / (const numbers num2)
        {
            ;
        }
    };
    int main()
    {
        numbers a,b,c;
        a.input(a);
        b.input(b);
        c=a*b;
        c.output(c);
    }
    
  • 0
    @ 2023-05-13 23:52:51

    #include<bits/stdc++.h>
    using namespace std;
    long long x,y;
    int main(){
    cin>>x>>y;
    cout<<(x+1)*(y+1)-1;
    return 0;
    }

  • 0
    @ 2020-09-07 11:01:09

    每跳一下,就可以少走一格的路程,所以需要a*(b+1)+b*(a+1)-a*b

  • 0
    @ 2020-07-23 15:36:32
    #include<bis/stdc++.h>
    using namespace std;
    long long a,b;
    int main()
    {
        cin>>a>>b;
        cout<<a*b+a+b;
        return 0;
    }
    
  • 0
    @ 2018-05-05 18:39:33

    #include <iostream>
    using namespace std;
    int main(int argc, char** argv)
    {
    long long a,b,z;
    scanf("%lld%lld",&a,&b);
    z=a*(b+1)+b*(a+1)-a*b;
    printf("%lld",z);
    return 0;
    }

  • 0
    @ 2017-10-04 00:41:35

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

    long long x,y;

    int main(){
    cin>>x>>y;
    cout<<(x+1)*(y+1)-1;
    return 0;
    }

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

    星际青蛙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-05-30 00:12:57

    找到通式是解题的关键。

    
    #include <stdio.h>
    int main()
    {
    long long x,y;
    scanf("%lld",&x);
    scanf("%lld",&y);
    printf("%lld", x*y + x + y);
    return 0;
    }
    
    
  • 0
    @ 2017-04-24 21:54:18
    #include <iostream>
    using namespace std;
    int main()
    {
    long long a,b;
    cin>>a>>b;
    cout<<a*b+a+b;
    return 0;
    }
    
  • 0
    @ 2016-10-23 19:00:58
    x,y=raw_input().split()
    x=int(x)
    y=int(y)
    print (x+1)*(y+1)-1
    
  • 0
    @ 2016-10-19 13:32:34

    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
    long long a,b;
    cin>>a>>b;
    cout<<(a+b)+(a*b);
    return 0;
    }

  • 0
    @ 2016-08-19 13:03:28

    下面的答案有一个错的符号,你们猜猜看是什么

  • 0
    @ 2016-08-19 13:02:55

    如此简单
    #include <iostream>
    using namespace std;
    int main()
    {
    long long a,b;
    cin>>a>>b;
    cout<<a*b+a*b;
    return 0;
    }

  • 0
    @ 2016-08-13 14:48:31

    woc一定要开int64啊,longint后三个点过不了。。。被坑了

    Pascal Code

    var
      a,b,c:int64;
    begin
      readln(a,b,c);
      c:=a*b+a+b;
      writeln(c);
    end.
    
  • 0
    @ 2016-07-29 15:08:46
    记录信息
    评测状态    Accepted
    题目  P1192 星际青蛙(木木版)
    递交时间    2016-07-29 15:08:15
    代码语言    C++
    评测机 ShadowShore
    消耗时间    0 ms
    消耗内存    556 KiB
    评测时间    2016-07-29 15:08:16
    评测结果
    编译成功
    
    测试数据 #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 = 552 KiB, score = 15
    测试数据 #3: Accepted, time = 0 ms, mem = 552 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
    代码
    #include<iostream>
    using namespace std;
    int main() {
      __int64 x,y;
      cin >> x >> y;
      cout << x*y+x+y;
    }
    

信息

ID
1192
难度
3
分类
高精度 点击显示
标签
递交数
1686
已通过
869
通过率
52%
被复制
7
上传者