题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3696 Alien's Organ Time Limit: 2 Seconds      Memory Limit: 65536 KB There's an alien whose name is Marjar. It is an universal solder came from planet Highrich a long time ago. Marjar…
看了好久的题,但还是看得一脸蒙圈,感觉完全无从下手,我的队友告诉我可能是正太分布之类的,但我感觉不太像,后来才听同学说是泊松分布,才恍然大悟,概率论刚刚学过这里不久,不禁感叹,学会了还要会用啊... 泊松分布的概率函数为:(我忽然发现一件日狗的事情,那就是我发的图片被和谐掉了……): (作者正在疯狂吐血中……) 泊松分布的参数λ是单位时间(或单位面积)内随机事件的平均发生率. 泊松分布适合于描述单位时间内随机事件发生的次数,与题目描述相应和,单位时间就是天, λ 是一天内随机事件的平均发生率.求…
泊松分布.... Alien's Organ Time Limit: 2 Seconds      Memory Limit: 65536 KB There's an alien whose name is Marjar. It is an universal solder came from planet Highrich a long time ago. Marjar is a strange alien. It needs to generate new organs(body parts…
Alien's Organ Time Limit: 2 Seconds      Memory Limit: 65536 KB There's an alien whose name is Marjar. It is an universal solder came from planet Highrich a long time ago. Marjar is a strange alien. It needs to generate new organs(body parts) to figh…
主题链接: HDU:pid=4430" target="_blank">http://acm.hdu.edu.cn/showproblem.php?pid=4430 ZJU:problemId=4888" target="_blank">http://acm.zju.edu.cn/onlinejudge/showProblem.do? problemId=4888 Problem Description Today is Yukari…
称号:四方形定理.输出可以表示为一个数目不超过四个平方和表示的数. 分析:dp,完全背包.背包分割整数.可用一维分数计算,它也可以被写为一个二维团结. 状态:设f(i,j,k)为前i个数字,取j个数字他们的平方和是k的便是方法数. 转移:f(i,j,k)= sum(f(i-1,j-1.k-i*i)).{ 当中i能够省掉不写 }. 说明:打表计算.求和输出就可以.(2011-09-19 11:01) #include <stdio.h> #include <string.h> int…
称号:拼布钱,表面值至1,5.10.25.寻求组成n表面值硬币的最大数目. 分析:dp,01背包.需要二元分割,除此以外TLE.使用每个硬币的数组记录数.轻松升级. 写了一个 多重背包的 O(NV)反而没有拆分快.囧,最后利用了状态压缩优化 90ms: 把 1 cents 的最后处理,其它都除以5,状态就少了5倍了. 说明:貌似我的比大黄的快.(2011-09-26 12:49). #include <stdio.h> #include <stdlib.h> #include &l…
称号:序列,在前面的每个元件的至少两倍,最大值至n.问:长l船舶有许多这样的. 分析:dp,LIS类别似事. 状态:f(i,j)结束数字为j且长度为i的序列的个数.有转移方程: F[ i ][ j ] = Sum(F[ i-1 ][ k ]) { 2^(i-2)<= k <= j/2). 再用S[ i ][ j ]求出长度为i结束不超过j的串的个数就能够了. 说明:(2011-09-19 01:33). #include <iostream> #include <cstdli…
题目链接: HDU:http://acm.hdu.edu.cn/showproblem.php?pid=4791 ZJU:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5072 Problem Description Alice is providing print service, while the pricing doesn't seem to be reasonable, so people using her pr…
链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1109 FatMouse prepared M pounds of cat food, ready to trade with the cats guarding the warehouse containing his favorite food, JavaBean. The warehouse has N rooms. The i-th room contains J…
题目:在m*n的地板上铺上同样的1*2的地板砖,问有多少种铺法. 分析:dp,组合,计数.经典dp问题,状态压缩. 状态:设f(i,j)为前i-1行铺满,第i行铺的状态的位表示为j时的铺砖种类数: 转移:由于仅仅能横铺或者竖铺.那么一个砖块铺之前的状态仅仅有两种: 且假设当前竖放会对下一行产生影响,建立相邻两行状态相应关系. 这里利用dfs找到全部f(i.j)的上一行的全部前置状态f(i-1,k)加和就可以. f(i.j)= sum(f(i-1,k)){ 当中,f(i-1,k)能够产生f(i.j…
链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3587 题意:给出两个字符串S和T.S,T<=100000.拿出S的两个子串(能够重叠),将两个子串连接起来成为字符串T的方法有多少种. 思路:用扩展KMP求出S的从每位開始的子串与T的公共前缀,再将两个子串翻转,再用扩展KMP求出S反的从每位開始的子串与T反的公共前缀.找出当中和为T子串长度的S公共前缀和S反的公共前缀的数量,相乘为结果. 代码: #include…
K - Alien's Organ Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu Submit Status Description There's an alien whose name is Marjar. It is an universal solder came from planet Highrich a long time ago. Marjar is a strange ali…
Alien's Organ Time Limit: 2 Seconds      Memory Limit: 65536 KB There's an alien whose name is Marjar. It is an universal solder came from planet Highrich a long time ago. Marjar is a strange alien. It needs to generate new organs(body parts) to figh…
/*二项分布即重复n次的伯努利试验,每次发生的概率一样,假设成功的概率是p,那么失败的概率就是1-p: 二项分布的概率公式:试验中发生K次的概率是 P(ξ=K)= C(n,k) * p^k * (1-p)^(n-k), 其中C(n, k) = n!/(k! * (n-k)!) 因为这里的数据,k最大为100,100的阶乘超过了int64位,所以不能用这个公式,这时候可以用泊松分布的概率 公式求近似值. 好了接着解释题意:这道题输入n和m,求m是期望,求实验中发生不超过n次的概率,所有所有的概率为…
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=516 Your old uncle Tom inherited a piece of land from his great-great-uncle. Originally, the property had been in the shape of a rectangle. A long time ago, however, his great-great-uncl…
Marlon's String Time Limit: 2 Seconds      Memory Limit: 65536 KB Long long ago, there was a coder named Marlon. One day he picked two string on the street.A problem suddenly crash his brain... Let Si..j denote the i-th character to the j-th characte…
传送门: Detect the Virus                                                                                                                                                                                                                                     …
假设想给上节讲的场景图库添加收集诊断信息的功能.这对于调试和性能分析很有用. 38条示例续 给每个Actor实例一个唯一的标识数. 添加标识数 function Actor(scene,x,y){ this.scene=scene; this.x=x; this.y=y; this.id=++Actor.nextID; scene.register(this); } Actor.nextID=0; 现在我们需要对Actor的子类做同样的事.假设,Alien类代表太空飞船的敌人.除了其角色标识数外…
1: /** 2: ZOJ 3229 有上下界的最大流 3: 两次求最大流的过程,非二分 4: 有源汇上下界的最大流问题, 首先连接 sink -> src, [0,INF]. 5: 根据net的正负,来建立 Supersrc 与 supersink 之间的边,做一次 maxflow. 6: 若所有的Supersrc 与 Supersink满流,则说明存在可行流. 7: 然后删除 sink -> src之间的边.(cap 置零即可). 从src -> sink 做一次最大流. 8: 两次…
Detect the Virus Time Limit: 2 Seconds      Memory Limit: 65536 KB One day, Nobita found that his computer is extremely slow. After several hours' work, he finally found that it was a virus that made his poor computer slow and the virus was activated…
[热烈庆祝ZOJ回归] P1002:简单的DFS #include <cstdio> #include <cstring> #include <algorithm> ][]; int N; int input() { scanf("%d",&N); ;i<N;i++) scanf("%s",map[i]); return N; } ][]; ,sizeof(disable)); } int dfs(int cur)…
题目大意:输入一串递增的单词序列,需要找出符合条件的单词递增输出,条件是:将一个单词拆成左右两个单词后,能在输入中找到这两个单词.例如单词 alien,可以拆成 a 和 lien,而输入中刚好同时有a和lien,则符合条件,输出alien.又如单词born,无论拆成b和orn,还是bo和rn,亦或是bor和n,都无法在输入中同时找到两个被拆分的单词. 解题思路:把每一个单词拆成两个,然后就看这两个单词是否在输入单词里面.因此可以采用set集合来判断某个单词是否存在输入单词序列里面,用substr…
POJ 1860 Currency Exchange / ZOJ 1544 Currency Exchange (最短路径相关,spfa求环) Description Several currency exchange points are working in our city. Let us suppose that each point specializes in two particular currencies and performs exchange operations onl…
p(k)=(y^k) / (k!) * e^(-y) 其中的y就是平均值 k就是我们要求的大小. Alien's Organ Time Limit: 2 Seconds      Memory Limit: 65536 KB There's an alien whose name is Marjar. It is an universal solder came from planet Highrich a long time ago. Marjar is a strange alien. It…
转自:http://www.cnblogs.com/kevince/p/3887827.html 首先声明一下,这里的规律指的是循环,即找到最小循环周期. 这么一说大家心里肯定有数了吧,“不就是next数组性质的应用嘛”,没错,正是如此. 在ACM的比赛中有些时候会遇到一些题目,可以或必须通过找出数据的规律来编写代码,这里我们专门来讨论下 如何运用KMP中next数组的性质 来寻找一个长数组中的最小循环周期. 先来看一道题 ZOJ 3785 What day is that day? Time…
题目链接:https://vjudge.net/problem/ZOJ-3430 Detect the Virus Time Limit: 2 Seconds      Memory Limit: 65536 KB One day, Nobita found that his computer is extremely slow. After several hours' work, he finally found that it was a virus that made his poor…
反素数: 对于不论什么正整数x,起约数的个数记做g(x).比如g(1)=1,g(6)=4. 假设某个正整数x满足:对于随意i(0<i<x),都有g(i)<g(x),则称x为反素数. ZOJ 2562 反素数 由于写了POJ 2886的线段树.然后里面有反素数,曾经没遇到过,所以先搞这两题普及一下知识再说. #include<iostream> #include<cstdio> #include<cstring> #include<algorith…
Knight Moves A friend of you is doing research on the Traveling Knight Problem (TKP) where you are to find the shortest closed tour of knight moves that visits each square of a given set of n squares on a chessboard exactly once. He thinks that the m…
Do the Untwish 题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1006 题意:给定密文按公式解密 注意点:pcode = (ccode + i)%28;的使用 贴代码: 1 //Problem Name: Do the Untwish 2 //Source: ZOJ 1006 3 //Author: jinjin18 4 //Main idea: easy to solve 5 //Languag…