Featured image of post codeforces practices

codeforces practices

栽在了简单数学题上

Codeforces Round #836 (Div. 2) B题目链接
反思:
其实就是((n-1)*(n+1)+1)/n=n。。。对简单数学不够敏感哎
题目意思没理解对,误以为𝑎1+𝑎2+⋯+𝑎𝑛求和可以不整除𝑛。。。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
    int t, n;
    scanf("%d", &t);
    while (t--)
    {
        scanf("%d", &n);
        if (n & 1)
        {
            for (int i = 1; i <= n; i++)
            {
                printf("%d",n);
                if(i!=n){
                    printf(" ");
                }
            }
            printf("\n");
            continue;
        } else {
            printf("1");
            for (int i = 1; i <= n-1; i++)
            {
                printf(" %d",n+1);
            }
            printf("\n");
        }
    }
    return 0;
}

最后更新于 2022年12月04日 16点02分11秒
别人在等伞,我在等雨停
Built with Hugo
主题 StackJimmy 设计