题目很简单,给出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
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
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
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
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++经典教程,本篇博文为C++Primer(第五版)中文版第五章课后编程习题解答。...
分类:
编程语言 时间:
2014-10-28 17:56:31
阅读次数:
281
考虑一个问题: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
素数判定模板。 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第五版中文版 第四章课后编程题...
分类:
编程语言 时间:
2014-10-25 14:36:16
阅读次数:
128
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