3 条题解

  • 0
    @ 2024-08-21 14:24:51

    可能是数据的问题吧,后2个点怎么都WA

    #include<iostream>
    using namespace std;
    int main(){
        int n, a, sum;
        cin >> n;
        a = n*n-n+1;
        cout << n << "^3=" << a;
        for(int i = 1; i < n; i++)cout << '+' << a+2*i;
        return 0;
    }
    
  • -1
    @ 2019-05-14 20:44:29

    #include<stdio.h>
    #define N 100

    int noco(int n,int *a);

    int main()
    {
    int a[N],n,k,i;
    scanf("%d",&n);
    k=noco(n,a);
    printf("%d^%d=",k,3);
    for(i=0;i<k;i++)
    {
    printf("%d",a[i]);
    if(i==k-1)
    break;
    printf("+");
    }
    printf("\n");
    return 0;

    }

    int noco(int n,int *a)
    {
    int i,k,j;
    k=n*n*n;
    for(i=1;i>0;i+=2)
    {
    j=n*i+(n-1)*n;
    if(k==j)
    {
    for(j=0;j<n;j++)
    {
    a[j]=i;
    i+=2;
    }
    break;
    }
    }
    return n;
    }//前三绿后两红,不知道为何

  • -1
    @ 2019-01-16 23:14:08

    #include <stdio.h>
    #include <stdlib.h>

    int noco(int n, unsigned long long *a)
    {
    unsigned long long mid = (unsigned long long)n * n;
    if (n == 1)
    {
    a[0] = 1;
    return 1;
    }
    if (n % 2 == 1)
    {
    mid = mid - (unsigned long long)(n / 2) * 2;
    }
    else if (n % 2 == 0)
    {
    mid--;
    mid = mid - (unsigned long long)(n / 2-1) * 2;
    }
    for (int i = 0; i < n; i++)
    a[i] = mid + (unsigned long long)i * 2;
    return n;
    }
    int main()
    {
    unsigned long long a[100000];
    int n;
    scanf("%d", &n);
    noco(n, a);
    printf("%d^3=",n);
    printf("%llu", a[0]);
    for (int i = 1; i < n; i++)
    printf("+%llu", a[i]);

    return 0;
    }//为什么前三个数据对了,后两个不对啊?我以为是数据溢出,改成llu还是不行。。。

  • 1

信息

难度
9
分类
(无)
标签
递交数
95
已通过
1
通过率
1%
被复制
5
上传者