public class Fibonacii{ public int m1(int n){ if(n == 1||n == 2){ return 1; } return m1(n-1) + m1(n-2); } public int m2(int n){ if(n == 1||n == 2){ return 1; } int i = 1; int j = 1; int result = 0; for(int count=3;count<=n;count++){ result = i + j; i…
A. Olympiad time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output The recent All-Berland Olympiad in Informatics featured n participants with each scoring a certain amount of points. As the head…
程序说明:求Fibonacci数列前m个中偶数位的数: 这是编译原理作业,本打算写 求Fibonacci数列前m个数:写了半天,不会写,就放弃了: 程序代码如下: var n1,n2,m,i; procedure panduan; begin i:=2; while i<m do begin n1:=n1+n2; n2:=n1+n2; i:=i+1; write(n2); end; end; begin read(m); n1:=1; n2:=1; if m=2 then write(n1,n2…
In the math class, the evil teacher gave you one unprecedented problem! Here f(n) is the n-th fibonacci number (n >= 0)! Where f(0) = f(1) = 1 and for any n > 1, f(n) = f(n - 1) + f(n - 2). For example, f(2) = 2, f(3) = 3, f(4) = 5 ... The teacher u…
Problem Description Now you are back,and have a task to do: Given you a string s consist of lower-case English letters only,denote f(s) as the number of distinct sub-string of s. And you have some query,each time you should calculate f(s[l...r]), s[l…
You can Solve a Geometry Problem too Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 13549 Accepted Submission(s): 6645 Problem Description Many geometry(几何)problems were designed in the ACM/…
1,2,3,5,8,13..... 求第n个数 def get_num(n): if n == 1: return 1 if n == 2: return 2 return get_num(n - 1) + get_num(n - 2) def get_num(n): if n == 1: return 1 if n == 2: return 2 a = 1 b = 2 for i in range(n - 2): a, b = b, a + b return b分为递归和循环两个求法…
DISUBSTR - Distinct Substrings Given a string, we need to find the total number of its distinct substrings. Input T- number of test cases. T<=20;Each test case consists of one string, whose length is <= 1000 Output For each test case output one nu…