传送门:

刷《数论一本通》时看到的题,简单记录一下。

题目大意(照抄书上的):形如4n+1的数被称为H数,乘法在H数组成的集合内是封闭的。在这个集合中是能被1和本身整除的数叫H-素数,其余的数被称为H合数,1个

H-合成数是一个能且只能被分解成两个H-素数乘积的H合数,求0-h内有多少个H合成数。

题解:

首先,两个H素数的乘积一定是H数,这个可以推导出来:

所以只要我们求出0-h内有多少个H素数,就可以得到本题的答案。根据同余原理我们知道如果i是素数,那么i(5+4x)必定不是H素数且一定是H数,那么就可以通过筛发求出本题的答案。

 //POJ 3292
 //by Cydiater
 //2016.8.29
 #include <iostream>
 #include <cstdio>
 #include <cstdlib>
 #include <cstring>
 #include <string>
 #include <iomanip>
 #include <ctime>
 #include <cmath>
 #include <queue>
 #include <map>
 #include <algorithm>
 using namespace std;
 #define ll long long
 #define up(i,j,n)       for(int i=j;i<=n;i++)
 #define down(i,j,n)     for(int i=j;i>=n;i--)
 ;
 ;
 const int oo=0x3f3f3f3f;
 inline int read(){
       ,f=;
       ;ch=getchar();}
       +ch-';ch=getchar();}
       return x*f;
 }
 ,N;
 namespace solution{
       void pret(){
             memset(prime,,sizeof(prime));
             memset(semi,,sizeof(semi));
             memset(ans,,sizeof(ans));
             ;i<=LIM;i+=){
                   if(prime[i])continue;
                   Count[++cnt]=i;
                   ;i*(*j+)<=LIM;j++)prime[i*(*j+)]=;
             }
             up(i,,cnt)up(j,,i)if(Count[i]*Count[j]>LIM)break;
             ;
             up(i,,LIM)ans[i]=ans[i-]+semi[i];
       }
       void slove(){
             )printf("%d %d\n",N,ans[N]);
       }
 }
 int main(){
       //freopen("input.in","r",stdin);
       using namespace solution;
       pret();
       slove();
       ;
 }

POJ3292 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. sencha xtype清单

    xtype Class ----------------- --------------------- actionsheet Ext.ActionSheet audio Ext.Audio butt ...

  2. 安装.NET Framework后程序无法启动的错误处理

    最近发现一直在使用的Database.NET软件无法正常使用了,表现为当尝试进行Sql Server的连接创建时,直接报错 在事件查看器具体错误信息为: 日志名称:          Applicat ...

  3. 东大OJ-一元三次方程解的个数

    1043: Fixed Point 时间限制: 5 Sec  内存限制: 128 MB 提交: 26  解决: 5 [提交][状态][讨论版] 题目描述 In mathematics, a fixed ...

  4. 拼接sql是陷阱

    项目临时新增一个功能,此时我们习惯自己拼接一个sql. 更可怕的是,后期用户要求新增查询条件,甚至有上10个查询条件,这时的拼接更头疼,if append append(" status=@ ...

  5. iSCSI 与 ceph

    SCSI  小型计算机系统接口(SCSI,Small Computer System Interface)是一种用于计算机及其周边设备之间(硬盘.软驱.光驱.打印机.扫描仪等)系统级接口的独立处理器标 ...

  6. Linux不重启的情况下添加硬盘

    众所周知,SATA和SCSI是支持热插拔的,但是新装了这类支持热插拔的驱动器,系统不会马上识别的,往往我们需要重启系统来识别,但是有另外一种方法可以很方面的让系统识别新的设备.作为系统管理员,需要了解 ...

  7. 51nod 1352 扩展欧几里德

    给出N个固定集合{1,N},{2,N-1},{3,N-2},...,{N-1,2},{N,1}.求出有多少个集合满足:第一个元素是A的倍数且第二个元素是B的倍数. 提示: 对于第二组测试数据,集合分别 ...

  8. css-控制元素中的字符超过规定的宽度影藏

    代码如下: <div style="width:100px; white-space:nowrap;overflow:hidden;text-overflow:ellipsis; bo ...

  9. 如何在HTMl网页中插入百度地图

    方法/步骤 1.打开"百度地图生成器"的网址:http://api.map.baidu.com/lbsapi/creatmap/index.html 如下图: 2.在"1 ...

  10. 【HDU 1150】Machine Schedule(二分图匹配)

    机器的不同模式为点,对于每个job,建两条边 A机器需要的模式<->B机器需要的模式. 问题转化为最小点覆盖,然后用二分图的最小点覆盖==最大匹配,用匈牙利算法解. #include &l ...