214 条题解

  • 1
    @ 2024-01-29 16:54:20

    暴力<算法<=数学

    #include<bits/stdc++.h>
    using namespace std;
    int main() {
        long long n;cin >> n;
        cout << n * (n + 1) * (2 * n + 1) / 6;}
    
  • 1
    @ 2021-03-17 17:41:40
    #include <cmath>
    #include <cstdio>
    #include <cstdlib>
    #include <cstring>
    #include <algorithm>
    #include <vector>
    #include <deque>
    using namespace std;
    
    namespace dts
    {
        typedef long long ll;
        
        ll n;
        
        void main()
        {
            scanf("%lld",&n);
            printf("%lld\n",n*(n+1)*(2*n+1)/6);
        }
    };
    
    int main()
    {
        dts::main();
    }
    
  • 0
    @ 2020-02-10 16:54:31
    #include<iostream>
    using namespace std;
    
    int main()
    {
        long long edge;
        cin>>edge;
        long long  answer=0;
        for(long long  i=1;i<=edge;i++ )
        {
            answer+=i*i;
        }
        cout<<answer;
    }
    
    
  • 0
    @ 2017-08-03 15:28:42

    醉人的题目,错了好几次:

    1.出题人语文水平有问题吧,题目题意都说不清楚。2.n的范围根本不在32767,int报错,要用long long。

    #include <bits/stdc++.h>
    using namespace std;
    
    int main()
    {
        //freopen("input.txt","r",stdin);
        long long n,sum;
        scanf("%lld",&n);
        sum=n*(n+1)*(2*n+1)/6;
        printf("%lld\n",sum);
        return 0;
    }
    
    
  • 0
    @ 2012-08-07 10:52:45

    我怎么会想到用高精度做?!直到想到了int64我才摆脱这厄运

  • 0
    @ 2012-07-27 20:40:52

    我去,n的范围不是小于32767吗。int n就错,long long n就对……

    • @ 2014-01-27 15:42:51

      n的范围是32767,但是计算出来的结果已经大于longint了,但是没有大于long long.
      计算是如果n是int,要把它类型转换为long long

  • 0
    @ 2010-04-15 18:45:51

    include

    include

    int num1;

    int a=0;

    int add(int x)

    {

    if(x>0)

    {

    a=a+x*x;

    x=x-1;

    add(x);

    }

    return(a);

    }

    main()

    {

    scanf("%d",&num1);

    printf("%d",add(num1));

    system("pause");

    }

  • 0
    @ 2010-04-14 18:30:36

    数学学来干什么?还要累加平方?不用

    var

    n:real;

    begin

    read(n);

    writeln(n*n*n/3+n*n/2+n/6:0:0);

    end.

  • 0
    @ 2009-11-10 14:41:10

    令人愤怒的叙述,有话就好好说么,整得那么晦涩……

    var

    n,i,j:longint;

    num:int64;

    begin

    readln(n);

    for i:=1 to n do

    num:=num+sqr(i);

    writeln(num);

    end.

  • 0
    @ 2009-11-08 20:53:49

    var

    a:int64;

    begin

    readln(a);

    writeln(a*(2*a+1)*(a+1)div 6);

    end.

  • 0
    @ 2009-10-31 10:45:39

    var

    s,j:int64; n,i:longint;

    begin

    readln(n);

    for i:=1 to n do

    begin

    j:=i*i;

    s:=s+j;

    end; writeln(s);

    end.

    So easy

  • 0
    @ 2009-10-30 12:08:46

    var

    s : int64;

    i,n : longint ;

    begin

    readln(n);

    s:=0;

    for i := 1 to n do

    s:=s+i*i;

    writeln(s);

    end.

    农夫山泉-味道有点甜;

    完全是water

    递推公式: An=n*n+An-1

  • 0
    @ 2009-10-25 15:22:16

    program p1307(input,output);

    var n,i:longint;

    zs:int64;

    begin

    readln(n);

    for i:=1 to n do

    zs:=zs+(n-i+1)*(n-i+1);

    writeln(zs);

    end.

    ^_^so easy!!!

  • 0
    @ 2009-10-25 11:17:13

    解释下。。。。。。没看懂

  • 0
    @ 2009-10-22 16:12:13

    说实话...这题我真的没读懂............

  • 0
    @ 2009-10-22 15:29:19

    水水水~~~~~~~

    var

    a,i:longint;

    g:qword;

    begin

    readln(a);

    for i:=1to a do begin

    g:=g+i*i;

    end;

    writeln(g);

    end.

  • 0
    @ 2009-10-07 13:12:24

    编译通过...

    ├ 测试数据 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-27 20:18:19

    刷水题有利身体健康 ^.^

  • 0
    @ 2009-09-21 18:40:32

    var

    n,m,i:int64;

    begin

    readln(n);

    m:=0;

    for i:=1 to n do

    m:=m+i*i;

    writeln(m);

    end.

  • 0
    @ 2009-09-16 17:05:01

    调高精度调了半天。。。

    我的通过率啊555555555~~~

信息

ID
1307
难度
3
分类
其他 | 数学 点击显示
标签
递交数
3739
已通过
1923
通过率
51%
被复制
16
上传者