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. MySQL入门,第四部分,学会创建、删除表

    一.列完整性约束 列完整性约束:是指对某一列设置的约束条件.该列上的数据必须满足.最常见的有: NOT NULL 该列值不能为空 NULL  该列值可以为空 UNIQUE 该列值不能存在相同 DEFA ...

  2. 29.2 Iterator 迭代器ConcurrentModificationException:并发修改异常处理

    /** Iterator:迭代器* * 需求:判断集合中是否包含元素java,如果有则添加元素android * Exception in thread "main" java.u ...

  3. VMware 15.5虚拟机安装群晖NAS

     一.群晖nas简介 NAS(Network Attached Storage:网络附属存储),按字面意思理解其实就是网络存储器,可以理解为存储资料的网盘,云盘.NAS本身支持多种协议(如NFS.CI ...

  4. IDEA永久激活码获取

      废话少说,直接上地址:http://idea.medeming.com/jet/ *小编还是建议,有家底的程序猿还是直接买正版的号,非正版的很多不便的地方~

  5. 支持向量机SVM推导

    样本(\(x_{i}\),\(y_{i}\))个数为\(m\): \[\{x_{1},x_{2},x_{3}...x_{m}\} \] \[\{y_{1},y_{2},y_{3}...y_{m}\} ...

  6. 数据结构和算法(Golang实现)(4)简单入门Golang-结构体和方法

    结构体和方法 一.值,指针和引用 我们现在有一段程序: package main import "fmt" func main() { // a,b 是一个值 a := 5 b : ...

  7. 微服务框架-Spring Cloud

    Spring Cloud入门 微服务与微服务架构 微服务架构是一种新型的系统架构.其设计思路是,将单体架构系统拆分为多个可以相互调用.配合的独立运行的小程序.这每个小程序对整体系统所提供的功能就称为微 ...

  8. webWMS开发过程记录(二)- WMS是什么

    (参考:WMS-百度百科) 简介 WMS是仓库管理系统(Warehouse Management System)的缩写,是一款标准化.智能化过程导向管理的仓库管理软件仓库管理系统,是通过出入库业务.仓 ...

  9. Docker搭建Nessus pro笔记

    0x01 准备Docker环境 拉取镜像: docker pull ubuntu 创建容器: docker run -p 9922:22 -p 8834:8834 --name nessus -it ...

  10. 【three.js第二课】页面自适应

    1.在[three.js第一课]的基础上加入以下代码,改变窗口大小时,页面内容会自适应 //加入事件监听器,窗口自适应 window.addEventListener('resize', functi ...