cjweffort

博客园 首页 联系 订阅 管理

2013年3月10日

摘要: 1018. Public Bike Management (30)时间限制400 ms内存限制32000 kB代码长度限制16000 B判题程序Standard作者CHEN, YueThere is a public bike service in Hangzhou City which provides great convenience to the tourists from all over the world. One may rent a bike at any station and return it to any other stations in the city.The 阅读全文
posted @ 2013-03-10 17:47 cjweffort 阅读(167) 评论(0) 推荐(0) 编辑

摘要: 题意要求最大子序列和,一道很经典的题目,可以用贪心算法解之~~// 1007. Maximum Subsequence Sum.cpp: 主项目文件。 #include "stdafx.h" #include int main() { int n; while(~scanf("%d",&n)){ int leftTemp,left,right,curSum=0,maxSum=-1; int first,end; bool tag=false; for(int i=0;i=0) tag=true; if(curSummaxSum){ maxS... 阅读全文
posted @ 2013-03-10 08:48 cjweffort 阅读(149) 评论(0) 推荐(0) 编辑

摘要: http://ac.jobdu.com/problem.php?cid=1040&pid=65题目描述: 某省调查城镇交通状况,得到现有城镇道路统计表,表中列出了每条道路直接连通的城镇。省政府“畅通工程”的目标是使全省任何两个城镇间都可以实现交通(但不一定有直接的道路相连,只要互相间接通过道路可达即可)。问最少还需要建设多少条道路?输入: 测试输入包含若干测试用例。每个测试用例的第1行给出两个正整数,分别是城镇数目N ( #include #include #include #include #include #include #include #include #inclu... 阅读全文
posted @ 2013-03-10 00:26 cjweffort 阅读(170) 评论(0) 推荐(0) 编辑

摘要: http://ac.jobdu.com/problem.php?cid=1040&pid=64题目描述: 对于一个十进制数A,将A转换为二进制数,然后按位逆序排列,再转换为十进制数B,我们乘B为A的二进制逆序数。 例如对于十进制数173,它的二进制形式为10101101,逆序排列得到10110101,其十进制数为181,181即为173的二进制逆序数。输入: 一个1000位(即10^999)以内的十进制数。输出: 输入的十进制数的二进制逆序数。样例输入:173样例输出:181// 题目65:10进制 VS 2进制.cpp: 主项目文件。 #include "stdafx.h& 阅读全文
posted @ 2013-03-10 00:25 cjweffort 阅读(484) 评论(0) 推荐(0) 编辑

摘要: http://ac.jobdu.com/problem.php?cid=1040&pid=63题目描述:对N个长度最长可达到1000的数进行排序。输入:输入第一行为一个整数N,(1 #include #include using namespace std; const int N=101; typedef struct Node { char str[1003]; int len; }Node; Node node[N]; bool cmp(Node m1,Node m2) { if(m1.len!=m2.len) return m1.len<m2.len; else ... 阅读全文
posted @ 2013-03-10 00:24 cjweffort 阅读(170) 评论(0) 推荐(0) 编辑

摘要: http://ac.jobdu.com/problem.php?cid=1040&pid=62题目描述:求2个浮点数相加的和题目中输入输出中出现浮点数都有如下的形式:P1P2...Pi.Q1Q2...Qj对于整数部分,P1P2...Pi是一个非负整数对于小数部分,Qj不等于0输入:对于每组案例,第1行是测试数据的组数n,每组测试数据占2行,分别是两个加数。每组测试数据之间有一个空行,每行数据不超过100个字符输出:每组案例是n行,每组测试数据有一行输出是相应的和。输出保证一定是一个小数部分不为0的浮点数样例输入:2 0.111111111111111111111111111111 0. 阅读全文
posted @ 2013-03-10 00:23 cjweffort 阅读(324) 评论(0) 推荐(0) 编辑

摘要: http://ac.jobdu.com/problem.php?cid=1040&pid=61题目描述:将M进制的数X转换为N进制的数输出。输入:输入的第一行包括两个整数:M和N(2 #include const int N=4003; char str[N];//输入字符串 int start[N],ans[N],res[N]; //被除数,商,余数 //转换前后的进制 int oldBase; int newBase; void change() {//各个数位还原为数字形式 int i,len = strlen(str); start[0] = len; for(i=1;i... 阅读全文
posted @ 2013-03-10 00:11 cjweffort 阅读(198) 评论(0) 推荐(0) 编辑

摘要: 题目要求出树每层的叶子节点。经典的数据结构题目,利用bfs可以逐步求出。// 1004. Counting Leaves.cpp: 主项目文件。 #include "stdafx.h" #include #include #include #include using namespace std; const int N=103; typedef struct Node{ int data,level; }Node; vector edge[N]; bool used[N]; queue Q; void bfs(){ int tLevel=1,tSum=0; while(! 阅读全文
posted @ 2013-03-10 00:06 cjweffort 阅读(144) 评论(0) 推荐(0) 编辑