自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

爆米

业精于勤而荒于嬉 行成于思而毁于随

  • 博客(149)
  • 资源 (2)
  • 收藏
  • 关注

原创 本博客停止更新,请访问新博客

本博客停止更新,请访问新博客如果优快云上有啥动态,可能还会回来的网站域名:www.zzkun.com欢迎访问~~~

2015-04-27 22:33:55 862

原创 UVa 10285 Longest Run on a Snowboard [DP]

题意:给定一个整数矩阵,找到一条严格递减的最长路。简单的动规题目,dp[i][j]表示走到(i, j)所走过的最长步数,向四个方向转移状态即可。#include using namespace std;const int maxn = 105;string str; int r, c;int a[maxn][maxn], dp[maxn][maxn];const int dir

2015-04-16 16:25:48 602

原创 UVa 1218 Perfect Service [DFS+DP]

题意:给定一个树形的机器结构,安装服务器,每台服务器恰好跟一台服务器相邻,问最少装几台服务器。首先DFS把树建立起来,然后动规求解,注意设置无穷大inf后累加要防止超int范围。#define _CRT_SECURE_NO_WARNINGS#include #include #include #include #include #include #include using

2015-04-14 11:11:34 592

原创 第三届ACM山东省赛 Pick apples [贪心+动规]

超大背包问题,刚开始想复杂了。分段填充背包,前面一大部分用性价比最高的填充,最后一部分动规就可以了。题目链接:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2408Pick applesTime Limit: 1000ms   Memory limit: 165536K  有

2015-04-12 21:42:25 794

原创 ZOJ 3326 - An Awful Problem

题意:给定一个日期范围,判断月和日均为素数的天数。比较水的题目,for循环中的?:判断语句、日期的打表,可以大幅精简代码。#include #include using namespace std;int day1[15] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; //闰年int day2[15] = {0,

2015-04-10 16:56:07 513

原创 HDU 1029 - Ignatius and the Princess IV

题意:给定N个数,选出其中数量大于(N+1)/2的数两种方法实现,第一种方法排序,选择中间的那个数。第二种方法搜一遍。#include #include #include #include #include using namespace std;int a[1024000];int main(){ int n; while(cin >> n){

2015-04-10 15:10:42 438

原创 POJ 2437 - Muddy roads [贪心法]

题意:给定n个泥坑路面的初末位置,判断最少需要几个桥才能覆盖这些路面。贪心法,从每个泥坑的开始位置建桥,然后判断是否覆盖后面的路面,就是分类讨论了。#include #include #include #include #include #include using namespace std;struct Seg{ int l, r; Seg(int l = 0, i

2015-04-08 23:11:45 592

原创 UVa 11584 - Partitioning by Palindromes [动规]

题意:给定一个字符串,判断能划分成尽量少的回文串的数量。dp[i]代表的状态为字符串前i个字符所能划分成的最少回文串的数量。判断回文串可以用递归来判断。#include #include #include #include using namespace std;char str[1024];int dp[1024];const int inf = 0x7f7f7f7f;

2015-04-07 22:17:26 434

原创 POJ 2385 - Apple Catching [DP]

比赛时不会动规,现在拿出来再做一遍。dp[i][j]表示在i时刻使用j次转移得到的最多苹果数#include #include #include using namespace std;int a[1024], dp[1024][35];int main(){ int n, w; cin >> n >> w; for(int i = 1; i <

2015-04-06 21:02:58 449

原创 HDU 1159 - Common Subsequence [最长公共子序列]

动规简单题,dp[i][j]表示的状态为字符串a.substr(0, i)和b.substr(0, j)的最长公共子序列。#include #include #include #include using namespace std;int dp[1024][1024];int main() { string a, b; while(cin >> a >> b)

2015-04-06 19:05:01 433

原创 UVa 12563 - Jin Ge Jin Qu hao [DP]

题意:给定几首歌的长度,在规定时间内,选择尽量多的曲目,在此前提下选择时间尽量长的歌。动态规划基础题,刚开始把条件看反了。dp[j]代表在j时间能够唱的最多曲目。#include using namespace std;int dp[10240], ti[10240];int main(){ int T, kase = 0; cin >> T; while(T-

