poj 3006 Dirichlet's Theorem on Arithmetic Progressions
题目大意:a和d是两个互质的数,则序列a,a+d,a+2d,a+3d,a+4d ...... a+nd 中有无穷多个素数,给出a和d,找出序列中的第n个素数
#include <cstdio> int isPrime(int n) { || (n != && n % == )) ; ; i*i <= n; ++i) ) ; ; } int main() { int a,d,n,cun,temp; while(scanf("%d %d %d",&a,&d,&n) && a && d && n) { cun = ; ; cun != n; ++i) { temp = a + i*d; if(isPrime(temp)) ++cun; } printf("%d\n",temp); } ; }
poj 3006 Dirichlet's Theorem on Arithmetic Progressions的更多相关文章
- poj 3006 Dirichlet's Theorem on Arithmetic Progressions【素数问题】
题目地址:http://poj.org/problem?id=3006 刷了好多水题,来找回状态...... Dirichlet's Theorem on Arithmetic Progression ...
- POJ 3006 Dirichlet's Theorem on Arithmetic Progressions (素数)
Dirichlet's Theorem on Arithmetic Progressions Time Limit: 1000MS Memory Limit: 65536K Total Submi ...
- POJ 3006 Dirichlet's Theorem on Arithmetic Progressions 素数 难度:0
http://poj.org/problem?id=3006 #include <cstdio> using namespace std; bool pm[1000002]; bool u ...
- Dirichlet's Theorem on Arithmetic Progressions 分类: POJ 2015-06-12 21:07 7人阅读 评论(0) 收藏
Dirichlet's Theorem on Arithmetic Progressions Time Limit: 1000MS Memory Limit: 65536K Total Submi ...
- Dirichlet's Theorem on Arithmetic Progressions POJ - 3006 线性欧拉筛
题意 给出a d n 给出数列 a,a+d,a+2d,a+3d......a+kd 问第n个数是几 保证答案不溢出 直接线性筛模拟即可 #include<cstdio> #inclu ...
- Dirichlet's Theorem on Arithmetic Progressions
http://poj.org/problem?id=3006 #include<stdio.h> #include<math.h> int is_prime(int n) { ...
- 【POJ3006】Dirichlet's Theorem on Arithmetic Progressions(素数筛法)
简单的暴力筛法就可. #include <iostream> #include <cstring> #include <cmath> #include <cc ...
- (素数求解)I - Dirichlet's Theorem on Arithmetic Progressions(1.5.5)
Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit cid=1006#sta ...
- Dirichlet's Theorem on Arithmetic Progression
poj3006 Dirichlet's Theorem on Arithmetic Progressions 很显然这是一题有关于素数的题目. 注意数据的范围,爆搜超时无误. 这里要用到筛选法求素数. ...
随机推荐
- ubuntu下root用户配置
01 接着,输入su root,以root用户登录, 由于命令提示符太长,这里输入export PS1='[\u@\h \W]$'重新设置了一下提示符,然后输入 cp -p /etc/lightdm/ ...
- DbProviderFactories.GetFactoryClasses
using System.Data.Common; private void Method1() { DataTable table = DbProviderFactories.GetFactoryC ...
- [HDOJ2512]一卡通大冒险(DP)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2512 给一个数n,问1~n这n个数内的划分.设dp(i,j)为i划分为j个集合时有多少个. 初始化条件 ...
- 在HibernateTemplate里执行Sql语句
如下所示只能执行非Select语句: public static void executeSQL(HibernateTemplate hibernateTemplate, String sql) { ...
- 导出excel小结(C#,.NET,Wpf)
range.NumberFormatLocal = "@"; //设置单元格格式为文本 range.NumberFormatLocal = "@&quo ...
- Microsoft.ACE.OLEDB.12.0 错误 上传读取Excel错误
使用"Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source=" + filePath + ";&quo ...
- c#调用系统资源大集合-2
public static void 打开格式化对话框() { Process.Start("rundll32.exe"," shell32.dll,SHFormatDr ...
- iOS8 LaunchScreen.storyboard
我目前的需求是需要将启动图片通过LaunchScreen.storyboard 来实现. 我首先想到的是创建一个Sb,使用自动布局来布局imageview,并设置如下图: 布局好之后,在Image里 ...
- Java Cardioid 心脏形曲线 (整理)
package demo; import java.awt.Color; import java.awt.Graphics; import javax.swing.JFrame; import jav ...
- 使用phantomjs生成网站快照
http://phantomjs.org/ 昨天(2013/08/12)在代码区看到一个生成站点快照的代码,看了半天才发现,作者仅仅贴出来业务代码,最核心的生成快照图片的代码反而没有给出来. 以前记得 ...