随笔分类 - POJ分类
POJ
摘要:http://poj.org/problem?id=1811View Code /*=====================================================*\| Miller Rabin 判断一个大数是不是素数 | Pollard 找出因子\*=====================================================*/#define inf 0x3f3f3f3f#define linf inf*inf#define SS 8//Miller测试次数#define C 240typedef long long ll;ll N,
阅读全文
摘要:http://poj.org/problem?id=3420View Code //矩阵乘法做递推Matrix mat(16,16);void get_init() { mat.reset(); mat(0,15)=mat(1,14)=mat(2,13)=1; mat(3,12)=mat(3,15)=mat(4,11)=1; mat(5,10)=mat(6,9)=mat(6,15)=1; mat(7,8)=mat(7,14)=mat(7,11)=1; mat(8,7)=mat(9,6)=mat(10,5)=1; mat(11,4)=mat(11,7)=...
阅读全文
摘要:find a+b+c=d , 3sum problem 枚举dhttp://poj.org/problem?id=2549View Code const int MM = 111111;int N;int num[MM];void get_data() { int i,j,k; for(i=0;i<N;i++) scanf("%d",&num[i]);}//choose three number from a set,then a+b+c=0void threesum(int n,int*val) { int i,j,k,a,b,c,tmp,l; sort(v
阅读全文
摘要:http://poj.org/problem?id=1753View Code struct GaussE { int a[MM][MM]; int x[MM]; // 解集 int equ, var; int free_x[MM]; // 记录不确定的变元. //初始化 GaussE(int e,int v):equ(e), var(v) {} void reset() { memset(a,0,sizeof(a)); memset(x,0,sizeof(x)); memset(free_x,0,sizeof...
阅读全文
摘要:View Code //POJ 1204#include <iostream>#include <cstdio>#include <cstring>using namespace std;#define ROOT 0#define debug puts("wrong")const int MM=1010;const int MAX_NODE=100100;const int CHI=26;int L,C,W;int cnt;int len[MM];int ansx[MM], ansy[MM], ansk[MM];char text[MAX
阅读全文
摘要:POJ2236 简单并查集POJ2492 转化一下的并查集,对于<x,y> , <x,z>则(y,z)必然是属于一个集合的http://paste.ubuntu.com/1541478/POJ 1182 http://poj.org/problem?id=1182(未做)
阅读全文