2013年8月16日

polya burnside 专题

摘要: polya题目:uva 11077 Find the Permutationsuva 10294 Arif in DhakaLA 3641 Leonardo's Notebookuva 11077 Find the PermutationsHOJ 2084 The Colored CubesHOJ 2647 Megaminx POJ 1286 Necklace of BeadsPOJ 2409 Let it BeadTOJ 2795 The Queen's New NecklacesHDU 1812 Count the TetrisUVa 11255 NecklacePOJ 2 阅读全文

posted @ 2013-08-16 20:49 雄.. 阅读(477) 评论(1) 推荐(0)

2013年8月15日

miller_rabin + pollard_rho模版

摘要: #include#include#include#include#include#define MAXN 100000using namespace std;typedef unsigned long long LL;LL fac[MAXN],cnt,G,L,m,p;LL min(LL a,LL b){ return a>=1; } return ans;}LL pow_mod(LL a,LL b,LL mod){ LL d=1; a%=mod; while(b) { if(b&1) d=mult_mod(d,a,m... 阅读全文

posted @ 2013-08-15 15:22 雄.. 阅读(208) 评论(0) 推荐(0)

uva 11762 数学期望+记忆化搜索

摘要: 题目大意:给一个正整数N,每次可以在不超过N的素数中随机选择一个P,如果P是N的约数,则把N变成N/p,否则N不变,问平均情况下需要多少次随机选择,才能把N变成1?分析:根据数学期望的线性和全期望公式可以为每个状态列出一个方程,例如: f(x)=1+f(6)*1/3+f(3)*1/3+f(2)*1/3等式右边的最前面的“1”是指第一次转移,而后面的几项是后续的转移,用全期望公式展开,一般地,设不超过x的素数有p个,其中有g个是x的因子,则f(x)=1+f(x)*(1-g/p)+Σf(x/y)/p边界f(1)=0。移项后整理得f(x)=(Σf(x/y)+p)/g因为x/y#include#inc 阅读全文

posted @ 2013-08-15 13:52 雄.. 阅读(429) 评论(0) 推荐(0)

2013年8月14日

uva 11427

摘要: 题目大意:每天晚上你都玩纸牌,如果第一次赢了就高高兴兴地去睡觉;如果输了就接着玩,假设每盘游戏获胜的的概率都是p,且各盘游戏相互独立。你是一个固执的完美主义者,因此会一直玩到当晚获胜局数的比例严格大于p时才停止,然后高高兴兴地去睡觉。当然,晚上的时间有限,最懂只玩n盘游戏,如果获胜比例一直不超过p的话,你只能垂头丧气地去睡觉,以后再也不玩纸牌了。你的任务是计算出平均情况下,你会玩多少个晚上的纸牌。分析:每天晚上的情况相互独立,因此先研究单独一天的情况,计算出只玩一晚上纸牌时,“垂头丧气地去睡觉”的概率Q。设d(i,j)表示前i局中每局结束后的获胜比例均不超过p,且前i局一共获胜j局的概率,则根 阅读全文

posted @ 2013-08-14 20:58 雄.. 阅读(354) 评论(0) 推荐(0)

uva 11722

摘要: 题意:你和朋友都要乘坐火车,并且都会途径A城市。你们很想会面,但是你们到达这个城市的准确时刻都无法确定。你会在时间区间[t1,t2]中的任意时刻以相同的概率密度到达。你的朋友则会在时间区间[s1,s2]的任意时刻以相同的概率密度到达。你们的火车都会在A城市停留w分钟。只有在同一,你们所在的火车都停在A城市的时候,才可能会面。你的任务是计算出现这种情况的概率。#include #include #include #include using namespace std; double t1,t2,s1,s2,w; double area(double b) // 求y=x+b... 阅读全文

posted @ 2013-08-14 16:26 雄.. 阅读(288) 评论(0) 推荐(0)

uva 11021

摘要: 题意:有k只麻球,每只活一天就会死亡,临死之前可能会生出一些新的麻球。具体来说,生i个麻球的概率为pi。给定m,求m天后所有麻球死亡的概率。注意,不足m天时就已经全部死亡的情况也算在内。分析:由于每只麻球的后代独立存活,只需求出一开始只有1只麻球,m天后全部死亡的概率f(m)。由全概率公式,有f(i)=p0+p1*f(i-1)+p2*f(i-1)^2+........+P(n-1)*f(i-1),其中pj*f(i-1)^j的含义是这个麻球生了j个后代,他们在i-1天后全部死亡。#include#include#includeusing namespace std;int p[1005];int 阅读全文

posted @ 2013-08-14 11:03 雄.. 阅读(224) 评论(0) 推荐(0)

2013年8月9日

uva 10561 sg定理

摘要: Problem C Treblecross Input:Standard InputOutput:Standard OutputTime Limit:4 SecondsTreblecrossis a two player game where the goal is to get three X in a row on a one-dimensional board. At the start of the game all cells in the board is empty. In each turn a player putsaX in an empty cell, and if th 阅读全文

posted @ 2013-08-09 20:07 雄.. 阅读(287) 评论(0) 推荐(0)

2013年8月8日

二进制下 求分数化小数的循环节问题

摘要: 表示还没理解过程,先贴个模版吧,套用在十进制下的求分数化小数的循环节答案不对。#include #includeusing namespace std;int gcd(int a,int b){ return b?gcd(b,a%b):a;}int euler(int n){ int phi=n; int top=n; for(int i=2;i*i1) phi=phi/n*(n-1); return phi;}int pow_mod(__int64 a,__int64 b,__int64 n){ __int64 t=1; a%=n; while... 阅读全文

posted @ 2013-08-08 11:10 雄.. 阅读(439) 评论(0) 推荐(0)

2013年8月7日

zoj 2562 反素数

摘要: 题目大意:求n范围内最大的反素数(反素数定义:f(x)表示x的因子数,f(x)>f(x1) (0=p2>=......>=pn证明:若pi#includeusing namespace std;typedef long long LL;int prime[15]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};LL n,ans,Max;void dfs(LL sum,LL num,LL k,LL t){ if(sum>Max) {Max=sum;ans=num;} if(sum==Max && num14) retu 阅读全文

posted @ 2013-08-07 22:36 雄.. 阅读(194) 评论(0) 推荐(0)

uva 11916 解模方程a^x=b (mod n)

摘要: Emoogle GridYou have to color anMxN(1M,N108) two dimensional grid. You will be providedK(2K108) different colors to do so. You will also be provided a list ofB(0B500) list of blocked cells of this grid. You cannot color those blocked cells. A cell can be described as(x,y), which points to they-th ce 阅读全文

posted @ 2013-08-07 09:44 雄.. 阅读(545) 评论(0) 推荐(0)

导航