Semi-prime H-numbers
题目描述形如4n+1的数被称为“H数”,乘法在“H数”集合内为封闭的。因数只有1和本身的数叫“H素数”(不包括1),其余叫“H合数”。一个“H合成数”能且只能分解为两个“H素数”。求0·h内的“H合成数”个数。
分析:可以根据同余理论筛素数。
如果一个数x为“H素数”,5*x+4*x*j一定是“H合数”
标记合数,找到素数就把它的倍数处理打上合数标记。
最后要统计一下。
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<string>
using namespace std;
#define M 1000001+16
bool he[M],hech[M];
int su[M],ans[M];
long long tot;
int main()
{
int i,j;
for( i=;i<M;i+=)
{
if(he[i]) continue;//合数跳过
su[++tot]=i;
for(j=i*;j<M;j+=i*)//素数的推论,找合数
he[j]=true;
}
for(i=;i<=tot;i++)
for(j=;j<=i&&su[i]*su[j]<M;j++)
hech[su[i]*su[j]]=true;
for(i=;i<M;i++)
ans[i]=ans[i-]+hech[i];
int h;
scanf("%d",&h);
while(h)
{
printf("%d %d\n",h,ans[h]);
scanf("%d",&h);
}
return ;
}
Semi-prime H-numbers的更多相关文章
- (全国多校重现赛一) H Numbers
zk has n numbers a1,a2,...,ana1,a2,...,an. For each (i,j) satisfying 1≤i<j≤n, zk generates a new ...
- Prime Matrix(暴力出奇迹)
Description You've got an n × m matrix. The matrix consists of integers. In one move, you can apply ...
- 河南省第十届省赛 Binary to Prime
题目描述: To facilitate the analysis of a DNA sequence, a DNA sequence is represented by a binary num ...
- Largest prime factor
problem 3:Largest prime factor 题意:求600851475143的最大的质因数 代码如下: #ifndef PRO3_H_INCLUDED #define PRO3_H_ ...
- Codeforces Round #324 (Div. 2) D. Dima and Lisa 哥德巴赫猜想
D. Dima and Lisa Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/584/probl ...
- codeforces 809E Surprise me!
Tired of boring dates, Leha and Noora decided to play a game. Leha found a tree with n vertices numb ...
- Codeforces Round #324 (Div. 2)D. Dima and Lisa 数学(素数)
D. Dima and Lisa Dima loves representing an odd num ...
- BLUEZ测试报告
测试小分队介绍: 马辰,李孟,罗凡 测试任务分类 帮助类 战斗类 道具类 敌军类 英雄类 地图类 AboutScene.h AchieveLayers.h GameLoading.h GameOver ...
- poj 3274 Gold Balanced Lineup(哈希 )
题目:http://poj.org/problem?id=3274 #include <iostream> #include<cstdio> #include<cstri ...
- Jordan Lecture Note-8: The Sequential Minimal Optimization Algorithm (SMO).
The Sequential Minimal Optimization Algorithm (SMO) 本文主要介绍用于解决SVM对偶模型的算法,它于1998年由John Platt在论文“Seque ...
随机推荐
- Xamarin.Forms初始
前言 Xamarin.Forms 为 .NET 开发人员提供一个完整的跨平台 UI 工具包. 在 Visual Studio 中使用 C# 生成完全本机的 Android.iOS 和通用 Window ...
- CISCO-路由器交换机密码恢复
路由器密码恢复: 准备工作:一台PC跟一台路由器用console线相连 工作原理:如果忘记密码被锁在路由器外,通过修复寄存器值来进行修复 默认的寄存器值为0x2102(关闭的),若要恢复口令需要开启这 ...
- Opencv— — mix channels
// define head function #ifndef PS_ALGORITHM_H_INCLUDED #define PS_ALGORITHM_H_INCLUDED #include < ...
- windbg调试堆破坏
堆破坏 所谓的堆破坏,是说没控制好自己的指针,把不属于你分配的那块内存给写覆盖了.这块内存可能是你程序的数据,也可能是堆的管理结构.那么这个会导致怎样的后果呢?可能的情况我们来yy下 把程序里的计算结 ...
- 使用weui
1 在https://github.com/weui/weui-wxss/下载项目,得到weui.wxss文件 2 把文件放在小程序项目的根目录下 3 在app.wxss中引用weui.wxss文件 ...
- project工期出现小数问题
进入“选项”,点击“日程”,将默认“开始”.“结束”时间调整为“9点~18点.原为PREJECT 日历 (注意是日历~!!)默认的“8点~17点”,与preject系统默认时间“9点~18点”有差别~ ...
- [转载] C++ 类中的类成员变量怎么调用带参数的构造函数来初始化?
#include "stdafx.h" class A { public: A(){ax = ;}; A(int a){ax = a;}; int ax; }; class B { ...
- Visual Studio 2017 本地调试 Chrome浏览器自动退出
在使用VS 2017(15..6 .15.7)对.NET Core MVC应用程序进行本地调试的时候,选择使用Chrome浏览器.但输入中文 就自动关闭Chrome浏览器,随后结束调试.但复制.粘贴中 ...
- Spring Boot 学习系列(09)—自定义Bean的顺序加载
此文已由作者易国强授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验. Bean 的顺序加载 有些场景中,我们希望编写的Bean能够按照指定的顺序进行加载.比如,有UserServ ...
- C#中var关键字用法分析
原文连接 本文实例分析了C#中var关键字用法.分享给大家供大家参考.具体方法如下: C#关键字是伴随着.NET 3.5以后,伴随着匿名函数.LINQ而来, 由编译器帮我们推断具体的类型.总体来说,当 ...