Dirichlet's Theorem on Arithmetic Progressions

时间:2022-08-27 15:11:30

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的更多相关文章

  1. Dirichlet&&num;39&semi;s Theorem on Arithmetic Progressions 分类: POJ 2015-06-12 21&colon;07 7人阅读 评论&lpar;0&rpar; 收藏

    Dirichlet's Theorem on Arithmetic Progressions Time Limit: 1000MS   Memory Limit: 65536K Total Submi ...

  2. POJ 3006 Dirichlet&&num;39&semi;s Theorem on Arithmetic Progressions (素数)

    Dirichlet's Theorem on Arithmetic Progressions Time Limit: 1000MS   Memory Limit: 65536K Total Submi ...

  3. poj 3006 Dirichlet&&num;39&semi;s Theorem on Arithmetic Progressions【素数问题】

    题目地址:http://poj.org/problem?id=3006 刷了好多水题,来找回状态...... Dirichlet's Theorem on Arithmetic Progression ...

  4. POJ 3006 Dirichlet&&num;39&semi;s Theorem on Arithmetic Progressions 素数 难度&colon;0

    http://poj.org/problem?id=3006 #include <cstdio> using namespace std; bool pm[1000002]; bool u ...

  5. poj 3006 Dirichlet&&num;39&semi;s Theorem on Arithmetic Progressions

    题目大意:a和d是两个互质的数,则序列a,a+d,a+2d,a+3d,a+4d ...... a+nd 中有无穷多个素数,给出a和d,找出序列中的第n个素数 #include <cstdio&g ...

  6. 【POJ3006】Dirichlet&&num;39&semi;s Theorem on Arithmetic Progressions(素数筛法)

    简单的暴力筛法就可. #include <iostream> #include <cstring> #include <cmath> #include <cc ...

  7. Dirichlet&&num;39&semi;s Theorem on Arithmetic Progressions POJ - 3006 线性欧拉筛

    题意 给出a d n    给出数列 a,a+d,a+2d,a+3d......a+kd 问第n个数是几 保证答案不溢出 直接线性筛模拟即可 #include<cstdio> #inclu ...

  8. (素数求解)I - Dirichlet&amp&semi;&num;39&semi;s Theorem on Arithmetic Progressions&lpar;1&period;5&period;5&rpar;

    Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit cid=1006#sta ...

  9. Dirichlet&&num;39&semi;s Theorem on Arithmetic Progression

    poj3006 Dirichlet's Theorem on Arithmetic Progressions 很显然这是一题有关于素数的题目. 注意数据的范围,爆搜超时无误. 这里要用到筛选法求素数. ...

随机推荐

  1. Hibernate之即时更新

    昨天工作中遇到了一个简单的问题,弄了好久,都怪自己没有好好的去了解hibernate,导致了这样的问题弄了两三个小时. 问题是这样的:我想即时更改数据,然后再查询 (1)用Spring的getHibe ...

  2. eclipse推荐的插件

    1.Log4j的颜色插件 http://m.blog.csdn.net/blog/JavaWinner/41548259

  3. 观察者(observer)设计模式

    转载:http://www.tracefact.net/CSharp-Programming/Delegates-and-Events-in-CSharp.aspx 假设我们有个高档的热水器,我们给它 ...

  4. 【Android - 进阶】之图片三级缓存的原理及实现

    在Android开发中,如果图片过多,而我们又没有对图片进行有效的缓存,就很容易导致OOM(Out Of Memory)错误.因此,图片的缓存是非常重要的,尤其是对图片非常多的应用.现在很多框架都做了 ...

  5. iOS 发布应用时屏蔽NSLog

    在开发过程中,经常需要使用NSLog来进行调试,但是NSLog是非常影响性能的,所以我们应该在发布应用时屏蔽掉NSLog,但是如果通过手工的去一行一行的改得话,未免太枯燥与费时了,庆幸的是,我们可以通 ...

  6. STL中map的用法

    map是STL的一个关联容器,它提供一对一(其中第一个可以称为关键字,每个关键字只能在map中出现一次,第二个可能称为该关键字的值)的数据处理能力,由于这个特性,它完成有可能在我们处理一对一数据的时候 ...

  7. Javascript之pixi框架学习

    pixi 创建渲染器(renderer) 创建一个可以播放动画的区域,相当于(canvas). var renderer = PIXI.autoDetectRenderer(512, 512); do ...

  8. Python Generator 运行细节验证

    今天来__next__和send, 改天来throw和close class A: def __setattr__(self, key, val): print('set %s to %s'%(key ...

  9. Bootstrap3基础 栅格系统 页面布局随 浏览器大小的变化而变化

      内容 参数   OS   Windows 10 x64   browser   Firefox 65.0.2   framework     Bootstrap 3.3.7   editor    ...

  10. 15个HTML元素方法&excl;

    首先让我们来讨论一下 HTML 与 DOM 之间的区别. 显然,普通的 <table> 元素就是一段 HTML 代码,它可以应用在任何一个以 .html 为扩展名的文件中.元素自带一系列特 ...