2015-04-06 18:55:20 689

原创 UVa 1025 - A Spy in the Metro [DP]

动态规划基础例题,要理解状态和状态转移方程。。。#include using namespace std;int kase = 0;int n, T, t[80];int M1, M2, st1[64], st2[64];bool has_train[512][64][2];int dp[512][80];const int INF = 1<<8;int main() {

2015-03-31 17:58:52 448

原创 UVa 1611 - Crane [构造法]

这道题有点像翻煎饼那题,方法不限,只要次数在9^6之内即可。从前到后依此选择数,最多只需要两次就可以将每个数放到正确位置。#include using namespace std;int a[10240];void change(const int l, const int r){ for(int i = l, j = l+(r+1-l)/2; j <= r; ++i,

2015-03-25 14:32:00 613

原创 UVa 11925 - Generating Permutations

这题用了冒泡排序的思想,不过紫书上的描述有误,建议参考原题。#include using namespace std;deque a;vector res;bool is_order(){ for (int i = 1; i != a.size(); ++i) if (a[i] < a[i-1]) return false; return true;}int ma

2015-03-19 17:26:54 874

原创 HDU 1016 - Prime Ring Problem [简单DFS]

不想说这题有多么水了,最简单的DFS题了,但是!我花了N天在杭电用G++交了20多遍一直超时,最后改C++交过了!!这是什么情况!!无语了!!#define _CRT_SECURE_NO_WARNINGS#include #include #include const int maxn = 1024;bool checked[maxn] = { 1, 1 };int pri[

2015-03-17 23:16:52 405

原创 UVa 12627 - Erratic Expansion

这题关键就是递推公式,注意紫书上推的c(k)那里貌似有点问题,应该是c(k-1)。另外2^k方的计算可以用1#include using namespace std;using LL = long long;LL C[32] = {1};LL g(LL k, LL i){ if(i (1LL<<k)) return 0; if(k <= 0) return 1;

2015-03-15 15:52:07 616

原创 UVa 11636 - Hello World!

最水的题,挺简单,用数学做的,刚开始判断负数写成了-1失误超时了.#include using namespace std;int main(){ int n, kase = 0; while(cin >> n, n > 0) printf("Case %d: %d\n", ++kase, (int)ceil(log2(n))); return

2015-03-14 15:16:16 444

原创 UVa 11093 - Just Finish it up

循环遍历数组即可,注意临界条件的判断。#include using namespace std;const int maxn = 102400;int p[maxn], q[maxn];int main(){ //freopen("in.txt", "r", stdin); int T; cin >> T; for(int t = 1; t <= T; +

2015-03-13 17:25:57 531

原创 UVa 1149 - Bin Packing [贪心]

这题算贪心中最简单的,属于背包问题吧,写的效率有点低,用数组加指针控制应该更好。#include #include #include #include #include using namespace std;int main(){ int T; cin >> T; while(T--){ deque a; int n, k; c

2015-03-13 17:23:06 483

原创 POJ 1328 - Radar Installation [贪心]

DescriptionAssume the coasting is an infinite straight line. Land is in one side of coasting, sea in the other. Each small island is a point locating in the sea side. And any radar installation,

2015-03-08 18:06:22 433

原创 HDU 2553 - N皇后问题 [回溯法]

