编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#103402 #1429. [L1-6] 序列变换 Compile Error 0 0 ms 0 K C++ 11 / 443 B 2177277017 2024-03-17 23:19:32
显示原始代码
#include <bits/stdc++.h>
#define ll long long
const int maxn = 1e5 + 5;
using namespace std;
int n;
ll a[maxn], b[maxn];
int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%lld", &b[i]);
    a[2] = b[1];
    a[n - 1] = b[n];
    for (int i = 3; i <= n; i += 2) a[i + 1] = b[i] - a[i - 1];
    for (int i = n - 2; i >= 1; i -= 2) a[i - 1] = b[i] - a[i + 1];
    if (n & 1)
        puts("Inf");
    else
        cout << n << endl, for (int i = 1; i <= n; i++) printf("%lld ", a[i]);
    return 0;
}

编译信息

/sandbox/1/a.cpp: In function 'int main()':
/sandbox/1/a.cpp:15:23: error: expected primary-expression before 'for'
   15 |         cout<<n<<endl,for(int i=1;i<=n;i++)printf("%lld ",a[i]);
      |                       ^~~
/sandbox/1/a.cpp:15:35: error: 'i' was not declared in this scope
   15 |         cout<<n<<endl,for(int i=1;i<=n;i++)printf("%lld ",a[i]);
      |                                   ^
/sandbox/1/a.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
/sandbox/1/a.cpp:9:31: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     for(int i=1;i<=n;i++)scanf("%lld",&b[i]);
      |                          ~~~~~^~~~~~~~~~~~~~