题目描述形如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. Springboot框架中request.getInputStream()获取不到上传的文件流

    Springboot框架中用下面的代码,使用request.getInputStream()获取不到上传的文件流 @PostMapping("/upload_img") publi ...

  2. 提高scroll性能

    在DevTools中开始渲染,向下滑动一点点滚动条,然后停止滚动. 在结果中,注意frames总是在30ftps线上面,甚至都木有很接近69ftps线的(事实上帧执行的太缓慢以致于60ftps线在图上 ...

  3. python装饰器精髓代码

    #!/usr/bin/env python #-*- coding:utf-8 -*- import time def foo(func): def inner(): print('fs...') f ...

  4. 三 vue学习三 从读懂一个Vue项目开始

    源码地址:     https://github.com/liufeiSAP/vue2-manage 我们的目录结构: 目录/文件 说明 build 项目构建(webpack)相关代码. config ...

  5. AspNetPager样式以及属性帮助文档

    帮助文档地址:http://www.webdiyer.com/AspNetPagerDocs/index.html 应用样式:http://www.webdiyer.com/AspNetPagerDe ...

  6. 改变bootstrapSwitch按钮状态

    $('.switch-state').bootstrapSwitch('state',true);

  7. Linux 执行定时任务 shell脚本

    Linux上面执行定时任务,我们可以利用crontab -e直接编辑定时任务 另外我们还可以写好shell脚本,定时去执行shell脚本,这两个方法都可以起到定时执行的作用 下面我详细说一下入如何执行 ...

  8. python 数据可视化

    一.基本用法 import numpy as np import matplotlib.pyplot as plt x = np.linspace(-1,1,50) # 生成-1到1 ,平分50个点 ...

  9. c/c++时间相关

    本文从介绍基础概念入手,探讨了在C/C++中对日期和时间操作所用到的数据结构和函数,并对计时.时间的获取.时间的计算和显示格式等方面进行了阐述.本文还通过大量的实例向你展示了time.h头文件中声明的 ...

  10. 【Linux学习】Linux文件系统5—查看文件内容命令

    Linux文件系统5-查看文件内容命令 cat: 由第一行开始显示文件内容 more: 一页一页地显示文件内容,空格键可以继续翻页显示下一页内容 less:与more类似,但是可以往前翻页 head: ...