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 to , the sum will never be a square number?"
As another reporter in that press conference, you also wondering that given , whether is a square number. Specifically, we regard a positive number as a square number when there exists an integer satisfying .
输入描述
There are multiple test cases. The first line of the input contains an integer indicating the number of test cases.
For each test case, the first line contains one integers .
输出描述
If the sum is a square number, please output "Fake news!" in one line. Otherwise, please output "Nobody knows it better than me!" instead.
示例1
输入
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!
分析
打表题,当且仅当 或 时, 为完全平方数。
知乎上的巨佬们给出了一些证明。
代码
/****************************************************************** Copyright: 11D_Beyonder All Rights Reserved Author: 11D_Beyonder Problem ID: 2020牛客暑期多校训练营(第七场)Problem D Date: 8/27/2020 Description: Just Attempt *******************************************************************/ #include<stdio.h> int main(){ int _; for(scanf("%d",&_);_;_--){ long long n; scanf("%lld",&n); if(n==1||n==24){ puts("Fake news!"); }else{ puts("Nobody knows it better than me!"); } } return 0; }
收集牛客暑期多校训练营的题解