当前位置: 代码迷 >> 综合 >> 2020牛客暑期多校训练营(第七场)D Fake News
  详细解决方案

2020牛客暑期多校训练营(第七场)D Fake News

热度:30   发布时间:2024-02-05 02:57:03.0

2020牛客暑期多校训练营(第七场)D Fake News
链接:https://ac.nowcoder.com/acm/contest/5672/D
来源:牛客网

McDonald Thumb, the greatest president ever in the history of the Great Tokitsukaze Kingdom has held his 100th press conference about the global pandemic after making his 1000000th tweets with his smartphone. With a big smile on his face, Mr. Thumb said that nobody knows math more than he does.

‘I learn math since I was born and I am very good at it’, said Mr. Thumb. ‘People keep asking me why I know math so much and I sometimes find myself having those amazing ideas about math.’

‘For example?’, asked by a reporter.

‘Oh you, I know you! Fake news! You and your agency always produce fake news!’, replied angrily by Mr. Thumb. ‘Let me teach you something, do you know if you add up the squares of numbers from 1 to n, the sum will never be a square number?’
As another reporter in that press conference, you also wondering that given n, whether在这里插入图片描述

is a square number. Specifically, we regard a positive number x as a square number when there exists an integer y satisfying
在这里插入图片描述
在这里插入图片描述
输入:

5
1
2
3
4
5

输出:

Fake news!
Nobody knows it better than me!
Nobody knows it better than me!
Nobody knows it better than me!
Nobody knows it better than me!

题意:
签到题:
在这里插入图片描述的结果求根号之后是不是整数
题解:
打表之后发现就只有1和24满足条件,直接输出结果
Code:

#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define sc(a) scanf("%d", &a)
#define sc2(a, b) scanf("%d%d", &a, &b)
#define ss(a) scanf("%s", a)
#define mem(a, b) memset(a, b, sizeof(a))
#define PII pair<int, int>
using namespace std;
int main(){int t;sc(t);while(t--){LL n;scanf("%lld",&n);if(n==1||n==24)printf("Fake news!\n");else printf("Nobody knows it better than me!\n");}system("pause");return 0;
}
  相关解决方案