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. 家庭版记账本app开发进度相关界面的规划

    总的app界面包括四个页面,页面可以来回滑动.设计的时候就和微信的四个页面类似. 由于没有找到合适的图标进行替换,在此仍应用微信对应的四个图标. 总的四个页面是: 1.增加收入或者支出的小账单.当点击 ...

  2. flask-migrate的基本使用

    Flask-migrate 在实际开发环境中,经常会发生数据库修改的行为.一般我们修改数据库不会手动的去修改,而是去修改orm对应的模型, 然后再把模型映射到数据库中.这时候如果有一个工具能专门做这种 ...

  3. 30.3 Collections 集合体系的工具类

    /* * Collections: * 面试题:Collection和Collections有什么区别? * Collection是集合体系的最顶层,包含了集合体系的共性 * Collections是 ...

  4. EOS基础全家桶(七)合约表操作

    简介 本篇我们开始来为后续合约开发做准备了,先来说说EOS内置的系统合约的功能吧,本篇将侧重于合约表数据的查询,这将有利于我们理解EOS的功能,并可以进行必要的数据查询. EOS基础全家桶(七)合约表 ...

  5. 计算机网络-CSMA/CD

    假定1km长的CSMA/CD网络的传输速率为1Gbit/s.设信号在网络上的传播速率为200000km/s,则能够使用此协议的最短帧长是? 答案:2×104bit/s 解析:C=2×105km/s,即 ...

  6. 一个不错的spring 学习博客

    http://www.iteye.com/blogs/subjects/spring-tittle-tattle

  7. 负载均衡服务之HAProxy基础入门

    首先我们来了解下haproxy是干嘛的?haproxy是一个法国人名叫Willy Tarreau开发的一个开源软件:这款软件主要用于解决客户端10000以上的同时连接的高性能的TCP和HTTP负载均衡 ...

  8. NK16

    C 小石的海岛之旅 链接:https://ac.nowcoder.com/acm/contest/949/C来源:牛客网 暑假到了,小石和小雨到海岛上玩. 从水平方向看海岛可以看成 nnn个小块,每一 ...

  9. 浏览器远程编写python代码--jupyter web server

    公司分配了开发机,偶尔需要写一些python自动化脚本.为了提高编写效率,可以开发机上起一个jupyter web server,然后在电脑chrome浏览器进行编辑. 以下步骤均在开发机上操作. 安 ...

  10. pytorch 中交叉熵损失实现方法