数学--数论-- HDU -- 2854 Central Meridian Number (暴力打表)
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 (暴力打表)的更多相关文章
- 数学--数论--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 ...
- 数学--数论--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! ...
- 数学--数论--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 ...
- HDU 1216 Assistance Required(暴力打表)
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1216 Assistance Required Time Limit: 2000/1000 MS (Ja ...
- XTU OJ 1210 Happy Number (暴力+打表)
Problem Description Recently, Mr. Xie learn the concept of happy number. A happy number is a number ...
- 数学--数论--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 ...
- 数学--数论--hdu 5878 I Count Two Three(二分)
I will show you the most popular board game in the Shanghai Ingress Resistance Team. It all started ...
- 数学--数论--HDU 5223 - GCD
Describtion In mathematics, the greatest common divisor (gcd) of two or more integers, when at least ...
- 数学--数论--HDU 5019 revenge of GCD
Revenge of GCD Problem Description In mathematics, the greatest common divisor (gcd), also known as ...
随机推荐
- hicharts中treemap添加超链接
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...
- Django 已生成数据时怎么查询数据库
数据库已写好时,怎样查询数据库 1.输入命令:python manage.py inspectdb > model1.py 注:>重定向 到model1.py
- CVPR2020| 阿里达摩院最新力作SA-SSD
作者:蒋天园 Date:2020-04-16 来源:SA-SSD:阿里达摩院最新3D检测力作(CVPR2020) Brief 来自CVPR2020的研究工作,也是仅仅使用Lidar数据进行3D检测的文 ...
- "三号标题"组件:<h3> —— 快应用组件库H-UI
 <import name="h3" src="../Common/ui/h-ui/text/c_h3"></import> < ...
- python3(一)
print('test', '怎么自动建了这么多目录', 'aaaaaaa') #test 怎么自动建了这么多目录 aaaaaaa 注释# # ---------------------------- ...
- AJ学IOS(49)多线程网络之线程的创建NSThreand
AJ分享,必须精品 一:NSThread的基本使用 1:创建和启动线程 一个NSThread对象就代表一条线程 创建.启动线程 NSThread *thread = [[NSThread alloc] ...
- 练习,自定义TextView(1.1)
重新自定义TextView是非常有趣的事情,跟着Android4高级编程,通过自定义TextView,来敲一下代码: 这个是那么的简单,自定义TextView,新建CustomTextView继承Te ...
- work of 1/6/2016
part 组员 今日工作 工作耗时/h 明日计划 工作耗时/h UI 冯晓云 UI动态布局改进和攻克疑难 6 继续下滑条等增删补减 ...
- Django开发文档-域用户集成登录
项目概述: 一般在企业中,用户以WINDOWS的域用户统一的管理,所以以Django快速开发的应用,不得不集成AD域登录. 网上一般采用django-python3-ldap的库来做集成登录,但是本方 ...
- 详解 Paths类 与 Files类
在本篇博文中,本人主要讲解NIO 的两个核心点 -- 缓冲区(Buffer) 和 通道 (Channel)之一的 缓冲区(Buffer), 有关NIO流的其他知识点请观看本人博文<详解 NIO流 ...