摘要: 1 #include<iostream> 2 using namespace std; 3 int n; 4 int a[5]; 5 int main() 6 { 7 int m,i; 8 while(~scanf("%d %d",&n,&m)) 9 {10 a[0]=1; 11 a[1]=2;12 a[2]=4;13 a[3]=6;14 if(n<=3)15 printf("%d\n",a[n]%m);16 else17 {1... 阅读全文
posted @ 2012-06-23 23:44 欧阳生朵 阅读(251) 评论(0) 推荐(0) 编辑
摘要: 1 import java.util.*; 2 import java.math.*; 3 public class Main 4 { 5 public static void main(String []args) 6 { 7 Scanner cin=new Scanner(System.in); 8 int i,n; 9 while(cin.hasNext())10 { 11 n=cin.nextInt();12 BigInteger... 阅读全文
posted @ 2012-06-23 23:42 欧阳生朵 阅读(330) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>using namespace std;int n;int main(){ int i; __int64 a[52]; a[1]=3; a[2]=6; a[3]=6; for(i=4;i<51;i++) a[i]=a[i-1]+a[i-2]*2; while(~scanf("%d",&n)) { printf("%I64d\n",a[n]); } return 0;}做了不少的递推题目了,发现了这些题目的结果一般都与前面或者前面的前面的结果有很大关系,自己以后做这种类型的... 阅读全文
posted @ 2012-06-23 23:39 欧阳生朵 阅读(165) 评论(0) 推荐(0) 编辑
摘要: 1 #include<iostream> 2 using namespace std; 3 int n; 4 int main() 5 { 6 int C; 7 int a[21],i; 8 scanf("%d",&C); 9 while(C--)10 {11 scanf("%d",&n);12 a[0]=0;13 a[1]=3;14 a[2]=7;15 for(i=3;i<=20;i++)16 {17 a[i]=a[i-1]*2+a... 阅读全文
posted @ 2012-06-23 23:36 欧阳生朵 阅读(135) 评论(0) 推荐(0) 编辑
摘要: 1 #include <stdio.h> 2 3 #define MAX 31 4 5 int main() 6 { 7 int arr[MAX] ={1,3}; 8 int t,i,j,n; 9 10 scanf("%d",&t);11 12 for(i = 0;i < t;i++)13 {14 scanf("%d",&n);15 for(j = 2;j < n;j++)16 arr[j] = 2*arr[j-2] + arr[j-1];17 printf("%d\n",ar... 阅读全文
posted @ 2012-06-23 23:33 欧阳生朵 阅读(307) 评论(0) 推荐(0) 编辑
摘要: 1 #include<iostream> 2 using namespace std; 3 int n; 4 int main() 5 { 6 int s[55]; 7 while(~scanf("%d",&n)&&n) 8 { 9 int i;10 s[0]=0;11 for(i=1;i<=4;i++)12 s[i]=i;13 s[5]=6;14 s[6]=9;15 s[7]=13;16 for(i=8;i<=54;i++)17 ... 阅读全文
posted @ 2012-06-23 23:31 欧阳生朵 阅读(165) 评论(0) 推荐(0) 编辑
摘要: 1 #include<iostream> 2 using namespace std; 3 int main() 4 { 5 int T,a,b,i; 6 scanf("%d",&T); 7 while(T--) 8 { 9 scanf("%d %d",&a,&b);10 __int64 f0=1,f1=1,f;11 if(b-a==0||b-a==1)12 printf("1\n");13 else14 {15 for(i=2;i<... 阅读全文
posted @ 2012-06-23 23:29 欧阳生朵 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 1 #include<iostream> 2 using namespace std; 3 int main() 4 { 5 int N,M,i; 6 scanf("%d",&N); 7 while(N--) 8 { 9 scanf("%d",&M);10 __int64 f1=1,f2=1,f;11 if(M==1||M==2)12 printf("1\n");13 else14 {15 for(i=3;i<=M;i++)16 ... 阅读全文
posted @ 2012-06-23 23:25 欧阳生朵 阅读(318) 评论(0) 推荐(0) 编辑
摘要: 1 #include<iostream> 2 #include<queue> 3 using namespace std; 4 int map[51][51][51]; 5 int flag[51][51][51]; 6 int A,B,C,T; 7 int dir[][3]={{0,0,1},{0,1,0},{1,0,0},{0,0,-1},{0,-1,0},{-1,0,0}}; 8 struct node 9 {10 int x,y,z;11 int time;12 };13 void bfs()14 {15 int i;16 flag[0][0][0]=... 阅读全文
posted @ 2012-06-23 23:22 欧阳生朵 阅读(167) 评论(0) 推荐(0) 编辑
摘要: 1 #include<iostream> 2 using namespace std; 3 int step[21]; 4 int flag[21]; 5 int a[42]; 6 int n; 7 bool check(int x,int y) 8 { 9 if(a[x+y]&&!flag[y])10 return true;11 else12 return false;13 }14 void dfs(int dp)15 {16 int i;17 if(dp==n)18 {19 if(a[1+step[... 阅读全文
posted @ 2012-06-23 23:18 欧阳生朵 阅读(147) 评论(0) 推荐(0) 编辑
摘要: 1 #include<iostream> 2 using namespace std; 3 char str[200][100]; 4 int flag[200]; 5 int t,i; 6 void dfs(char temp) 7 { 8 int j; 9 if(temp=='m')10 {11 t=1;12 return;13 }14 for(j=0;j<i;j++)15 {16 if(str[j][0]==temp&&!flag[j])17 {18 ... 阅读全文
posted @ 2012-06-23 23:15 欧阳生朵 阅读(199) 评论(0) 推荐(0) 编辑