随笔分类 - 数学
摘要:The problem is so easy, that the authors were lazy to write a statement for it!InputThe input stream contains aset ofinteger numbersAi(0≤Ai≤ 10^18). The numbers are separated byany number ofspaces and line breaks. Asize ofthe input stream does not exceed 256KB.OutputFor each numberAifrom the last on
阅读全文
摘要:DescriptionBeads of red, blue or green colors are connected together into a circular necklace of n beads ( n _ 2 #include 3 #include 4 #include 5 using namespace std; 6 typedef long long LL; 7 8 const int MAXN = 25; 9 10 int n, m = 3;11 bool vis[MAXN];12 13 LL power(LL x, int p) {14 LL ret =...
阅读全文
摘要:One day Greg and his friends were walking in the forest. Overall there werenpeople walking, including Greg. Soon he found himself in front of a river. The guys immediately decided to get across the river. Luckily, there was a boat by the river bank, just where the guys were standing. We know that th
阅读全文
摘要:DescriptionA well known algorithm called heapsort is a deterministic sorting algorithm taking O(n log n) time and O(1) additional memory. Let us describe ascending sorting of an array of different integer numbers. The algorithm consists of two phases. In the first phase, called heapification, the ar
阅读全文
摘要:DescriptionHave you ever thought about comparing the weight of fruits? That’s what you should do in this problem! Given a series of fruit weight comparisons, you should anticipate the result of another comparison. In this problem, all fruits of the same kind are identical and have the same weights.
阅读全文
摘要:DescriptionDavy Jones: You've been captain of the Black Pearl for 13 years. That was our agreement. Jack: Technically I was only captain for two years, then I was mutinied upon. Davy Jones: Then you were a poor captain, but a captain nonetheless. Have you not introduced yourself as Captain Jack
阅读全文
摘要:DescriptionBootstrap: Wondering how it's played? Will: It's a game of deception. But your bet includes all the dice, not just your own. What are they wagering? Bootstrap: Oh, the only thing we have. Years of service. Will: So any crew member can be challenged? Bootstrap: Aye. Anyone. Will: I
阅读全文
摘要:DescriptionOne day, Implus gets interested in binary addition and binary carry. He will transfer all decimal digits to binary digits to make the addition. Not as clever as Gauss, to make the addition from a to b, he will add them one by one from a to b in order. For example, from 1 to 3 (decimal dig
阅读全文
摘要:In finance, Internal Rate of Return (IRR) is the discount rate of an investment when NPV equals zero. Formally, givenT,CF0,CF1, ...,CFT, thenIRRis the solution to the following equation:NPV=CF0+++K+= 0Your task is to find all validIRRs. In this problem, the initial cash-flowCF0 0for alli= 1, 2,...).
阅读全文
摘要:Input: Standard Input Output: Standard Output� There is a rectangle on the cartesian plane, with bottom-left corner at (0,0) and top-right corner at(L,W). There is a ball centered at(x,y), with radius=R, shown belowAt time 0, the ball starts to move along a ray with polar anglea(the angle from posit
阅读全文
摘要:Problem Description A sequence Snis defined as:Where a, b, n, m are positive integers.┌x┐is the ceil of x. For example, ┌3.14┐=4. You are to calculate Sn. You, a top coder, say: So easy!Input There are several test cases, each test case in one line contains four positive integers: a, b, n, m. Whe...
阅读全文
摘要:Problem DescriptionA Fibonacci sequence is calculated by adding the previous two members the sequence, with the first two members being both 1. F(1) = 1, F(2) = 1, F(3) = 1,F(4) = 1, F(n>4) = F(n - 1) + F(n-2) + F(n-3) + F(n-4) Your task is to take a number as input, and print that Fibonacci numb
阅读全文
摘要:Problem DescriptionGiven an integer N(0 ≤ N ≤ 10000), your task is to calculate N!InputOne N in one line, process to the end of file.OutputFor each N, output N! in one line.题目大意:求N的阶乘。思路:用高精度,内存存不下这么多只能每次都重新算了……代码(3093MS): 1 //模板测试 2 #include 3 #include 4 #include 5 #include 6 #include 7...
阅读全文
摘要:1、求逆元1 int inv(int a) {2 if(a == 1) return 1;3 return (MOD - MOD / a) * inv(MOD % a);4 }View Code 2、线性筛法 1 bool isPrime[MAXN]; 2 int label[MAX...
阅读全文
摘要:一、代码: 1、求逆元(原理貌似就是拓展欧几里得,要求MOD是素数): 2、底层优化(正确性未验证): 3、扩栈,这玩意儿在OJ上用能防爆? 4、神速读入fread 二、神牛blog matrix67 ZKW watashi 三、专题 动态规划系列: 数位dp模板 字符串系列: 【专辑】AC自动机
阅读全文
摘要:DescriptionN(3 2 #include 3 #include 4 #include 5 using namespace std; 6 typedef long long LL; 7 8 const int MAXN = 20010; 9 10 struct Node {11 int val, id;12 bool operator 0) {29 ret += tree[k];30 k -= lowbit(k);31 }32 return ret;33 }34 35 inline void modify(int...
阅读全文
摘要:Yaroslav has an arrayp = p1, p2, ..., pn(1 ≤ pi ≤ n), consisting ofndistinct integers. Also, he hasmqueries:Query numberiis represented as a pair of integersli,ri(1 ≤ li ≤ ri ≤ n).The answer to the queryli, riis the number of pairs of integersq,w(li ≤ q, w ≤ ri)such thatpqis the divisor ofpw.Help Ya
阅读全文
摘要:转自http://www.cnblogs.com/perseawe/archive/2012/05/03/01fsgh.html//原版为pascal代码,C++代码是我自己写的,写得不好敬请见谅【关键字】0/1分数规划、最优比率生成树、最优比率环【背景】根据楼教主的回忆录,他曾经在某一场比赛中秒掉了一道最优比率生成树问题,导致很多人跟风失败,最终悲剧。自己总结了一些这种问题的解法,因为水平有限,如果有错误或是麻烦的地方,尽管喷,邮箱或是下方留言。联系我的话perseawe@163.com,欢迎讨论,请在标题前注明[acm]或是[oi],以免被垃圾邮件。【知识储备】只会用到简单的公式的整理与变
阅读全文
摘要:ProblemDescriptionBandBandRockisquitesensitivewithnumbers(anumberisdefinedasasequenceformedby‘0’-‘9’).Hethinksthislistofluckynumberscanbringhimluck(forexamplehisluckylistcouldbe9,13)andhelovesthesenumbersverymuch!Oneday,BandBandRockischoosingapasswordforhisbankaccount(apasswordisasequenceformedby‘0’
阅读全文

浙公网安备 33010602011771号