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. go 锁和sync包

    一.什么是锁? sync.Mutex 是一个互斥锁,它的作用是守护在临界区入口来确保同一时间只能有一个线程进入临界区 在 sync 包中还有一个 RWMutex 锁:他能通过 RLock() 来允许同 ...

  2. matplotlib BlendedAffine2D 和 CompositeAffine2D

    2020-04-11 10:00:01 --Edit by yangrayBlendedAffine2D 继承于Affine2DBase,支持x和y方向使用不同的仿射变换策略.(自译:混合仿射变换)C ...

  3. Go语言的GPM调度器是什么?

    我是平也,这有一个专注Gopher技术成长的开源项目「go home」 导读 相信很多人都听说过Go语言天然支持高并发,原因是内部有协程(goroutine)加持,可以在一个进程中启动成千上万个协程. ...

  4. Thinking in Java,Fourth Edition(Java 编程思想,第四版)学习笔记(九)之Interfaces

    Interfaces and abstract classes provide more structured way to separate interface from implementatio ...

  5. GeoGebra案例(傅里叶级数的方波)

    傅里叶级数介绍:请移步参见这位马大佬的博文 https://www.matongxue.com/madocs/619.html 马大佬中的gif图在我看来是非常直观且有趣的,奈何本人本领实在有限,学习 ...

  6. Python 注释(Python Comments)用法详解

    目录 1 Python 注释概述 2 Python 注释的作用 2.1 调试代码 2.2 提高程序的可读性 3 Python 单行注释 3.1 Python 单行注释概述 3.2 单行注释注释单行代码 ...

  7. Salesforce 产品 | 协同办公“大魔王”,Salesforce Quip的使用攻略!

    Salesforce帮助企业渡过疫情难关,支持在线远程办公.7.5亿美金收购的动态文档共享平台Quip,即刻开放给所有Salesforce老客户还有非营利组织免费使用至2020年9月30日. Quip ...

  8. 借助Python来实现的定量城市研究

    一.数据处理基础 (一)数据分析的概念 城市数据分析,可以从数据分析的广义和狭义两个角度来看: 狭义的数据分析是指根据分析目的,采用对比分析.分组分析.交叉分析和回归分析等分析方法,对相关城市数据(包 ...

  9. 给想学python但还没有接触过的你,python代码的书写规则,小白入门

    Python 文件结构 变量命名 注释 单行注释 多行注释 缩进 Python 文件结构 #!/usr/bin/env python3 # 指定python解释器 # -*- coding: utf- ...

  10. tensorflow基础--LeNet-5测试模型遇到TypeError: Failed to convert object of type <class 'list'> to Tensor

    最近在看<TensorFlow 实战Google深度学习框架第二版>这本书,测试LeNet-5这个模型时遇到了TypeError: Failed to convert object of ...