Problem Description在N*N的方格棋盘放置了N个皇后,使得它们不相互攻击(即任意2个皇后不允许处在同一排,同一列,也不允许处在与棋盘边框成45角的斜线上。你的任务是,对于给定的N,求出有多少种合法的放置方法。#include #include #include using namespace std;int N, cnt, vis[3][32], res[12]

2015-03-06 11:41:43 632

原创 UVa 11582 - Colossal Fibonacci Numbers!

数学题,寻找斐波那契取模后的周期T,然后求Mod_Fib(a^b % T)即可。求a^b % T时要用快速幂来计算,详细方法为http://blog.youkuaiyun.com/kun768/article/details/42344897#include #include using LLU = unsigned long long;using namespace std;int Fib

2015-03-04 16:20:22 507

原创 分治法:循环赛日程表问题

循环赛日程表问题问题描述:   设有n(n = 2^k)位选手参加网球循环赛,循环赛共进行n-1天,每位选手要与其他n-1位选手比赛一场,且每位选手每天必须比赛一场,不能轮空。试按此要求为比赛安排日程: (1) 每个选手必须与其他n-1个选手各赛一场; (2) 每个选手一天只能赛一场; (3) 循环赛一共进行n-1天。思路和代码比较简单,就不多解释了^_^#include

2015-03-04 11:24:22 1003

原创 UVa 557 - Burger

题目大意:有n个牛肉汉堡和n个鸡肉汉堡给2n个孩子吃。每个孩子在吃之前都要抛硬币,正面吃牛肉汉堡,反面吃鸡肉汉堡。如果剩下的所有汉堡都一样,则不用抛硬币。求最后两个孩子吃到相同汉堡的概率。正面不好思考,考虑最后两个孩子吃不同汉堡的概率。则根据概率相关知识,P(n) = (1 / 2) ^ (2n - 2) * C(n - 1, 2n - 2),由P(n)和P(n+1)的关系得到:P(n+1)

2015-03-04 10:05:59 443

原创 UVa 11346 - Probability

纯粹数学题,推公式吧。注意边界处理精度控制就可以了。#include #include #define EPS 1e-7int main(){ int T; scanf("%d", &T); while (T--){ double a, b, S; scanf("%lf %lf %lf", &a, &b, &S); if (S - a *b >= EPS) puts("0.

2015-03-03 23:26:02 640

原创 UVa 1641 - ASCII Area

比较水的一题,找到方法就好说了。#include using namespace std;char tab[128][128];int main(){ int h, w; while (cin >> h >> w){ cin.get(); for (int i = 0; i < h; ++i ) cin >> tab[i]; int cnt = 0; for

2015-03-03 22:51:49 502

原创 UVa 10539 - Almost Prime Numbers

通过这题学习了线性筛法素数打表的方法,题目本身更像数学思考题。#include #include #include #include #include using namespace std;using LL = long long int;const int maxn = 1024000;bool check[maxn];LL pri[maxn], tot;void

2015-03-03 21:59:22 412

原创 UVa 294 - Divisors

基础题,就用基本方法即可,计算约数时算到sqrt(n)即可,要注意(int)sqrt(n)和n的关系。#include #include #include using namespace std;int main(){ int T; cin >> T; while (T--){ int L, U; cin >> L >> U; int MAX = -1, num;

2015-03-03 16:06:38 703

原创 UVa 1645 - Count

用打表的方法来做,蕴含着一种递推的思想。#include #include using namespace std;int n, res[1024];const int MOD = 1e9 + 7;void init() { res[1] = res[2] = 1; for (int i = 3; i <= 1000; ++i) for (int j = 1; j < i

2015-03-03 15:13:30 551

原创 UVa 11040 - Add bricks in the wall

纯粹找规律的一小学数学题,空格处的数可有输入计算得出,每个6格三角形为一个计算单位。#include #include using namespace std;int tab[10][10];int main(){ int T; cin >> T; while (T--){ for (int i = 0; i <= 8; i += 2) for (int j = 0; j

2015-03-03 13:25:32 502

原创 UVa 1210 - Sum of Consecutive Prime Numbers

高中数学数列方法做的,打表大法好,全程打表。计算一段数的和,用S(n~m) = S(m) - S(n-1)做的。#include using namespace std;const int maxn = 10001;bool isp[maxn];int cnt, p[2000], sum[2000], res[100000];void init(){ memset(

2015-03-02 16:40:57 478

原创 UVa 246 - 10-20-30 [STL应用]

这道题在数据结构这一章里算是简单的,但是很容易WA和RE,可能得debug很长时间。值得注意的地方:1.纸牌被处理的次数中,每次发牌并且检查一次匹配,算处理一次,而不是四次2.查看匹配的时候,如果一次匹配成功并且删除了三张纸牌,要继续检查是否匹配,这是个循环的过程3.可以通过用set记录State判重,判断打平的情况4.纸牌收回手中时,注意纸牌摆放的顺序#include

2015-03-01 10:41:04 744

原创 基于Python的对拍debug工具

脚本程序基于Python3.4,请先配置好环境。import osdef run(): # 运行程序并输出结果 os.system('my.exe my.dat') os.system('right.exe right.dat')def check(): # 逐行对比运行结果 my = open('my.dat', 'r') righ

2015-02-28 16:42:46 1225

原创 UVa 1103 - Ancient Messages [进制转换+DFS]

提供三组测试数据吧:5 3ffff0fffff0ffff5 50fff00f0f0fffff00f0000f005 50f0f00f0f0fffff00f0000f00 0 0AC输出是:Case 1: KCase 2: ACase 3: W做题的时候,发现使用ios::sync_with_st

2015-02-28 13:00:14 4228

原创 Python小程序:简易翻译器

Python就是爽啊,用来抓网页信息是再合适不过了。今天结合小甲鱼的视频做了一个简易翻译工具,大牛勿喷,仅供娱乐!^_^主要用到的模块是json和easyGUI,结合网易有道翻译的网页制作而成。效果还可以。# Powered By KunSoft# 2015年2月27日from urllib.request import *from urllib.parse import *imp

2015-02-27 21:25:23 1738

原创 UVa 511 - Do You Know the Way to San Jose? [STL应用]

这题不难,但细节比较多,排序的依据有很多,比较容易出错。考差C++和STL也比较全面,比如结构体、构造函数、map、pair、vector、sort、unique、copy等等,使用C++11的lambda配合泛型算法是一个很好的选择。#include #define EPS 1e-7using namespace std;struct MAP{ string name; dou

2015-02-27 12:13:07 1192

原创 中海洋朗讯杯比赛总结[2014年12月]

非常荣幸又获得了这次比赛的机会,虽然正处在期末考试前的关键时期,也还有学生会的包饺子大赛活动,但我还是参加了 ACM 比赛,因为只有这才能锻炼自己,学到更多自己想要的东西。虽然在大一上学期加入了集训队,但还是感觉自己比较水,智商严重不符合比赛要求,数学英语之类的东西都很弱,还有最近几次学校和青岛内高校的比赛,自己做的都不爽,还是跟上次一样,没有什么信心。后来得知跟瑞神在一个队,还是比较高兴

2015-02-26 21:16:30 623

原创 青理工ACM比赛总结和反思[2014年11月]

很荣幸获得了参加这次校际ACM比赛的机会,的确,比赛让我有了很大的感触和收获。这次比赛虽然经过努力,我们队取得了比较好的成绩,但这主要是队长茄神的功劳。未能在比赛中做出贡献,对此深感惭愧,今后必将吸取教训,加倍努力。下面是我这次的经验、总结和反思。从心态方面,虽然比预想的要稍微放松一些,但还是非常激动,有时候一到关键时刻就手脚哆嗦,大脑空白,最后可能发挥不出五分之一的水平。我想以后要积极参加这

2015-02-26 21:14:17 629

转载 程序员技术练级攻略

月光博客6月12日发表了《写给新手程序员的一封信》,翻译自《An open letter to those who want to start programming》,我的朋友(他在本站的id是Mailper)告诉我,他希望在酷壳上看到一篇更具操作性的文章。因为他也是喜欢编程和技术的家伙,于是,我让他把他的一些学习Python和Web编程的一些点滴总结一下。于是他给我发来了一些他的心得和经历

2015-02-26 20:43:38 625

转载 一天能学会的计算机技术

作者:Vamei 出处:http://www.cnblogs.com/vamei在Quora中看到一个有趣的问题,题目是"What are some useful computer related technical skills I can learn within a day?",哪些有用的计算机技术,是一天能够学会的?后面的回答很高质量,最受欢迎的答案拿到了2000多个赞。提问人

2015-02-26 15:55:07 561

Dev-cpp 5.5 免费版

Dev-C++是一个C&C++开发工具,使用 Delphi/Kylix 开发, 它是一款自由软件,遵守GPL协议。它集合了GCC、MinGW等众多自由软件,并且可以从工具支持网站上取得最新版本的各种工具

2014-11-15

C&C++语言参考

C&C++语言参考 很全秒的哦! 欢迎下载

2013-01-03

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除