afterward

导航

 

2012年8月7日

摘要: 不懂树状数组时什么意思,找了个简单的树状数组做!View Code #include <iostream>using namespace std;#define N 32001int sum[N+1];//算这个^k有一个快捷的办法,定义一个函数如下即可//利用机器补码的特点,这个函数可以改得更方便int lowbit(int k){ return k&(-k);}//如果要把a[i]增加v,可以通过调用如下函数实现void add(int i,int v){ while(i<=N) { sum[i]+=v; cout<<"i:"< 阅读全文
posted @ 2012-08-07 11:04 afterward 阅读(451) 评论(0) 推荐(0) 编辑
 

2012年8月6日

摘要: 找出重复的起始点和重复周期,起始点不一定找第一个,可以使第一个周期中的任意一个。View Code #include<iostream>#include<stdio.h>using namespace std;int f[100000005];int main(){ int a,b,n,i,j; f[1]=1;f[2]=1; while(scanf("%d%d%d",&a,&b,&n)) { int s=0;//记录周期 if(a==0&&b==0&&n==0) break; for(i=3;i 阅读全文
posted @ 2012-08-06 17:09 afterward 阅读(132) 评论(0) 推荐(0) 编辑
 
摘要: “对于所有的 x|a, 有 x|A”。能够在进制 A 下用有限数位表示的任何一个有理数.其最简分母 (a) 和进制数 (A) 肯定能满足上面的“充要条件”。也就是说,这些有理数的最简分母,都可以表示成 A 的若干个因子相乘的形式(相同因子可乘多次)。那么如果要保证这些有理数在进制 B 下也能顺利用有限数位表示的话,B 这个数的因子必须至少要包含 A 中的因子。看到这题目谁想的到啊!View Code #include <stdio.h>#include <string.h>int main(){ __int64 a,b,ans,i,t,cas; scanf(" 阅读全文
posted @ 2012-08-06 14:58 afterward 阅读(202) 评论(0) 推荐(0) 编辑
 

2012年8月5日

摘要: View Code #include <iostream>#include <cstdio>#include <cmath>#include <cstring>#define maxn 155using namespace std;int map[maxn][maxn],res[maxn];bool vt[maxn];int n,m;bool flag;void dfs(int pos,int num){ int i; if (flag) return ; res[num] = pos; for (i = 1;i <= n;++i) { i 阅读全文
posted @ 2012-08-05 17:48 afterward 阅读(358) 评论(0) 推荐(0) 编辑
 
摘要: View Code #include<stdio.h>#include<stdlib.h>#include<string.h>#include<iostream>using namespace std;#define MAX_LEN 101#define is_valid(x, y) ((x)>=0 && (x)<N && (y)>=0 && (y)<M)int N, M;char image[MAX_LEN][MAX_LEN];int visited[MAX_LEN][MA 阅读全文
posted @ 2012-08-05 10:37 afterward 阅读(330) 评论(0) 推荐(0) 编辑
 

2012年8月4日

摘要: 关于拓扑排序特意找了个简单的做,呵呵。。。View Code #include <stdio.h>#include <string.h>#include <iostream>using namespace std;int a[551][501],ru[551];int main(){ int n,m,i,q1,q2,z,j,k; while(scanf("%d%d",&n,&m)!=EOF) { z=0; memset(a,0,sizeof(a)); memset(ru,0,sizeof(ru)); for(i=1; i. 阅读全文
posted @ 2012-08-04 19:38 afterward 阅读(165) 评论(0) 推荐(0) 编辑
 
摘要: View Code /*5001001000001001111011100050111100000010000110001110*/#include<iostream>#include<cstdio>using namespace std;#define N 2010int indegree[N],a[N][N];char b[N];int main(){// freopen("in.txt","r",stdin); int n,t,x,p=1; scanf("%d",&t); while(t--){ 阅读全文
posted @ 2012-08-04 15:54 afterward 阅读(154) 评论(0) 推荐(0) 编辑
 

2012年8月3日

摘要: View Code #include<iostream>#include<iomanip>#include<cstdio>#include<queue>using namespace std;struct node{ int dest; double value; node* next; node() { next=NULL; }}edge[50010];//构造点int n,s,t;double power;double len[50010];node temp[2500010];queue<int> ans;void bfs(){ 阅读全文
posted @ 2012-08-03 19:02 afterward 阅读(265) 评论(0) 推荐(0) 编辑
 
摘要: 一点都不知道这个公式怎么来的?求解释!!!代码是别人的。答案挺对的。求解公式来的过程,翻译题目就不用。泪!这个题放在高中可能还知道,全忘干净了。View Code #include <cstdio>#include <iostream>using namespace std;const int maxn = 22;double p[maxn];int main() { int n,i,j; while (~scanf("%d",&n)) { for (i = 0; i < n; ++i) scanf("%lf",&a 阅读全文
posted @ 2012-08-03 17:17 afterward 阅读(206) 评论(0) 推荐(0) 编辑
 
摘要: View Code /* pku 3414 Pots BFS+记录路径2011-04-15 18:00题目意思.1. 给出两个容积分别为 A 、B 的空瓶子,求经过下列操作是否能得到某个瓶子 装 体积为 C 的水。2. 1> 把某个瓶子装满,2> 把某个瓶子的水倒光,3> 把某个瓶子的水倒入另一个。思路: 由于 某个状态最多可以推出 六个状态。 1> 当 A 瓶未满时,把 A 瓶装满 2> 当 B 瓶未满时,把 B 瓶装满 3> 当 A 瓶非空时,把 A 瓶倒光 4> 当 B 瓶非空时,把 B 瓶倒光 ... 阅读全文
posted @ 2012-08-03 10:39 afterward 阅读(159) 评论(0) 推荐(0) 编辑