摘要:
" 题目链接 " Description Farmer John has built a new long barn, with N (2 include include using namespace std; int N,M; int x[100009]; bool C(int d) { int 阅读全文
摘要:
" 题目链接 " Description Inhabitants of the Wonderland have decided to hold a regional programming contest. The Judging Committee has volunteered and has 阅读全文
摘要:
Problem You have been invited to the popular TV show "Would you like to be a millionaire?". Of course you would! The rules of the show are simple: Bef 阅读全文
摘要:
一个监狱里有P个并排着的牢房,从左往右一次编号为1,2,…,P。最初所有牢房里面都住着一个囚犯。现在要释放一些囚犯。如果释放某个牢房里的囚犯,必须要贿赂两边所有的囚犯一个金币,直到监狱的两端或者空牢房为止。现在要释放a1,a2,...,aQ号囚犯,如何选择释放的顺序,使得使用的金币最少。 思路: 其 阅读全文
摘要:
Problem You are given an N x N matrix with 0 and 1 values. You can swap any two adjacent rows of the matrix. Your goal is to have all the 1 values in 阅读全文
摘要:
快速幂取模算法 所谓的快速幂,实际上是快速幂取模的缩写,简单的说,就是快速的求一个幂式的模(余)。在程序设计过程中,经常要去求一些大数对于某个数的余数,为了得到更快、计算范围更大的算法,产生了快速幂取模算法。 我们先从简单的例子入手:求x^n % mod 。 算法1.首先直接地来设计这个算法: 本算 阅读全文