1周记
文章平均质量分 87
Hzy_hzy_hzy
世间万物生生衍息······ 你找到生命的存在了吗?
展开
-
大数运算
//大数加法 hdu 1002(可练习hdu 1715,1753,2100) #include #include #include using namespace std; const int N=1500; int a[N],b[N]; char a1[N],b1[N]; int main() { int t,cas=1; cin>>t; while(t--){原创 2016-11-13 15:47:33 · 307 阅读 · 0 评论 -
二分
#include //hdu1969 using namespace std; const int N=10000+10; const double pi=acos(-1); const double precision=1e-6; int n,f,a[N]; double s[N]; bool ok(double si) { int num=0; for(int i=0;i<n;原创 2016-11-27 15:42:21 · 212 阅读 · 0 评论 -
遍历二叉树
#include //uva122 using namespace std; const int N=110; const int Maxn=1000000; struct Node { bool have_value; int v; Node *left,*right; Node():have_value(false),left(NULL),right(NULL)原创 2016-11-27 14:04:44 · 176 阅读 · 0 评论 -
队列
#include//uva540 using namespace std; const int maxt=1000+10; int main() { int t,kase=0; while(scanf("%d",&t)==1&&t) { printf("Scenario #%d\n",++kase); map team; fo原创 2016-11-27 14:01:39 · 238 阅读 · 0 评论 -
水了,,
#include//找能判断的情况,猜出差值规律 #include #include #include using namespace std; typedef long long ll; const int N=10000; int a[N],b[N]; int main(){ int t; scanf("%d",&t); while(t--) {原创 2016-11-20 21:38:56 · 269 阅读 · 0 评论 -
水了,,递推 hdu 2563
/*推错,,自行理解答案;题目要求是每步走后,上一步的位置便塌陷,所以,这一步是向上走来的那有三个方向可走, 而如果是向左或向右走来的,那就只有两个方向可走,设f(n)为走n步后存在的可能走法,不管上一步是怎么走来的,f(n)>2*a[n-1]; 想等于的话,那就找n-1步是由向上走来的走法数目,其实就是f[n-2];因为n-1步由向上走法来的数目有f[n-2];f[n]=f[n-1]+f[n原创 2016-11-20 10:13:34 · 245 阅读 · 0 评论 -
递归回溯
#include //nyoj_488 using namespace std; const int N=30; int a[N],n,flag=1; int vis[N],isp[N]; void init() { memset(isp,0,sizeof(isp)); for(int i=2;i<N;i++) { if(!isp[i])for(int j=原创 2016-11-27 14:42:19 · 264 阅读 · 0 评论 -
Pocket Cube hdu 5983
/*数字是6个,直接模拟,采取的是按题目的展开面位置来判断是否合法,枚举三种转法,变换数组的值,每两个面造的空间对应一种,没有用滚动数组,强行覆盖*_*!*/ #include #include #include using namespace std; int a[10][10],b[10][10]; int xx() { set pq; for(int i=0;i<=7;原创 2016-11-20 09:42:29 · 713 阅读 · 0 评论 -
水了,,
KI的斐波那契 Description KI十分喜欢美丽而优雅的斐波那契数列,最近他新认识了一种斐波那契字符串,定义如下 f (0) = b, f (1) = a, f (2) = f (1) + f (0) = ab, f (3) = f (2) + f (1) = aba, f (4) = f (3) + f (2) = abaab, ...... KI想知道 f (n原创 2016-11-20 21:41:43 · 437 阅读 · 0 评论 -
水了,,递推 hdu 2502
/*推出来了,,额,*/ #include #include #include #include using namespace std; const int N=21; int a[N],b[N],ans[N]; void init() { int s=4; a[1]=1,a[2]=3;a[3]=8; ans[3]=12; for(int i=4;i<N原创 2016-11-20 09:48:04 · 242 阅读 · 0 评论 -
hpu_oj 1192: Sequence
#include //有些暴力,没想到10个数也有这么大的复杂度,要过3s #include using namespace std; typedef long long ll; int a[11],book[11],s; ll result,c[60][60]; long long f(long long n,long long m) { long long ans=1; f原创 2016-12-01 23:52:03 · 309 阅读 · 0 评论 -
水,,
#include// hpuoj_judge #include typedef long long ll; int x,m; ll mul(ll a,ll b) { return ((a%m)*(b%m))%m; } ll cal(ll n,ll origin) { ll ans=1; while(n) { if(n&1) ans=mul原创 2016-11-27 21:12:15 · 337 阅读 · 0 评论 -
hdu_5099 理解题意要求即可
#include #include using namespace std; typedef long long ll; char str1[7],str2[7]; void f(int a,int b) { if(a<b) printf("<"); else if(a>b) printf(">"); else printf("="); } void g(char a,ch原创 2016-12-18 22:04:15 · 507 阅读 · 0 评论 -
hduoj_5090 桶标记的运用
#include #include using namespace std; typedef long long ll; int a[110],book[110]; int main() { int t; scanf("%d",&t); while(t--) { memset(book,0,sizeof(book)); int n,k,flag=原创 2016-12-18 21:52:17 · 340 阅读 · 0 评论 -
最大流
//最大流 hdu 3549 /*模板-不断找到从源点到汇点的路线,找到一次,就更新一次存边用的二维数组的值,并且对应有个流值,取和即为最大流(反向边不懂...)*/ #include #include #include #include #include using namespace std; typedef long long ll; const int N=1105; int a[N]原创 2016-11-13 17:25:39 · 242 阅读 · 0 评论 -
哈弗曼编码
//老师很细致的讲了这个编码,,直接摘自课本的代码,很不赖,, #include #include #include #include #include #include using namespace std; const int N=30; typedef struct{ int weight; int parent,lchild,rchild; }HTNode,*HuffmanTree;原创 2016-11-13 18:12:57 · 567 阅读 · 0 评论 -
二分图的最大匹配
//dfs版本 hdu 1207 /*增广路径就交替路,非匹配边加匹配边,奇数次,能使匹配点加1,同时取反即改变匹配对象*/ #include #include #include #include #include #include using namespace std; const int N=105; int n,m; int a[N][N]; int vis[N]; int cors原创 2016-11-13 19:35:02 · 237 阅读 · 0 评论 -
分治
#include //nyist 90 int solve(int n,int m) { if(n==1||m==1) return 1; else if(n==m) return solve(n,m-1)+1; else if(n>m) return solve(n-m,m)+solve(n,m-1); else return solve(n,n); } int main(){原创 2016-11-13 23:46:26 · 234 阅读 · 0 评论 -
hpu_oj 1191。
#include//hpu_oj 1191 #include typedef long long ll; const int maxn=1e7; int a,b,c,d,s; int cost[3]={45,90,180}; int fe[3]; void dfs(int ans,int yy,int ci,int ti) { if(ans<=0){ //忘加 if(ans==原创 2016-12-04 21:11:46 · 306 阅读 · 0 评论 -
01背包。
#include//hdu_oj 1171(01背包) using namespace std; typedef long long ll; const int N=5000+50; int cost[N],f[N*50]; int main() { int n; while(scanf("%d",&n)&&n>0) { memset(f,0,sizeof(原创 2016-12-04 21:13:23 · 228 阅读 · 0 评论 -
对自己无语的_数据结构-二叉树
#include using namespace std; typedef char ElemType; typedef struct BiTNode { ElemType data; struct BiTNode *lchild,*rchild; }BiTNode,*BiTree; void InOrderTraverse(BiTree T) { if(!T) retu原创 2016-12-04 21:20:00 · 389 阅读 · 0 评论 -
Regionals 2015 >> Asia - EC Final>> Multiplication Table
/*由两个点的值及相对位置求解左上角点的坐标,解的判断很麻烦,wr*/ #include #include #include using namespace std; typedef long long ll; const ll M=1e9,N=1e3+10; struct point { int x,y,v; }pq[N*N]; int n,m,k; int jud(ll x,ll y原创 2016-12-15 20:51:47 · 419 阅读 · 0 评论 -
模拟-Team
#include//wr #include const int N=50000; int a[N+100],c[N+100][2],book[N+100]; int main() { int t; scanf("%d",&t); while(t--) { memset(a,0,sizeof(a)); memset(book,0,siz原创 2016-12-16 20:21:18 · 287 阅读 · 0 评论 -
区间全覆盖-喷水装置(2)
#include #include using namespace std; const int N=10000; int w,h; struct f{ double l,r; }a[N+100]; bool cmp(f p,f q) { return p.l<q.l; if(p.l==q.l) return p.r>q.r; } int g(int k) { if(a[原创 2016-12-17 17:48:06 · 301 阅读 · 0 评论 -
2016.12.4_参考答案...
Run time: 预处理数据,a[i]代表听完前i首歌跑的总步数,听了 l-r 歌后跑的步数是:a[r]-a[l-1]。这样就不超时了,复杂度降到O(1); #include #include using namespace std; typedef long long ll; const int N=10000+100; ll a[N]; int main() { int t原创 2016-12-04 14:02:20 · 1371 阅读 · 0 评论