2020牛客多校第七场 Fake News(结论)

在这里插入图片描述
题意:
给以数 n n ,求 i 2 , 1 i n ∑i^2,1≤i≤n 是否是一个完全平方数。

思路;
结论题,也可以打表看出来,只有1和24满足条件。
不过也可以直接用平方和公式写。

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <map>
#include <string>

using namespace std;

typedef long long ll;

const int mod = 1e9 + 7;
const int maxn = 5000 + 7;

int main() {
    int T;scanf("%d",&T);
    while(T--) {
        int n;scanf("%d",&n);
        if(n == 1 || n == 24) {
            printf("Fake news!\n");
        } else {
            printf("Nobody knows it better than me!\n");
        }
    }
}

猜你喜欢

转载自blog.csdn.net/tomjobs/article/details/107827553