A Central Meridian (ACM) Number N is a positive integer satisfies that given two positive integers A and B, and among A, B and N, we have

N | ((A^2)*B+1) Then N | (A^2+B)

Now, here is a number x, you need to tell me if it is ACM number or not.

Input

The first line there is a number T (0<T<5000), denoting the test case number.

The following T lines for each line there is a positive number N (0<N<5000) you need to judge.

Output

For each case, output “YES” if the given number is Kitty Number, “NO” if it is not.

Sample Input

2

3

7

Sample Output

YES

NO

Hint

X | Y means X is a factor of Y, for example 3 | 9;

X^2 means X multiplies itself, for example 3^2 = 9;

XY means X multiplies Y, for example 33 = 9.

题意:

给你一个数,如果能找出两个数a,b使得这三个数满足式子1,但不满足式子2,那么这个数n就不是符合要求的数,输出NO

思路:

实在算不粗来了,把我写的代码打了个表,然后,发现最大是240,然后其他,就没其他了。

#include <cstring>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>
using namespace std;
int mp[10000000];
int main()
{
mp[1] = 1;
mp[2] = 1;
mp[3] = 1;
mp[4] = 1;
mp[5] = 1;
mp[6] = 1;
mp[8] = 1;
mp[10] = 1;
mp[12] = 1;
mp[15] = 1;
mp[16] = 1;
mp[20] = 1;
mp[24] = 1;
mp[30] = 1;
mp[40] = 1;
mp[48] = 1;
mp[60] = 1;
mp[80] = 1;
mp[120] = 1;
mp[240] = 1;
int T, a;
cin >> T;
while (T--)
{
scanf("%d", &a);
if (mp[a] == 1)
puts("YES");
else
puts("NO");
}
return 0;
}

达标代码


#include <iostream>
#include <cstdio>
using namespace std;
int mp[10000000]; int ok(int x)
{
for (int i = 1; i <= 1000; i++)
{
for (int j = 1; j <= 1000; j++)
{
if ((i * i * j + 1) % x == 0 && ((i * i + j) % x != 0))
return 0;
}
}
return 1;
}
int main()
{
for (int i = 1; i <= 1000; i++) //打表部分
{
if (ok(i))
{
printf("mp[%d]=1; \n", i);
}
}
}

数学--数论-- HDU -- 2854 Central Meridian Number (暴力打表)的更多相关文章

  1. 数学--数论--hdu 6216 A Cubic number and A Cubic Number (公式推导)

    A cubic number is the result of using a whole number in a multiplication three times. For example, 3 ...

  2. 数学--数论--Hdu 5793 A Boring Question (打表+逆元)

    There are an equation. ∑0≤k1,k2,⋯km≤n∏1⩽j<m(kj+1kj)%1000000007=? We define that (kj+1kj)=kj+1!kj! ...

  3. 数学--数论--HDU 2582 F(N) 暴力打表找规律

    This time I need you to calculate the f(n) . (3<=n<=1000000) f(n)= Gcd(3)+Gcd(4)+-+Gcd(i)+-+Gc ...

  4. HDU 1216 Assistance Required(暴力打表)

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1216 Assistance Required Time Limit: 2000/1000 MS (Ja ...

  5. XTU OJ 1210 Happy Number (暴力+打表)

    Problem Description Recently, Mr. Xie learn the concept of happy number. A happy number is a number ...

  6. 数学--数论--HDU - 6395 Let us define a sequence as below 分段矩阵快速幂

    Your job is simple, for each task, you should output Fn module 109+7. Input The first line has only ...

  7. 数学--数论--hdu 5878 I Count Two Three(二分)

    I will show you the most popular board game in the Shanghai Ingress Resistance Team. It all started ...

  8. 数学--数论--HDU 5223 - GCD

    Describtion In mathematics, the greatest common divisor (gcd) of two or more integers, when at least ...

  9. 数学--数论--HDU 5019 revenge of GCD

    Revenge of GCD Problem Description In mathematics, the greatest common divisor (gcd), also known as ...

随机推荐

  1. .net 垃圾回收

    垃圾回收器帮我们处理了内存中不在使用的对象,提高了机器的性能,让开发人员轻松了很多. 你真的了解垃圾回收吗? 或许你知道垃圾回收,听说过是通过标记回收,可是怎么标记回收呢就不是很清楚了,好吧,如果不清 ...

  2. 29.3 ArrayList、List、LinkedList(链表)优缺点

    ArrayList.List特点:查询快.增删慢 链表特点:查询慢,增删快 案例 package day29_collection集合体系; import java.util.ArrayList; i ...

  3. 学习《深入应用c++11》2

    &&   universal references(未定的引用类型),它必须被初始化,它是左值还是右值取决于它的初始化,如果&&被一个左值初始化,它就是一个左值;如果它 ...

  4. 二、Python2.7的安装并与Python3.8共存

    一:Python解释器为什么要2个版本? 众所周知,Python2.7是一个过渡版本. 很多公司写的项目并不是基于最新的Python3写的,在之后进行一些项目更改的时候,Python3的语法有一些并不 ...

  5. spark sql error mismatched input 'union' expecting { <EOF>,''................................

    给union的前后sql加括号就可以解决

  6. 练习,自定义TextView(1.1)

    重新自定义TextView是非常有趣的事情,跟着Android4高级编程,通过自定义TextView,来敲一下代码: 这个是那么的简单,自定义TextView,新建CustomTextView继承Te ...

  7. 选择IT行业的自我心得,希望能帮助到各位!(三)失败篇

    可能很多小伙伴会说人人创业岂不是人人都能成功,岂不是人人都能成功,是不是每个人都能开上保时捷,法拉利泡着美女,很多人也会说你看他看她多轻松,做个IT一样就赚钱赚钱了. 那么又有多少人能理解到你的心酸了 ...

  8. sublime text3添加并修改编译系统

    版权声明:本文为CSDN博主「肥宅_Sean」的原创文章,遵循 CC 4.0 BY-SA 版权协议,原文链接 方法工具 -> 编译系统 -> 新建编译系统 按ctrl+s保存.(注意,这里 ...

  9. Delphi学习手记——单引号和双引号的区别

    单引号和双引号的区别 双引号表示其中字符可能包含变量,而单引号表示整个引号内的东西都当成字符串来处理. 也就是说:没有内设变量就用单引号'',有就用双引号"". 举例说明: $va ...

  10. 小程序—银行、券商们下一代APP的进阶方向

    传统金融机构们的App——尤其以手机银行.手机证券为最,发展到今天,已经产生一系列的问题:从用户角度看,体验普遍不好.高度同质化:从业务运营角度看,几乎没有什么“运营”的抓手:从IT角度看,投入产出比 ...