摘要: 首先本题需要用到扩展欧几里得算法…… 关于exgcd算法的一点简略证明: 那么,对于函数exgcd(a,b)=(d,x,y),其中d满足d=gcd(a,b); (x,y)满足ax+by=d; 则exgcd(b,a mod b)=(d,x',y'),而此时,使用 x = y' ; y = x' - f 阅读全文
posted @ 2017-04-23 20:33 Dilthey 阅读(295) 评论(0) 推荐(0) 编辑
摘要: Worried School Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 112 Accepted Submission(s): 34 Pr 阅读全文
posted @ 2017-04-22 20:52 Dilthey 阅读(301) 评论(0) 推荐(0) 编辑
摘要: 感觉自己好咸鱼呀……B题写了这么久,虽然可以算作1A(忽略一次少include一个头文件的CE)…… 思想很简单,每次选定一个字符串作为目标字符串,然后把其他所有字符串都当做测试字符串,计算出总共需要的步数,再在这些计算出的步数中找到最小的那个就是答案。 阅读全文
posted @ 2017-04-22 00:13 Dilthey 阅读(223) 评论(0) 推荐(0) 编辑
摘要: N有N_cnt个约数,M有M_cnt个约数,那么总共有N_cnt * M_cnt种对应情况。 假设其中有D_cnt个对应结果是相等的,而这D_cnt个数正好是gcd(N,M)的所有约数。 例如: N=18 , M=42 18 = 1 * 18 ; 2 * 9 ; 3 * 6 ; N_cnt=6 42 阅读全文
posted @ 2017-04-19 23:04 Dilthey 阅读(193) 评论(0) 推荐(0) 编辑
摘要: 解题思路参考:http://www.cnblogs.com/kuangbin/archive/2013/08/13/3255943.html 如果gcd(b[1...n])=d,那么b[1...n]中每个b[i]都应是d的倍数, 而b[1...n]是从a[1...n]修改k个数进而变过来的, 那么, 阅读全文
posted @ 2017-04-17 22:16 Dilthey 阅读(232) 评论(0) 推荐(0) 编辑
摘要: 水题,只是想借此记一下gcd函数的模板 关于HDU1108,lcm( m , n ) = gcd( m , n ) * ( a / gcd( m , n ) ) * ( b / gcd( m , n ) ) = m * n / gcd( m , n ); 当然,我们知道,对于一个递归函数,将它用wh 阅读全文
posted @ 2017-04-17 13:35 Dilthey 阅读(312) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://poj.org/problem?id=2377 Time Limit: 1000MS Memory Limit: 65536K Description Bessie has been hired to build a cheap internet network among 阅读全文
posted @ 2017-04-12 12:31 Dilthey 阅读(163) 评论(0) 推荐(0) 编辑
摘要: 题目翻译来自:http://poj.org/showmessage?message_id=97785 老老实实两次Dijkstra呗…… 两次都是从x点出发,第一次是按输入生成的正常的图,这样dijkstra后得到的是每头牛去参加宴会的最短时间, 第二次是将图上每条边都翻转一个方向后得到的图,这样d 阅读全文
posted @ 2017-04-10 22:43 Dilthey 阅读(239) 评论(0) 推荐(0) 编辑
摘要: Time Limit: 1000MS Memory Limit: 65536K Description Freddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fiona Frog who is s 阅读全文
posted @ 2017-04-09 21:39 Dilthey 阅读(494) 评论(0) 推荐(0) 编辑
摘要: Time Limit: 1000MS Memory Limit: 65536K Description Arbitrage is the use of discrepancies in currency exchange rates to transform one unit of a curren 阅读全文
posted @ 2017-04-09 10:42 Dilthey 阅读(369) 评论(0) 推荐(0) 编辑
摘要: 二分查找。 阅读全文
posted @ 2017-04-07 23:18 Dilthey 阅读(224) 评论(0) 推荐(0) 编辑
摘要: Time Limit: 5000MS Memory Limit: 65536K Description There are so many different religions in the world today that it is difficult to keep track of the 阅读全文
posted @ 2017-04-07 23:13 Dilthey 阅读(226) 评论(0) 推荐(0) 编辑
摘要: Time Limit: 1000MS Memory Limit: 65536K Description Windy has a country, and he wants to build an army to protect his country. He has picked up N girl 阅读全文
posted @ 2017-04-06 22:51 Dilthey 阅读(258) 评论(0) 推荐(0) 编辑
摘要: 1 #include<cstdio> 2 #include<queue> 3 #include<cstring> 4 using namespace std; 5 int n,m,mv;char map[103][103];bool vis[103][103]; 6 struct type{ 7 i 阅读全文
posted @ 2017-04-05 23:06 Dilthey 阅读(170) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://poj.org/problem?id=3522 Time Limit: 5000MS Memory Limit: 65536K Description Given an undirected weighted graph G, you should find one of s 阅读全文
posted @ 2017-04-05 17:32 Dilthey 阅读(222) 评论(0) 推荐(0) 编辑
摘要: 排序的水题,主要拿来测试了一下快速排序和归并排序哪个速度快一点。 当然单纯的一道题目其实完全说明不了什么问题…… 顺手再贴一个写法更加得劲儿一点的归并排序…… 阅读全文
posted @ 2017-04-04 10:26 Dilthey 阅读(183) 评论(0) 推荐(0) 编辑
摘要: Time Limit: 10000MS Memory Limit: 65536K Description An earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team) have set up a 阅读全文
posted @ 2017-04-02 11:05 Dilthey 阅读(221) 评论(0) 推荐(0) 编辑
摘要: Time Limit: 1000MS Memory Limit: 10000K Description 动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形。A吃B, B吃C,C吃A。 现有N个动物,以1-N编号。每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种。 有人用 阅读全文
posted @ 2017-03-31 22:44 Dilthey 阅读(269) 评论(0) 推荐(0) 编辑
摘要: 引用来自http://www.cnblogs.com/iiyiyi/p/4738644.html的思路: 【题目大意】 给出C头奶牛的SAT成绩和申请奖学金,选出N头牛,使得总奖学金在≤F的情况下奶牛SAT成绩的中位数最大。 【思路】 假设before[i]表示前i头奶牛中n/2头奶牛奖学金总额的最 阅读全文
posted @ 2017-03-30 22:15 Dilthey 阅读(204) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://poj.org/problem?id=3614 Time Limit: 1000MS Memory Limit: 65536K Description To avoid unsightly burns while tanning, each of the C (1 ≤ C ≤ 阅读全文
posted @ 2017-03-29 21:49 Dilthey 阅读(218) 评论(0) 推荐(0) 编辑
摘要: 因为在允许的情况下,必然是左右手交替进行,这样不会增加多余的无谓的能量。 然后根据不同的分界点,肯定会产生左手或右手重复使用的情况,这是就要加上Qr/Ql * 次数。 一开始的想法,很直接,枚举每个分界点,计算出总共要用的能量,取最小的那个即是答案: 但是在数据来那个很大的情况下会超时。 所以考虑到 阅读全文
posted @ 2017-03-26 10:28 Dilthey 阅读(196) 评论(0) 推荐(0) 编辑
摘要: 依然是非常暴力的DFS,1~n这n个数字,全排列一遍,找到第一个符合的排列就是答案。 阅读全文
posted @ 2017-03-24 10:12 Dilthey 阅读(100) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://poj.org/problem?id=3050 超级大水题,一次过…… 以5*5的map的某一格 ( i , j ) 为起点,dfs到deep=6,直接把得到的那个数字插入到set容器里(set容器保证每个元素不重复), 然后 i=1 to 5 { j = 1 to 5{.. 阅读全文
posted @ 2017-03-23 21:26 Dilthey 阅读(191) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://poj.org/problem?id=1753 Time Limit: 1000MS Memory Limit: 65536K Description Flip game is played on a rectangular 4x4 field with two-sided 阅读全文
posted @ 2017-03-23 15:44 Dilthey 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 #include 3 #include 4 using namespace std; 5 int dx[4]={+1,0,-1,0}; 6 int dy[4]={0,+1,0,-1}; 7 struct type{ 8 int x,y,t; 9 }meteor[50000+5],now,next; 10 int n,map[305][305],... 阅读全文
posted @ 2017-03-21 22:26 Dilthey 阅读(290) 评论(0) 推荐(0) 编辑