![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
bit acm 2013寒假集训期间
文章平均质量分 67
soul11201
这个作者很懒,什么都没留下…
展开
-
hdu diy contest 创业中心之鼠
创业中心之鼠Time Limit : 3000/1000ms (Java/Other) Memory Limit : 65535/32768K (Java/Other)Total Submission(s) : 52 Accepted Submission(s) : 14Font: Times New Roman | Verdana | GeorgiaFon原创 2013-02-27 10:29:14 · 585 阅读 · 0 评论 -
hdu 1787 GCD again
题意是求 比N小且满足(M,N)> 1的M的数的个数Num。根据 N = phi(N) + Num + 1,即可求得,phi(N) :N的欧拉函数。#includeint ans;void Euler(int n){ ans = 1; for(int i = 2; i * i <= n;++i){ if(!(n%i)){原创 2013-02-21 21:00:26 · 520 阅读 · 0 评论 -
hdu 1286 找新朋友
此题是赤裸裸的求欧拉函数,但是傻冒的用辗转想除法去求的,结果悲剧了,tle了。#includeint Ecluid(int N,int a){//求 N 和a的最大公约数 if(N % a == 0)return a; else{ N%=a; Ecluid(a,N); }}int main(){ int test_case,N,friend_num; sca原创 2013-02-21 17:46:58 · 2350 阅读 · 0 评论 -
hdu 1253 胜利大逃亡
先前在次处漏掉了,could_come的判断,结果一直wa。if(step > T||!could_come){}#include #include struct { int x,y,z;}Q[150000];int head,tail,step,add_step_flag;int input[52][52][52];int end_x,end_y,end_z原创 2013-02-21 10:53:29 · 432 阅读 · 0 评论 -
hdu 1240 Asteroids!
入队错误,从昨天一直调到今天。先前在这句话if((temp_x >=0 &&temp_x =0&&temp_y=0 &&temp_z是这样:if(!visited[temp_z][temp_y][temp_x]&&(temp_x >=0 &&temp_x=0&&temp_y=0 &&temp_zRE了老半天。。。#include #include原创 2013-02-21 09:31:56 · 497 阅读 · 0 评论 -
hdu 1548
都说人间自有真情在,这道题写的我都快没有爱了。 if(num[begin]&&!visited[begin]&&(begin + num[begin] >=1)&&(begin + num[begin] <= N)){ Q[tail++] = begin + num[begin]; } if(num[begin]&&!visited[begin]&&(begin - num[b原创 2013-02-20 16:53:40 · 425 阅读 · 0 评论 -
(吐槽)一点学习心得。
图论里面的东西从一开始对我来说就是一个大头疼的问题,不敢去做不敢去想,甚至有点畏惧,我刚开始的时候在想,土改怎么保存比较好呢?看了书上的给的邻接表,和邻接矩阵两种方法后感觉好麻烦,操作感觉也很不爽,所以一直以来就看到图的问题,我都是三十六计走为上策。但是当我做了一些最小生成树的问题的时候,我就开始感觉图并不是想象中的那么难,那么麻烦,并不是想象中的那样,所有的题都要用邻接矩阵或者邻接表先把输入原创 2013-02-20 11:50:07 · 827 阅读 · 0 评论 -
hdu 2544 最短路
单纯的 dijkstra就可以做。#include #include int arcs[110][110];int dist[110]; int visited[110],added;int dijk(int N){ int min = 0x7f7f7f7f; for(int i = 1;i <=N;++i){ dist[i] = 0x7f7f7f7f; } for(in原创 2013-02-20 11:05:17 · 436 阅读 · 0 评论 -
hdu 1042 N!
#include #include int main(int argc, char *argv[]){ FILE *fp; fp = freopen("in.txt","r",stdin); fp = freopen("out.txt","w",stdout); int N; int RES[50000]; int RES_top = 1,j; while(~scanf("原创 2013-02-19 10:39:07 · 457 阅读 · 0 评论 -
hdu 1233 还是畅通工程
#include #include #include typedef struct{ int a,b; int cost; int status; }Edge;Edge input[5050];int cost[5050];int parent[5050];int cmp(const void *a,const void *b){ return (((Edge原创 2013-02-19 09:43:20 · 379 阅读 · 0 评论 -
hdu 1879 继续畅通工程
#include #include #include typedef struct{ int a,b; int cost; int status; }Edge;Edge input[5050];int cost[5050];int parent[5050];int cmp(const void *a,const void *b){ return (((Edge原创 2013-02-19 09:37:58 · 412 阅读 · 0 评论 -
hdu 2824
题意大意求[a,b]内的所有数的欧拉函数的数值之和。。。。先前便求欧拉函数便求和的方法直接超时了,改用筛法打个欧拉函数表就好了,用空间换时间哇。哈哈哈。。。因为 long long sum 一直wa 改成__int64 直接过了。。。。#include #include int phi[3000010];int prime[3000010],prime_top = 0;原创 2013-02-21 22:00:20 · 523 阅读 · 0 评论 -
hdu 1722
公式:m+n -gcd(m,n);参考blog:http://blog.csdn.net/cqjianx/article/details/7831743/* 公式q+p-gcd(p,q) gcd 求两个数的最大公约数 也就是两种分法重复的部分 先把蛋糕分成q份,然后把蛋糕拼在一起,然后再分成p份。 分成q份需要切q刀,分成p份需要切p刀,但是会有重复,减去重原创 2013-02-21 21:27:51 · 531 阅读 · 0 评论 -
hdu 2191
多重背包,先前一直不过,想回去睡觉。刚修改了一下用移位运算进行二进制模拟,没想到就过了。#include #include void OneZero(int V,int cost,int value,int *dp){ for(int j = V;j>=cost;--j){ if(dp[j] < dp[j - cost] + value){ dp[j] = dp[j原创 2013-02-22 23:48:09 · 1037 阅读 · 3 评论 -
hdu 1171 bit 1014
多重背包 :01+二进制优化。一开始 MultyPack函数for循环内因为没加 j = 0,结果一直Wa,最后多谢果神帮助。 #include #include #include int V_all[350000]; //dp的结果 int V; //背包的体积 //将一个体积为cost,价值为value的物品放入背包。 void ZeroOne(in原创 2013-02-22 19:22:34 · 447 阅读 · 0 评论 -
hdu 1325 poj 1308 bit 1060
这道题,本来做过当时在hdu上过不去,今天改写了一边,bit pku hdu 都过了。根据题意可以看出这是一个有想图,且每一个节点的入度小于等于1,根据这两个性质,用parent,表示此处的入度,这样这个图就可以转化为无向图了。当入度为2的时候,is_tree = 0;此时表明此书已经不是树。因为每个节点的入度 #include #include i原创 2013-02-24 14:57:29 · 772 阅读 · 0 评论 -
(吐槽)寒假集训总结
今明两天是最后的集训期间的最后两轮总决赛,现在,我不想做了,偷个闲,谢谢这段时间的收获,其实是我不会做这些题。 我不是计软院的学生,其实我也可以不用来这参加这次的集训的,因为这次集训来的特别早,是初六晚上报道,初七开始,正月十五上午结束,也就是明天。家里人都有点抱怨了,过年的怎么那么早就回去了,再加上不是计软类的学生,很多人问我“学这有用吗?”,哎,其实我也不知以后会有什么用原创 2013-02-23 22:57:30 · 707 阅读 · 0 评论 -
hdu 1712 分组背包
#include #include int dp_res[200];void dp_group(int N,int M,int effec[][105]){ for(int i = 0;i < N;++i){ for(int j = M;j >= 1;--j){ for(int k = 1;k<=j;++k){ if(dp_res[j] < dp_res原创 2013-02-22 20:48:24 · 419 阅读 · 0 评论 -
hdu 3496
二位背包。我发现自己太帅了,在if(dp[M][L] == -1)这一行我居然能写成if(dp[M][L] != -1)还一直在琢磨为什么结果是零。#include #include int main(int argc, char *argv[]){ int test_case,N,M,L; int dvdTimeLen[110],dv原创 2013-02-22 22:47:14 · 573 阅读 · 0 评论 -
hdu 1222
原理用到的公式就是就是m,n不是互素的。下面我从中国剩余定理的角度说一下原因。假设m,n是互素的,则一定存在一个x 满足 m x mod n 分别余 k = 1,2,3,4,、、、n-1,即 mx mod n = k 有解。其中x为狼转的圈数,k为洞的编号。说明如果m,n互素,只要这只狼足够耐心,所有的洞都会让它找一遍。。。其实更一般的来说这是一个一元模线性方程。mx mod n = k 如果k原创 2013-02-21 21:39:05 · 922 阅读 · 0 评论 -
hdu 2669
扩展的欧几里德。直接上模板。AC!#include void ext_eclud(int a,int b,int *gcd,int *x,int *y){ if(b==0){ *gcd = a; *x = 1; *y = 0; return ; } ext_eclud(b,a%b,gcd,x,y); int temp = *y; (*y) = (*x)-(a原创 2013-02-22 11:11:32 · 1042 阅读 · 0 评论 -
hdu 2602 bit 1013
01背包,具体不说,背包九讲写的真好。因为V_all这个数组一不小心在mian函数里面也定义了一个,结果导致本地测试时结果一直为零。#include #include int V_all[1100];void oneZero(int N,int V,int *V_each,int *value_each){ for(int i = 0;i<N;++i){ for(int j原创 2013-02-22 16:50:22 · 413 阅读 · 0 评论 -
数论学习笔记
这两天一直再看数论方面的东西,心里也想了很多的东西,凑着现在有时间,写写也整理一下思路,学习数论的第一感觉就是东西多,乱杂,性质定理公式太别多。但是思路理清楚,就好了。在这里推荐和我一样数论刚入门的人,看陈景润写的初等数论一书,我感觉写的真不错,看完后,思路感觉非常的清晰。当然东西也特别多,东西真是一次无法看完呀,但是我感觉有很多的东西非常的有意思,比如说的数论的性质引理定理什么的第一章一次就给出原创 2013-02-22 12:06:28 · 1003 阅读 · 0 评论 -
hdu 1863 畅通工程
#include #include #include typedef struct{ int a,b; int cost; int status; }Edge;Edge input[5050];int cost[5050];int parent[5050];int cmp(const void *a,const void *b){ return (((Edge原创 2013-02-19 09:41:05 · 421 阅读 · 0 评论 -
hdu 1316 poj 2413 how many Fibs
先前是怎么都过不了,后来打了一张斐波那契表就过了,。#include #include char res[150],res_1[150],res_2[150];char all_res[600][130];int all_res_len[600];int res_top = 0,res_fir_top,res_sec_top;int a_len,b_len;int原创 2013-02-17 20:38:01 · 773 阅读 · 0 评论 -
bit 1012 poj 1887 hdu 1275
导弹防御问题时间限制: 1秒 内存限制: 64MProblem Description一种新型的防卫导弹可截击多个攻击导弹 . 它可以向前飞行 , 也可以用很快的速度向下飞行 , 可以毫无损伤地截击进攻导弹 , 但不可以向后或向上飞行 . 但有一个缺点 , 尽管它发射时可以达到任意高度 , 但它只能截击比它上次截击导弹时所处高度低或者高度相同的导弹 . 现对这种新型防卫导弹进原创 2013-02-11 21:18:46 · 1271 阅读 · 6 评论 -
Is It A Tree?
Is It A Tree?时间限制: 1秒 内存限制: 10240KBDescriptionA tree is a well-known data structure that is either empty (null, void, nothing) or is a set of one or more nodes connected by directed edges b原创 2013-02-10 14:53:48 · 612 阅读 · 0 评论 -
bit 1031 Binary Tree Traversals
Binary Tree Traversals时间限制: 1秒 内存限制: 64MProblemDescriptionA binary tree is a finite set of vertices that is eitherempty or consists of a root r and two disjoint binary trees called the left原创 2013-02-07 19:53:00 · 428 阅读 · 0 评论 -
bit 1038 Red and Black
Red and Black时间限制: 1秒 内存限制: 64MDescriptionThere is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, h原创 2013-02-06 21:30:41 · 410 阅读 · 0 评论 -
bit 1046 Leftmost Digit
Leftmost Digit时间限制: 1秒 内存限制: 1024KBDescriptionGiven a positive integer n, please write a program to get the leftmost digit of n!. (1 InputThe input contains several test cases, the firs原创 2013-02-06 19:18:43 · 628 阅读 · 0 评论 -
bit 穿越沙漠
参考:无上阳光13的博客 穿越沙漠 acm.bit.edu.cn 1005 智力题穿越沙漠时间限制: 1秒 内存限制: 64MProblem Description一辆吉普车来到 x 公里宽的沙漠边沿 A 点,吉普车的耗油量为 1 升 / 公里,总装油量为 500 升。通常,吉普车必须用自身油箱中的油在沙漠中设置若干个临时储油 点,才能穿越沙漠的。假设在沙原创 2013-02-02 17:54:15 · 730 阅读 · 0 评论 -
bit Who is the Smartest Man
参考:态度决定高度的blog zoj 3519 Who is the Smartest Man 无上阳光13的博客 Who is the Smartest ManWho is the Smartest Man时间限制: 1秒 内存限制: 64MProblem DescriptionCao Cao is very pround原创 2013-02-02 11:59:29 · 706 阅读 · 0 评论 -
bit Number Converter
Number Converter时间限制: 1秒 内存限制: 64MProblem DescriptionAs we know 3 = 11 if we think about the binary representation . Now let’s make a number converter. Given you two integers n (0 <= n <=10原创 2013-02-02 10:59:20 · 529 阅读 · 0 评论 -
bit 1003 Exchange for Cola
Exchange for Cola时间限制: 1秒 内存限制: 64MProblem DescriptionThe Cola company is holding a promotional activity that customerscan exchange B bottles of Cola with A caps. Now Silence has N caps. Fu原创 2013-02-02 21:02:32 · 607 阅读 · 0 评论 -
bit Roman numerals
Roman numerals时间限制: 1秒 内存限制: 64MProblem DescriptionNow let’s think about roman numerals!-The Roman numerals for 1 through 10 are I, II, III, IV, V, VI, VII, VIII, IX, and X.原创 2013-02-02 20:59:07 · 650 阅读 · 2 评论 -
bit 1049 Relatives
Relatives时间限制: 1秒 内存限制: 64MProblemDescriptionGiven n, a positive integer, how many positive integers less than or equal to n are relatively prime to n ? Two integers a and b are relativ原创 2013-02-14 23:41:21 · 638 阅读 · 0 评论 -
bit 1015 Edit Distance
Edit Distance时间限制: 1秒 内存限制: 64MProblem DescriptionGiven a string, an edit script is a set of instructions to turn itinto another string. There arethree kinds of operations in an edit scri原创 2013-02-15 21:53:07 · 494 阅读 · 0 评论 -
poj 2421 hdu 1102 Constructing Roads
因为用的前几次的代码input 和parent开的太小了,一直wa。#include #include #include typedef struct{ int a,b; int len; int status;}Edge;Edge input[6000];/******************************************************原创 2013-02-19 08:53:47 · 449 阅读 · 0 评论 -
hdu 1232 畅通工程
#include #include int pararent[1150];int root(int n){ if(pararent[n] == 0)return n; else return pararent[n] = root(pararent[n]);}int main(int argc, char *argv[]){ //FILE *fp; //fp = freop原创 2013-02-18 17:16:30 · 456 阅读 · 0 评论 -
hdu 1162 Eddy's picture
#include #include #include #include /**************************************************************************/typedef struct{ double x,y;}Point;typedef struct{ int a,b; double原创 2013-02-19 08:58:52 · 354 阅读 · 0 评论