题目描述形如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的更多相关文章

  1. (全国多校重现赛一) H Numbers

    zk has n numbers a1,a2,...,ana1,a2,...,an. For each (i,j) satisfying 1≤i<j≤n, zk generates a new ...

  2. Prime Matrix(暴力出奇迹)

    Description You've got an n × m matrix. The matrix consists of integers. In one move, you can apply ...

  3. 河南省第十届省赛 Binary to Prime

    题目描述: To facilitate the analysis of  a DNA sequence,  a DNA sequence is represented by a binary  num ...

  4. Largest prime factor

    problem 3:Largest prime factor 题意:求600851475143的最大的质因数 代码如下: #ifndef PRO3_H_INCLUDED #define PRO3_H_ ...

  5. 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 ...

  6. codeforces 809E Surprise me!

    Tired of boring dates, Leha and Noora decided to play a game. Leha found a tree with n vertices numb ...

  7. Codeforces Round #324 (Div. 2)D. Dima and Lisa 数学(素数)

                                                     D. Dima and Lisa Dima loves representing an odd num ...

  8. BLUEZ测试报告

    测试小分队介绍: 马辰,李孟,罗凡 测试任务分类 帮助类 战斗类 道具类 敌军类 英雄类 地图类 AboutScene.h AchieveLayers.h GameLoading.h GameOver ...

  9. poj 3274 Gold Balanced Lineup(哈希 )

    题目:http://poj.org/problem?id=3274 #include <iostream> #include<cstdio> #include<cstri ...

  10. Jordan Lecture Note-8: The Sequential Minimal Optimization Algorithm (SMO).

    The Sequential Minimal Optimization Algorithm (SMO) 本文主要介绍用于解决SVM对偶模型的算法,它于1998年由John Platt在论文“Seque ...

随机推荐

  1. Python:条件判断

    条件控制:if...elif...else if condition_1: statement_1 elif condition_2: statement_2 else: statement_3 判断 ...

  2. 机器学习:Principal components analysis (主分量分析)

    Principal components analysis 这一讲,我们简单介绍Principal Components Analysis(PCA),这个方法可以用来确定特征空间的子空间,用一种更加紧 ...

  3. FFmpeg常用命令 (三)流媒体

    前言 如此强大的FFmpeg,能够实现视频采集.视频格式转化.视频截图.视频添加水印.视频切片.视频录制.视频推流.更改音视频参数功能等.通过终端命令如何实现这些功能,Richy在本文做一记录,以备之 ...

  4. ubuntu 安装配置 JDK7和Android Studio(apt-get方式)

    Ubuntu 安装配置JKD 7 $ sudo add-apt-repository ppa:webupd8team/java $ sudo apt-get update $ sudo apt-get ...

  5. 【Linux学习】Linux文件系统3—文件操作命令

    Linux文件系统3-文件操作命令 Linux文件操作命令主要有: cd:    改变目录位置 pwd:  显示当前目录的绝对路径 ls:    显示文件名称.属性等 -a 列出全部文件 -l  列出 ...

  6. Flutter实战视频-移动电商-03.底部导航栏制作

    03.底部导航栏制作 material是谷歌退出的 还有另外的一种:cupertino是IOS的风格 我们底部的导航栏,静态的widget是不合适的,这垃圾我们用到动态的widget 这重新改成动态的 ...

  7. [ACM] hdu 1285 确定比赛名次 (拓扑排序)

    确定比赛名次 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Subm ...

  8. 网络编程-http连接-GET&POST

    GetRequest package com.net.http; import java.io.BufferedReader; import java.io.IOException; import j ...

  9. PhpStorm下载、破解

    下载 去官网下载新版phpstorm 破解 1.打开编辑器, Help->Register->License server,输入http://idea.codebeta.cn (支持10. ...

  10. 51nod1393

    思路:一个位num0-num1值=某位num0-num1值相等就代表这段区间内01数字相等,然后还要判断当前位置num0==num1这个情况 #include <bits/stdc++.h> ...