ACM
文章平均质量分 95
Hearthougan
这个作者很懒,什么都没留下…
展开
-
Nyoj 21 三个水杯
题目来源:原创 2014-04-03 21:06:52 · 851 阅读 · 0 评论 -
NYoj 60 谁获得了最高奖学金
题目来源:http://acm.nyist.net/JudgeOnline/problem.php?pid=60#include #include #include #include using namespace std;const int MAXN = 110;struct studentNode{ char name[21]; int average;原创 2014-04-24 21:10:57 · 785 阅读 · 0 评论 -
poj 2654 Rock-Paper-Scissors Tournament
题目来源:http://poj.org/problem?id=2654#include #include #include using namespace std;const int MAXN = 210;int main(){ char m1[10], m2[10]; int iWin[MAXN], iLose[MAXN], p1, p2, i, n, m,原创 2014-04-28 21:15:18 · 1206 阅读 · 0 评论 -
Nyoj 488 素数环
题目来源:http://acm.nyist.net/JudgeOnline/problem.php?pid=488#include #include #include using namespace std;const int MAXN = 55;bool IsPrime[MAXN], visit[MAXN];int arr[MAXN];int n;void Ch原创 2014-04-05 21:58:11 · 795 阅读 · 0 评论 -
nyoj 220 推桌子
题目来源:http://acm.nyist.net/JudgeOnline/problem.php?pid=220原创 2014-04-19 20:38:33 · 859 阅读 · 0 评论 -
poj 1298 The Hardest Problem Ever
题目来源:http://poj.org/problem?id=1298#include #include #include #include #include #include using namespace std;int main(){ string str; int i; while( cin>>str ) { cin原创 2014-04-28 20:07:40 · 719 阅读 · 0 评论 -
poj 2339 Rock, Scissors, Paper
题目来源:http://poj.org/problem?id=2339小模拟,注意字母的原创 2014-04-27 10:16:24 · 714 阅读 · 0 评论 -
UVA 10894 - Save Hridoy
题目来源:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1835模拟!原创 2014-04-27 16:20:54 · 755 阅读 · 0 评论 -
poj 2612 Mine Sweeper
题目来源:http://poj.org/problem?id=2612原创 2014-04-28 19:27:28 · 891 阅读 · 0 评论 -
Hoj LC-Display 1138
题目来源:http://acm.hit.edu.cn/hoj/problem/view?id=1138模拟!原创 2014-04-18 17:32:27 · 636 阅读 · 0 评论 -
poj 1017 Packets
题目来源:http://poj.org/problem?id=1017原创 2014-04-30 18:12:23 · 677 阅读 · 0 评论 -
poj 3983 快算24
题目来源:http://poj.org/problem?id=3983总共有5 * 3 ^ 4原创 2014-04-07 11:55:04 · 970 阅读 · 0 评论 -
Nyoj 12 喷水装置(二)
题目来源:http://acm.nyist.net/JudgeOnline/problem.php?pid=12原创 2014-04-17 19:19:06 · 705 阅读 · 0 评论 -
Frogger ZOJ 1942 POJ 2253
本题类似于上一篇的卡车容量;有一句话需要理解:石头之间的青蛙距离,定义为在所有的路径之中两块石头之间的最大跳跃距离的最小值。(最小最大距离)#include #include #include #include using namespace std;#define MIN(a, b) (a > b ? b : a)#define MAX(a, b) (a > b ? a : b原创 2013-09-01 21:37:23 · 1119 阅读 · 0 评论 -
ZOJ 2797 POJ 2472 106 miles to Chicago
Floyd递推方程dist[i][j] = max(dis[i][j], dist[i][k]*dist[k][j]);#include #include #include using namespace std;#define MAX(a, b) (a > b ? a : b)const int MAXN = 1010;double dist[MAXN][MAXN];原创 2013-09-03 16:25:06 · 972 阅读 · 0 评论 -
2412 ZOJ Farm Irrigation
/**因为每一块地,最多只有四个水管的接口,故而可以把每一块土地上,下,左,右,都标记成0或1(0,代表该方向没有接口;1,代表该方向有接口)DFS(int x, int y){从第一块开始搜索,如果:该土地的1.Land[x][y].up=1,则如果和其他土地连通必有,Land[x-1][y].down = 1;(注意:Land[x-1][y]是在Land[x][y]的上方)2.Lan原创 2013-07-25 09:26:29 · 542 阅读 · 0 评论 -
1049. Counting Ones (30)
/**给定一个数计算其以内1出现的次数设为k,那么k = 个位1出现的次数 + 十位1出现的次数 + 百位1出现的次数······那么:例如:123,如果要推断个位1出现的次数,它与高位和低位有什么关系呢?如果个位数为0,那么这个数以内个位出现1的次数只与他的高位有关,等于高位数,如果个位数字等于1那么个位出现1的次数既与高位有关也与低位有关,等于高位数加上低位数再加上1;如果低位数大于原创 2014-03-20 20:43:11 · 654 阅读 · 0 评论 -
ZOJ 1003 Crashing Balloon
题目来源:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=3这是一道模拟题!#include #include #include using namespace std;bool aTrue, bTrue;/**判断a, b有没有公共的因子,如果有,那么分数低的胜,如果没有,那么分数高的获胜如果分数在2原创 2014-04-02 15:46:11 · 770 阅读 · 0 评论 -
Zoj 1006 Do the Untwist
题目来源:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=6模拟#include #include #include using namespace std;int main(){ char ciphertext[80], plaintext[80]; int ciphercode[100]原创 2014-04-02 16:21:05 · 630 阅读 · 0 评论 -
zoj 1016 Parencodings
题目来源:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1016#include #include #include using namespace std;int main(){ int p[25], match[50]; char str[50]; int T, i, j,原创 2014-04-02 17:08:44 · 676 阅读 · 0 评论 -
zoj 1005 Jugs
题目来源:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5模拟,由于这题是特判的,因此解不唯一!#include #include #include using namespace std;int main(){ int Ca, Cb, N; int t; while(~scanf原创 2014-04-02 16:37:42 · 722 阅读 · 0 评论 -
Zoj 1024 Calendar Game
题目来源:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=24模拟#include #include #include using namespace std;int IsWin[102][13][32];//如果值为1表明 亚当赢,0表明 亚当输,初始时为-1int Month_Day[13] = {0, 3原创 2014-04-02 21:53:19 · 1000 阅读 · 0 评论 -
NYOJ 353 3D dungeon + zoj 1940 Dungeon Master
其实跟二维的一样,注意方向。原创 2014-04-05 18:11:08 · 1284 阅读 · 0 评论 -
zoj 1008
题目来源:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=8之前的写法:原创 2014-04-09 14:56:35 · 653 阅读 · 0 评论 -
Nyoj 587blockhouses zoj 1002 Fire Net
题目来源:Nyojhttp://acm.nyist.net/JudgeOnline/problem.php?pid=587zojhttp://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=2原创 2014-04-09 17:20:17 · 992 阅读 · 0 评论 -
zoj 1019 Illusive Chase
题目来源:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1019#include #include #include #include using namespace std;const int MAXN = 1010;int row, col;int Graph[MAXN][MAXN];int r原创 2014-04-09 20:53:56 · 1934 阅读 · 0 评论 -
poj 2411 zoj1100
参考周伟的论文:http://download.csdn.net/detail/hearthougan/7045453第i行的铺设方法,例如(i, j)位置的铺设受到(i-1,j), (i, j-1)影响,因此(i, j)的铺设可能影响到(i-1, j+1), (i, j+1)位置的铺设.首先交代几个变量的含义:j, curstatus, prestatus,分别表示当前为第j列,当前第i...原创 2014-03-25 17:35:37 · 1427 阅读 · 0 评论 -
zoj 1100
题目来源:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=100现在换一种方式来写这个状态压缩我们先把第0行铺满,然而其余每一行的状态都可以由前一种状态转移而来。我们令第0层全部铺满,只有一种情况,当0 <= i < row时,我们有如下方程: 第0行铺满的状态为(1<<col)-1,铺设...原创 2014-04-10 14:42:12 · 888 阅读 · 0 评论 -
Common Divisors
题目来源:http://codeforces.com/contest/182/problem/D D. Common Divisorstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya has...原创 2014-04-25 12:49:46 · 1022 阅读 · 0 评论 -
Nyoj 5 Binary String Matching
题目来源:http://acm.nyist.net/JudgeOnline/problem.php?pid=5修正的nextval写法: #include <iostream>#include <cstdio>#include <cstring>using namespace std;const int MAXN = 1010;con...原创 2014-04-08 14:03:50 · 794 阅读 · 0 评论 -
kmp hdu 3336
#include <iostream>#include <cstring>#include <cstdio>using namespace std;const int MAXN = 200010;int next[MAXN];void Get_Next(char* str, int n){ int i = 0, j = -1; ...原创 2013-12-03 18:25:43 · 633 阅读 · 1 评论 -
poj 1961 Period KMP
题目大意:给定字符串S,求其前n位所组成的字符串,其最小单元重复的次数。是上一篇的拓展;上一篇 #include <iostream>#include <cstring>#include <cstdio>using namespace std;const int MAXN = 1000010;int next[MAXN];...原创 2013-12-03 15:32:06 · 706 阅读 · 0 评论 -
KMP poj 2406 Power Strings 字符串的幂
题意: 给定两个字符串a和b,定义式子:a*b表示两个字符串的连接,例如:a = "abc", b = "def" 则:a*b = "abcdef"。如果将连乘看成乘法,则按照普遍的方法一个非负整数的幂表示如下: a^0 = "" (the empty string) and a^(n+1) = a*(a^n).输入: 输入字符串S每组样例一行,S为可打印字符.S长度在1~...原创 2013-12-03 13:25:12 · 1105 阅读 · 0 评论 -
KMP poj 2752 Seek the Name, Seek the Fame
深入理解KMP中的next,当我们求完next之后,len为字符串S的长度, 令j = next[len],k = next[j],则有:S[j-k+1, j] = S[len-k+1, len],就是根据这个思路来求解这个问题; #include <iostream>#include <cstring>#include <cstdio&...原创 2013-12-03 12:33:11 · 690 阅读 · 0 评论 -
KMP poj 3461
找一个模式串在主串中出现的次数 #include <iostream>#include <cstring>using namespace std;const int MAXN = 1000010;const int MAXM = 10010;int nextval[MAXM];void Get_NextVal(char* str){...原创 2013-12-03 11:30:46 · 651 阅读 · 0 评论 -
hdu 1867 KMP A + B for you again
//利用KMP求解,找两个字符串的前缀或者后缀相同的部分,不能是中间部分;la = KMP(str1,str2);lb = KMP(str2,str1);如果la > lb 说明找到模式串str2的//前缀与主串str1的后缀相同的部分,长度为la,公共部分是谁的后缀就先输出谁,此处时显然的; #include <iostream>#include <...原创 2013-08-02 15:58:57 · 660 阅读 · 0 评论 -
POj 1061 青蛙的约会
扩展欧几里得: 利用扩展欧几里得,解不定方程。对于形如:p * a+ q * b = c <1> 的不定方程(其中a,b,c已知),可以用扩展欧几里得算法求解。对于<1>式,若有解,则一定有:gcd(a,b) /c = 0; 使用扩展欧几里德算法解决不定方程的办法对于不定整数方程pa+qb=c,若 c mod Gcd(a, b)=...原创 2013-07-15 17:09:21 · 778 阅读 · 0 评论 -
hdu1004字典树
#include <iostream>#include <cstring>using namespace std;struct Trie{ int cnt; Trie* pNext[26]; Trie() { cnt = 0; memset(pNext, NULL, sizeof(pNext)); }};Trie* proot;c...原创 2014-03-06 14:05:55 · 1005 阅读 · 0 评论 -
hdu 2072
这个题对线段树来说有点坑! #include<iostream>#include<cstdio>#include<cstring>#include<algorithm>using namespace std;int sum;char s[100000];char st[500];struct node{ in...原创 2013-11-23 19:11:12 · 732 阅读 · 0 评论 -
hdu 1800 Flying to the Mars
题目大意: 有一群士兵,给定这些士兵的等级,等级大的士兵可以作为教师教等级低的士兵,等级低的不能教等级高的,等级相同的也不可以互相教,每个士兵至多有一个教师(或者没有),每个教师至多有一个士兵(可以没有),问至少需要多少把扫帚? 分析:这个题可以用字典树做,因为如果等级不同,则至少需要一把,但是如果出现等级相同的,一个等级出现几个相同的,在每个等级出现相同的次数中选出一个最大...原创 2013-11-23 14:02:15 · 781 阅读 · 0 评论