题目大意:给出一个等差数列,问这个等差数列的第n个素数是什么. 思路:这题主要考怎样筛素数,线性筛.详见代码. CODE: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #define MAX 1000010 using namespace std; int prime[MAX],primes; bool notp[MAX]; int a,d,n;…
Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit cid=1006#status//I/0" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" style="font-family:Verdana,Arial,sans-serif; f…
题目地址:http://poj.org/problem?id=3006 刷了好多水题,来找回状态...... Dirichlet's Theorem on Arithmetic Progressions Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 16803   Accepted: 8474 Description If a and d are relatively prime positive integers, t…
Dirichlet's Theorem on Arithmetic Progressions Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 13636   Accepted: 6808 Description If a and d are relatively prime positive integers, the arithmetic sequence beginning with a and increasing…
Dirichlet's Theorem on Arithmetic Progressions Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 16733   Accepted: 8427 Description If a and d are relatively prime positive integers, the arithmetic sequence beginning with a and increasing…
http://poj.org/problem?id=3006 #include <cstdio> using namespace std; bool pm[1000002]; bool usd[1000002]; bool judge(int x) { if(usd[x])return pm[x]; usd[x] = true; if(x == 2) return pm[x] = true; if(((x & 1) == 0) || (x < 2))return pm[x] =…
题目大意: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,a+d,a+2d,a+3d......a+kd 问第n个数是几 保证答案不溢出 直接线性筛模拟即可 #include<cstdio> #include<cstring> using namespace std; ]; ]; ]; int cnt; void Prime(int n){ cnt=; memset(Is_Primes,,sizeof(Is_Primes)); ;i<=n;i++){ if(!Is_Primes[i]) Pr…
http://poj.org/problem?id=3006 #include<stdio.h> #include<math.h> int is_prime(int n) { int i,m; ) ; m = sqrt(n); ; i <= m; i ++) { ) ; } ; } int main() { int a,d,n,i; while(~scanf("%d%d%d",&a,&d,&n)) { ; &&d==…
简单的暴力筛法就可. #include <iostream> #include <cstring> #include <cmath> #include <cctype> #include <cstdio> #include <cmath> #include <algorithm> #include <numeric> using namespace std; , M = ; bool is[N]; int pr…