03 2014 档案

摘要:#include#include#includeusing namespace std;__int64 pow_mod1(__int64 a,__int64 n,__int64 m){ if(n==0) return 1; __int64 ans,x=pow_mod1(a,n/2,m); ans=(x*x)%m; if(n%2) ans=(ans*a)%m; return ans;}__int64 pow_mod2(__int64 a, __int64 b, __int64 c){ __int64 ans = 1; a = a % c; while(b>0) { if(b%2==1) a 阅读全文
posted @ 2014-03-17 17:02 来自大山深处的菜鸟 阅读(119) 评论(0) 推荐(0) 编辑
摘要:/* 很好的字符串 比较方法 很多个字符串 组成的 数字 需要最大 然后 比较 a和b 是 比较a+b 和b+a 的大小*/#include#include#include#includeusing namespace std;struct point{ char str[100];}T[55];bool cmp(point A,point B){ int i,a=strlen(A.str),b=strlen(B.str); point C=A,D=B; for(i=0;iD.str[i]; } return true;}int main(){ int n,i; c... 阅读全文
posted @ 2014-03-09 22:38 来自大山深处的菜鸟 阅读(146) 评论(0) 推荐(0) 编辑
摘要:/* 最长公共子序列*/#include #include #include const int maxn=105;int N[maxn],M[maxn];int dp[2][maxn];int main(){ int i,j,n,m,num=0; while(true){ scanf("%d%d",&n,&m); if(n==0&&m==0) break; for(i=0;idp[d^1][j]?dp[d][j-1]:dp[d^1][j]; } d=d^1; } printf("Twin Towers #%d\n",++ 阅读全文
posted @ 2014-03-09 21:33 来自大山深处的菜鸟 阅读(184) 评论(0) 推荐(0) 编辑
摘要:/* (栈)这里 有一个需要知道的 如果一个点走出了 原来的 位置 那么它最早的那个位置的 当他在回到原来位置的时候 可能还会有 块在那个下面 根据这点 我们就可以 大胆 的进行出栈入栈操作 */#include #include #include using namespace std;int L[30],N[30][30],num[30],t1,t2,A,B,KH[30],n;void dec(int er){ int i,LOC=L[er]; for(i=num[LOC];i>=1;i--){ if(N[LOC][i]==er) break; int d=N[LOC... 阅读全文
posted @ 2014-03-09 20:26 来自大山深处的菜鸟 阅读(314) 评论(0) 推荐(0) 编辑
摘要:/* 最长递减子序列, 题目说的是 每头大象都有体重和IQ 要证明 随着 体重的增加智商 在不断的减少的最长序列 解 : 先对 体重进行一次排序 ,排完后 LIS(最长递增(减)子序列) */#include #include #include #include #include using namespace std;struct Elephant{ int num,W,S; bool operator T[j].W&&(dp[i]maxv) maxv=dp[i]; } for(i=num-1;i>=0;i--) if(dp[i]==maxv) break; ... 阅读全文
posted @ 2014-03-08 14:26 来自大山深处的菜鸟 阅读(409) 评论(0) 推荐(0) 编辑
摘要:/* 暴力 过了 要使得两半的 樱桃数目相等 去试每一个斜率 还好他这里要的是 A、B 都为正整数 这样范围就锁定在200*100 个点范围内*/#include #include #include using namespace std;struct point{ int x,y;}node[110];void solve(int num){ int i; for(int A=-100;A0)L++; if(d<0)R++; if(d==0) break; } if(L==num/2&&R==num/2&&i==num){ printf("%d 阅读全文
posted @ 2014-03-08 13:39 来自大山深处的菜鸟 阅读(196) 评论(0) 推荐(0) 编辑
摘要:During each move the player can chooseall lines of the matrix where dwarf is not on the cell with candyand shout "Let's go!"这个 看成是 选其所有干行 我却看成是选其中 若干 行 水一下自己#include #include #include #include using namespace std;char map[1005][1005];int N[1005],L[1005];int main(){ int n,m; while(scanf 阅读全文
posted @ 2014-03-08 11:22 来自大山深处的菜鸟 阅读(142) 评论(0) 推荐(0) 编辑
摘要:/* 题目是 有一个 m*n 的矩阵然后矩阵中的每个点有个权值 你从 第一列走到最后一列 然后输出最小权值的 路径 和最小权值,来个 倒的 dp[i][j]=min(dp[i+1][j+1],dp[i][j+1],dp[i-1][j+1])+w[i][j]*/#include #include #include using namespace std;int turn[11][3];int map[15][105],dp[15][105];int path[15][105];int main(){ int n,m,i,j,k; while(scanf("%d%d",& 阅读全文
posted @ 2014-03-07 10:11 来自大山深处的菜鸟 阅读(151) 评论(0) 推荐(0) 编辑
摘要:/*2014.3.6 这题说的是给你了一根木棒 然后 n 个点(线段上的点) 然后计算 在这 n个点上都切下去的 最小花费 举个例子 100 3 25 50 75 如果 从 25 开始切 然后切 50 75 则花费是 100 + 75 +50= 225 如果 从 50 开始切 然后切 25 75 则花费 100 +50 +50 =200 相对 更优一些 解题: 可以发现 当 从某个点坐标为 D 切下去后则从0到D的 部分和从 D到 I 的 部分就没有了关系 因此 得到状态转移的 公式 dp[i][j]=min(dp[i][k]+dp[k][j... 阅读全文
posted @ 2014-03-06 18:11 来自大山深处的菜鸟 阅读(212) 评论(0) 推荐(0) 编辑
摘要:/* 坑了 把 重载的#include#include#includeusing namespace std;struct word{ char str[205]; bool operator ='A'&&str[i]='a'&&str[i]='a'&&str[i]<='z'&&i<L){ T[num].str[Len++]=str[i]; i++; } num++; }else i++; } sort(T,T+num); printf("%s\ 阅读全文
posted @ 2014-03-05 20:58 来自大山深处的菜鸟 阅读(325) 评论(0) 推荐(0) 编辑
摘要:/* 水题 体现出题目看不懂 额 */#include #include #include #include using namespace std;const int maxn=55;struct card{ char A,B; card(char a=0,char b=0){ A=a;B=b; } bool operator == (const card F){ if(A==F.A||B==F.B) return true; else return false; }};struct stac{ card T[maxn]; int t; void sclea... 阅读全文
posted @ 2014-03-05 15:32 来自大山深处的菜鸟 阅读(132) 评论(0) 推荐(0) 编辑
摘要:/* 这题相对比较水 算 用5面值的 货币拼成 固定的面值的 有多少种方法*/#include #include #include using namespace std;long long dp[10000];int C[]={50,25,10,5,1};int main(){ int N; while(scanf("%d",&N)==1){ memset(dp,0,sizeof(dp)); dp[0]=1; for(int i=0;i<5;i++) for(int j=C[i];j<=N;j++) ... 阅读全文
posted @ 2014-03-05 14:21 来自大山深处的菜鸟 阅读(162) 评论(0) 推荐(0) 编辑
摘要:/* 题目的大意是 给你 N 学生 然后 给前 K个学生编号了 给定的 号码 , 然后你按照 使得接下来学生 学号尽量小的 方法 从第 K+1个学生开始编号 每个号码 自然只能用一次, 解答 : 先将编好的号码排好序,排完后 记录他们之间的 空格数,进行二分查找 有三种情况 1、学生就在 1至K中 2、学生在 K+1 到 D(K个学生中编号最大的那个数) 3、学生在D以后 1、3 都很好求, 对于第二种计算 他距离 第K个 学生都少位 ,然后再 之前算好的空格中 安排他 我为何如此的弱 想了 一天... 阅读全文
posted @ 2014-03-04 22:45 来自大山深处的菜鸟 阅读(164) 评论(0) 推荐(0) 编辑
摘要:/* 通过这题 学会了 两个词组 immediately to the left 是左邻的意思 immediately to the right 这个是右邻的意思*/#include #include#includeusing namespace std;const int maxn=50;int N[2][maxn];int DNA[10];char str[]={' ','.','x','W'};int main(){ int t; scanf("%d",&t); while(t--){ for(i 阅读全文
posted @ 2014-03-03 16:39 来自大山深处的菜鸟 阅读(159) 评论(0) 推荐(0) 编辑
摘要:/* 最长 公共子序列 记得用 gets(); 用scanf坑了一次*/#include #include #include using namespace std;const int maxn=1005;char str[2][maxn];int N[2][maxn];int main(){ while(gets(str[0])){ gets(str[1]); int n=strlen(str[0]); int m=strlen(str[1]); memset(N,0,sizeof(N)); int d=0; ... 阅读全文
posted @ 2014-03-02 15:06 来自大山深处的菜鸟 阅读(117) 评论(0) 推荐(0) 编辑
摘要:/* 这题说的的是 N 维的坐标, 每个盒子的N维坐标 可以进行 随意方式的调换 然后求出 A全部的坐标小于B的 则 A 可以嵌套在B中 然后 计算出最多的 盒子嵌套个数 简单的状态转移 我为何如此的弱*/#include #include #include #include #include #include #include using namespace std;const int maxn=35;const int maxm=15;int N[maxn][maxm];int dp[maxn];int lis,mlis,n,m,per[maxn];bool mark[maxn][... 阅读全文
posted @ 2014-03-02 14:43 来自大山深处的菜鸟 阅读(150) 评论(0) 推荐(0) 编辑
摘要:A -Macaw Baby Learns ComputerTime Limit:1000MSMemory Limit:0KB64bit IO Format:%lld & %lluSubmitStatusDescriptionProblem FMacaW Baby Learns ComputerThe newborn Macaw baby is learning computer now. But as the Macaw dad cannot afford much so he has bought a computer that supports only floating-poin 阅读全文
posted @ 2014-03-01 16:13 来自大山深处的菜鸟 阅读(234) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示