码迷,mamicode.com
首页 >  
搜索关键字:bear and prime numbe    ( 2904个结果
hdu1016【dfs】
题目很简单,给出n(1 2 #include 3 using namespace std; 4 bool prime[40]; 5 bool hash[40]; 6 int ans[40]; 7 int n; 8 int cas = 1; 9 10 void getprime() {11 ...
分类:其他好文   时间:2014-10-30 20:41:33    阅读次数:229
poj3126--Prime Path(广搜)
Prime Path Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11751   Accepted: 6673 Description The ministers of the cabinet were quite upset by the message from...
分类:其他好文   时间:2014-10-30 17:08:51    阅读次数:194
hdu 4135 Co-prime(容斥原理)
http://acm.hdu.edu.cn/showproblem.php?pid=4135 求连续区间[a,b]内与n互质的数的个数。 因为a,b相当大,考虑用容斥原理。只需先求出[a,b]内与n不互质的数的个数,等于[1,b]内与n不互质的个数 - [1,a-1]内与n不互质的个数。问题转化为求【1,m】内与n不互质的数的个数。 先对n分解质因子,[1,m]内是n的质因子的倍数的...
分类:其他好文   时间:2014-10-30 00:27:50    阅读次数:266
Codeforces Round #226 (Div. 2)--A Bear and Raspberry
ACdaim #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define INF 0x7fffffff int main() { #ifdef sxk...
分类:Web程序   时间:2014-10-29 07:04:15    阅读次数:148
O(n) 筛法求素数
var tot,i,j,k,m,n:longint; prime:array[0..100000] of boolean; p:array[0..100000] of longint;begin read(n); fillchar(prime,sizeof(prime),true); p...
分类:其他好文   时间:2014-10-28 21:13:10    阅读次数:174
C++ Primer第五章课后编程题
C++ Primer第五版这本书是久负盛名的C++经典教程,本篇博文为C++Primer(第五版)中文版第五章课后编程习题解答。...
分类:编程语言   时间:2014-10-28 17:56:31    阅读次数:281
POJ2417 Baby-Step-Gaint-Step 算法
考虑一个问题:A^x%p=B,给定A,B,p,求x的最小非负整数解。 在p是质数的情况下,这个问题比较简单。 A^x=B(mod P) (P is a Prime, A,B Let m = floor(sqrt(P)) Put A^0,A^1,...A^(m-1) into HashSet(You Can Also Use Map in STL),for Example M[A^i]=i....
分类:编程语言   时间:2014-10-28 13:55:30    阅读次数:271
【数论】【素数判定】CODEVS 2851 菜菜买气球
素数判定模板。 1 #include 2 #include 3 using namespace std; 4 int a[2001],ans=-2147483647,l,r,n,sum[2001]; 5 bool is_prime(const int &x) 6 { 7 for(int i=...
分类:其他好文   时间:2014-10-27 12:17:56    阅读次数:172
C++ Primer第四章课后编程题
C++ Primer第五版中文版 第四章课后编程题...
分类:编程语言   时间:2014-10-25 14:36:16    阅读次数:128
Exercise 31: Making Decisions
print "You enter a dark room with two doors. Do you go through door #1 or door #2?"door = raw_input("> ")if door == "1": print "There's a giant bear ....
分类:其他好文   时间:2014-10-24 18:34:08    阅读次数:242
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!