Dirichlet's Theorem on Arithmetic Progressions
http://poj.org/problem?id=3006
#include<stdio.h>
#include<math.h>
int is_prime(int n)
{
int i,m;
if (n==)
return ;
m = sqrt(n);
for (i = ; i <= m; i ++)
{
if (n%i==)
return ;
}
return ;
}
int main()
{
int a,d,n,i;
while(~scanf("%d%d%d",&a,&d,&n))
{
int cnt = ;
if (a==&&d==&&n==)
break;
for (i = a;; i =i+d)
{
if(is_prime(i))
cnt++;
if(cnt==n)
break;
}
printf("%d\n",i);
}
return ;
}
Dirichlet's Theorem on Arithmetic Progressions的更多相关文章
- 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 ...
- 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【素数问题】
题目地址:http://poj.org/problem?id=3006 刷了好多水题,来找回状态...... Dirichlet's Theorem on Arithmetic Progression ...
- 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 ...
- 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&g ...
- 【POJ3006】Dirichlet's Theorem on Arithmetic Progressions(素数筛法)
简单的暴力筛法就可. #include <iostream> #include <cstring> #include <cmath> #include <cc ...
- Dirichlet's Theorem on Arithmetic Progressions POJ - 3006 线性欧拉筛
题意 给出a d n 给出数列 a,a+d,a+2d,a+3d......a+kd 问第n个数是几 保证答案不溢出 直接线性筛模拟即可 #include<cstdio> #inclu ...
- (素数求解)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下获取内核源码
查看当前系统使用的内核版本: apt-cache search linux-source 输出如下: linux-source - Linux kernel source with Ubuntu pa ...
- Codeforces_738B
B. Spotlights time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- How an SSL connection is established
An SSL connection between a client and server is set up by a handshake, the goals of which are: To s ...
- 好用的JS数字格式化
/* *js格式化数字代码 * *value: 要格式化的数字值 *scale: 最多保留几位小数 *zeroed: 是否保留尾0 *percented: 是否转称百分比形式 * */ functio ...
- Win32中 DLL、Lib 库的创建机器使用
Windows 下 的静态库和动态库 一.静态函数库(Lib) 1. 静态函数库的制作(C/C++) —— 打开新建项目,然后选中Win32项目,接着在创建项目中选择 Lib,再接着将函数.实现功能的 ...
- [加强版] Codeforces 835D Palindromic characteristics (回文自动机、DP)
题目链接: https://codeforces.com/contest/835/problem/D 题意: 一个回文串是\(1\)-回文的,如果一个回文串的左半部分和右半部分一样且都是\(k\)-回 ...
- ReportNG 替换testng过程中遇到的问题
1. Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/collectio ...
- Python 5 运算符
数学运算符: + 加 1 + 1 = 2 - 减 2 - 1 = 1 × 乘 2 × 2 = 4 / 除 3 / 2 = 1.5 不同版本可能显示小数位数不同 ...
- C++ 数据结构模板 队列 栈 动态链表 模板 Queue Stack List
C++数据结构模板,可以实现基本功能,用法和stl差不多,比如Q.pop();Q.push(a);Q.front();...... (由于动态链表用的不多,若有错误望各位大神不吝赐教:) 队列: cl ...
- 【学QT】1 - QT的安装
1.解压文件在/usr/local/下 #tar zxvf qt-x11-free-3.3.8b.tar.gz -C /usr/local 更改文件夹名称为qt #mv /usr/local/qt-x ...