There are three separate approaches to pattern matching provided by?PostgreSQL: the traditional?SQL?LIKE?operator, the more recent?SIMILAR TO?operator (added in SQL:1999), and?POSIX-style r...
分类:
数据库 时间:
2014-09-01 12:44:23
阅读次数:
380
先上题目:How LaderLader is a game that is played in aregularhexagonal board (all sides equal, all angles are also equal). The game is much similar as pool...
分类:
其他好文 时间:
2014-08-30 20:24:29
阅读次数:
259
题目链接
题意:斐波那契数列,当长度大于8时,要输出前四位和后四位
思路:后四位很简单,矩阵快速幂取模,难度在于前四位的求解。
已知斐波那契数列的通项公式:f(n) = (1 / sqrt(5)) * (((1 + sqrt(5)) / 2) ^ n - ((1 + sqrt(5)) / 2) ^ n),当n >= 40时((1 + sqrt(5)) / 2) ^ n近...
分类:
其他好文 时间:
2014-08-30 15:11:21
阅读次数:
288
http://poj.org/problem?id=3070根据本题算矩阵,用快速幂即可。裸题#include #include #include #include #include #include using namespace std;#define rep(i, n) for(int i=0...
分类:
其他好文 时间:
2014-08-30 09:56:49
阅读次数:
204
题解:找规律……#include int main(){ int n; while(~scanf("%d",&n)){ if((n-2)%4!=0)puts("no"); else puts("yes"); }return 0;}
分类:
其他好文 时间:
2014-08-30 08:45:09
阅读次数:
159
题目链接
题意:给出n和m,求出f(n) % m, f(x)为斐波那契数列。
思路:因为n挺大的,如果直接利用公式计算很有可能会TLE,所以利用矩阵快速幂求解,|(1, 1), (1, 0)| * |f(n - 1), f(n - 2)| = |f(n), f(n - 1)|,所以求f(n)相当于|f(1), f(0)|乘上n - 1次的|(1, 1), (1, 0)|。
...
分类:
其他好文 时间:
2014-08-28 16:57:40
阅读次数:
187
FinonacciT(N) = T(N-1) + T(N-2);>= 2T(N-2) = O(2^(N/2))Memorized Dp algorithm//1,1,2,3,5,8.....Memo = {}fib(n): if n in memo, return memo{n} if n<...
分类:
其他好文 时间:
2014-08-28 04:16:28
阅读次数:
183
How many Fibs?DescriptionRecall the definition of the Fibonacci numbers:f1 := 1 f2 := 2 fn := fn-1 + fn-2 (n>=3) Given two numbers a and b, calcul...
分类:
其他好文 时间:
2014-08-27 20:17:48
阅读次数:
208
#include<iostream>
usingnamespacestd;
intmain()
{
intpound,p0,p1,days,result;
charans;
do
{
cout<<"Pleaseinputthepoundandthedays:\n";
cin>>pound>>days;
intn=days/5;
if(0==n||1==n)
{
result=pound;
cout<<"Theresultis"<<..
分类:
其他好文 时间:
2014-08-26 03:12:26
阅读次数:
204
Fibonacci again and again
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 5093 Accepted Submission(s): 2127
Problem Description
任何一个...
分类:
其他好文 时间:
2014-08-24 23:55:23
阅读次数:
241