ural 1152. False Mirrors】的更多相关文章

题目传送门 /* 题意:一个圈,每个点有怪兽,每一次射击能消灭它左右和自己,剩余的每只怪兽攻击 搜索水题:sum记录剩余的攻击总和,tot记录承受的伤害,当伤害超过ans时,结束,算是剪枝吧 回溯写挫了,程序死循环,跑不出来.等回溯原理搞清楚了,下次自己重写一遍:) */ #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> #include <iostre…
1152. False Mirrors Time limit: 2.0 secondMemory limit: 64 MB Background We wandered in the labyrinth for twenty minutes before finally entering the large hall. The walls were covered by mirrors here as well. Under the ceiling hung small balconies wh…
题目地址:space=1&num=1152">Ural 1152 初学状压DP,原来状压仅仅是用到了个位运算.. 非常水的状压DP.注意四则运算的优先级是高于位运算的..也就是说假设既用到了四则运算.也用到了位运算.要想先算位运算的话,要将位运算加括号.由于这个地方调了好久.. 代码例如以下: #include <iostream> #include <cstdio> #include <string> #include <cstring&…
题目链接 题意 : 每一颗子弹破坏了三个邻近的阳台.(第N个阳台是与第1个相邻)射击后后的生存的怪物都对主角造成伤害- 如此,直到所有的怪物被消灭,求怎样射击才能受到最少伤害. 思路 : 状压,数据不是很大,可以爆一爆,或者DFS下去就行,枚举每一种状态. #include <cstdio> #include <cstring> #include <iostream> #define oo 1 << 28 using namespace std ; ],dp…
题目链接 理解了题意之后,就不难了..状态压缩+暴力. #include <cstring> #include <cstdio> #include <string> #include <iostream> #include <algorithm> #include <vector> #include <queue> #include <cmath> using namespace std; <<];…
列表: URAL 1225 Flags URAL 1009 K-based Numbers URAL 1119 Metro URAL 1146 Maximum Sum URAL 1203 Scientific Conference URAL 1353 Milliard Vasya's Function URAL 1260 Nudnik Photographer URAL 1012 K-based Numbers. Version 2 URAL 1073 Square Country URAL 1…
这几天扫了一下URAL上面简单的DP 第一题 简单递推 1225. Flags #include <iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; #define LL long long LL dp[][]; int main() { int i,n; scanf("%d",&n); dp[][] = ;d…
题目传送门 /* 题意:程序从1到n版本升级,正版+正版->正版,正版+盗版->盗版,盗版+盗版->盗版 正版+破解版->正版,盗版+破解版->盗版 DP:每种情况考虑一遍,递推就行了 注意:开long long */ #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <cmath> using…
题目传送门 /* 题意:给出一个长为n的仅由小写英文字母组成的字符串,求它的回文串划分的元素的最小个数,并按顺序输出此划分方案 回文串+回溯:dp[i] 表示前i+1个字符(从0开始)最少需要划分的数量,最大值是i+1,即单个回文串: 之前设置ok[j][j+i] 判断从j到j+i的字符是否为回文串(注意两个for的顺序,为满足ok[j][j+i] = ok[j+1][j+i-1]) 最后枚举找到最优划分点,用pre[i]记录前一个位置,print函数 输出空格 */ #include <cst…
NYOJ 239:http://acm.nyist.net/JudgeOnline/problem.php?pid=239 ural 1109 :http://acm.timus.ru/problem.aspx?space=1&num=1109 NYOJ 月老的难题,是裸的最大匹配,很烦的是邻接阵超时.改用邻接表. #include <bits/stdc++.h> using namespace std; #define maxn 1005 vector <int> G[m…
URAL 2035 输入x,y,c,  找到任意一对a,b 使得a+b==c&& 0<=a<=x && 0<=b<=y 注意后两个条件,顺序搞错wa几次 #include<cstdio> #include<algorithm> using namespace std; int main(){ int x,y,c; while(~scanf("%d%d%d",&x,&y,&c)){ i…
#1152 : Lucky Substrings 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 A string s is LUCKY if and only if the number of different characters in s is a fibonacci number. Given a string consisting of only lower case letters, output all its lucky non-empty sub…
F - The Great TeamTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=87643#problem/F Description When a few students of the Ural State University finished their sport career, the university encountered…
点我看题目 题意  : 这个人在左下角,地铁在右上角,由很多格子组成的地图,每一条边都是一条路,每一条边都是100米.还有的可以走对角线,问你从起点到终点最短是多少. 思路 : 其实我想说一下,,,,,这个题基本都是用DP做的,这是为什么呢?好吧,这要从我最近要刷BFS题开始,于是二货自己很厉害的用BFS做完了,所以就给我推荐了,我其实没看出来能用BFS来做....... //URAL 1119 #include <iostream> #include <stdio.h> #inc…
URAL 1707. Hypnotoad's Secret space=1&num=1707" target="_blank" style="">题目链接 题意:这题设置的恶心不能多说.构造点和矩形.大概就是问每一个矩形里面是否包括点 思路:树状数组.把点排序,按y轴,在按x轴.在按询问,这样每次遇到一个点就在对应的扫描线上加.遇到查询就询问出左边到这个点位置的,就能预处理出每一个点左下角包括的点的个数,然后每一个矩形再利用容斥原理去搞一下就…
标题来源:URAL 1141. RSA Attack 意甲冠军:给你e n c 并有m^e = c(mod n) 求 m 思路:首先学习RSA算法 here 过程大致是 1.发送的信息是m 2.随机选择两个质数 p和q, n = q*p, n的欧拉函数值φ(n)= (p-1)*(q-1)这个须要证明 3.选择一个与φ(n)互质的而且小于φ(n)的数e, 计算c = m^e(mod n) 4.发送c 5解密 求e的逆元d 逆元就是2个数乘一下在mod一个数等于1 这里就是e*d = 1(mod φ…
1152 Google Recruitment (20 分)   In July 2004, Google posted on a giant billboard along Highway 101 in Silicon Valley (shown in the picture below) for recruitment. The content is super-simple, a URL consisting of the first 10-digit prime found in con…
文章转自http://blog.csdn.net/technologyboy/article/details/17143641 简单点来说,repository就是个仓库.maven里有两种仓库,本地仓库和远程仓库.远程仓库相当于公共的仓库,大家都能看到.本地仓库是你本地的一个山寨版,只有你看的到,主要起缓存作用.当你向仓库请求插件或依赖的时候,会先检查本地仓库里是否有.如果有则直接返回,否则会向远程仓库请求,并做缓存.你也可以把你做的东西上传到本地仓库给你本地自己用,或上传到远程仓库,供大家使…
[BZOJ1814]Ural 1519 Formula 1 (插头dp) 题面 BZOJ Vjudge 题解 戳这里 上面那个链接里面写的非常好啦. 然后说几个点吧. 首先是关于为什么只需要考虑三进制状态,因为哈密顿回路是不可能出现自交的,因此对于当前的轮廓线一定直接分割了哈密顿回路的一部分,不可能出现只考虑分割出来的情况下,存在插头的连通性直接交叉,否则一定不合法(比如说四个连续位置,你不可能\(1,3\)匹配,因为这样子画一条路径出来,无论如何都会和\(2,4\)的路径相交).因此,我们把一…
1837. Isenbaev's Number Time limit: 0.5 second Memory limit: 64 MB Vladislav Isenbaev is a two-time champion of Ural, vice champion of TopCoder Open 2009, and absolute champion of ACM ICPC 2009. In the time you will spend reading this problem stateme…
URAL 1741 思路: dp 状态:dp[i][1]表示到第i个版本为正版的最少流量花费 dp[i][0]表示到第i个版本为盗版的最少流量花费 初始状态:dp[1][0]=dp[0][0]=0 目标状态:min(dp[n][0],dp[n][1]) 状态转移:见代码,注意如果是cracked版本,如果原来是盗版,转移后还是盗版 代码: #include<bits/stdc++.h> using namespace std; #define ll long long #define mem(…
URAL 1501 思路: dp+记忆化搜索 状态:dp[i][j]表示选取第一堆前i个和第二堆前j的状态:0:0多1个              1:0和1相等                2:1多一个         -2:不能达到题目所描述的状态 初始状态:dp[0][0]=1 状态转移:见代码 代码: #include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_bck #defin…
URAL 1029 思路: dp+记录路径 状态:dp[i][j]表示到(i,j)这个位置为止的最少花费 初始状态:dp[1][i]=a[1][i](1<=i<=m) 状态转移:dp[i][j]=a[i][j]+max(dp[i-1][j],dp[i][j-1],dp[i][j+1])(注意扫的方向不同) 数组记录上一次的坐标,最后递归输出 代码: #include<bits/stdc++.h> using namespace std; #define ll long long #…
URAL 1658 思路: dp+记录路径 状态:dp[i][j]表示s1为i,s2为j的最小位数 初始状态:dp[0][0]=0 状态转移:dp[i][j]=min(dp[i-k][j-k*k]+1,dp[i][j])(0<=k<10) 在状态转移时用一个数组v[i][j]记录选的k 代码: #include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define…
URAL 1303 思路: dp+贪心,然后记录路径 mx[i]表示从i开始最大可以到的位置 sufmx[i]表从1-i的某个位置开始最大可以到达的位置 比普通的贪心效率要高很多 代码: #include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define mp make_pair #define pii pair<int,int> #define mem(a,b…
URAL 1183 思路:区间dp,打印路径,详见http://www.cnblogs.com/widsom/p/8321670.html 代码: #include<iostream> #include<cstdio> #include<cstring> #include<string> #include<cmath> #include<algorithm> using namespace std; #define ll long l…
URAL 2072 思路: dp+离散化 由于湿度的范围很大,所以将湿度离散化 可以证明,先到一种湿度的最左端或者最右端,然后结束于最右端或最左端最优,因为如果结束于中间,肯定有重复走的路 状态:dp[i][0]表示湿度为i结束于左端最优的步数 dp[i][1]表示湿度为i结束于右端最优的步数 初始状态:dp[0][0]=dp[0][1]=0 状态转移: dp[i][0]=min(dp[i][0],dp[i-1][0]+abs(prel-nowr)+abs(nowl-nowr));       …
URAL 1635 思路:区间dp+贪心,先n^2处理出每段区间是否是回文串,然后贪心地找每一段1到i的最少分割. 代码: #include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define mem(a,b) memset(a,b,sizeof(a)) ; string s; int n; int dp[N][N]; int ans[N]; int pre[N]; void…
Ural Sport Programming Championship 2015 A - The First Day at School 题目描述:给出课程安排,打印一个课程表. solution 暴力模拟. B - Maths 题目描述:给定一个数\(n\),找出一个序列\(a_i\)满足\(\forall i \in [2, n], \sum_{j=1}^{j \leq i} a_j\) 有\(a_i\)个约数. solution 暴力搜索,发现和不会超过\(2 \times 10^6\),…
 Ancient Necropolis Time Limit:5000MS     Memory Limit:4096KB     64bit IO Format:%I64d & %I64u Submit Status Practice URAL 1249 Description Aerophotography data provide a bitmap picture of a hard-to-reach region. According to the suggestions of scie…