UVA
文章平均质量分 81
zzuspy
本人初学者~~
展开
-
UVA - 439 - Knight Moves (BFS)
UVA - 439Knight MovesTime Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %lluSubmit StatusDescriptionA friend of you is doing research on t原创 2015-03-27 23:41:08 · 911 阅读 · 0 评论 -
UVA - 10012 - How Big Is It? (枚举)
思路:刚开始以为直接全排列枚举一下就好了,结果WA了。没想到没这么简单,重新排列后还要判断当前情况是否能够成立(这时可能会有相交的)。比如现在有两个大圆中间围着几个很小很小的圆,肯定是两个大圆先相切,中间几个小圆就有空隙了,这就能说通相邻的圆可以不相切而又使得box最小,解决方案是算出当前圆和之前的圆的相对位置取最大值,这样就能够保证既能够最大,又能够不相交AC代码:#includ原创 2015-03-24 19:48:50 · 827 阅读 · 0 评论 -
UVA - 10716 - Evil Straw Warts Live (简单模拟)
UVA - 10716Evil Straw Warts LiveTime Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %lluSubmit StatusDescriptionProblem D: Evil Straw Warts原创 2015-04-02 23:55:36 · 827 阅读 · 0 评论 -
UVA - 10954 - Add All (贪心)
UVA - 10954Add AllTime Limit: 3000MSMemory Limit: Unknown64bit IO Format: %lld & %lluSubmit StatusDescriptionProblem FAdd AllInput: standard inputOutput: stan原创 2015-03-31 22:12:35 · 1142 阅读 · 0 评论 -
UVA - 103 - Stacking Boxes (动态规划)
UVA - 103Stacking BoxesTime Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %lluSubmit StatusDescriptionBackgroundSome concepts in Mathe原创 2015-03-31 23:24:27 · 681 阅读 · 0 评论 -
UVA - 624 - CD (动态规划)
UVA - 624CDTime Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %lluSubmit StatusDescriptionYou have a long drive by car ahead. You have a t原创 2015-03-22 11:26:59 · 1286 阅读 · 0 评论 -
UVA - 111 - History Grading (LCS)
UVA - 111History GradingTime Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %lluSubmit StatusDescriptionBackgroundMany problems in Comput原创 2015-03-15 20:36:59 · 703 阅读 · 0 评论 -
UVA - 562 - Dividing coins (01背包)
UVA - 562Dividing coinsTime Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %lluSubmit StatusDescriptionIt's commonly known that the Dutch h原创 2015-03-25 18:43:09 · 786 阅读 · 0 评论 -
UVA - 10130 - SuperSale (动态规划 - 01背包)
10130 SuperSaleThere is a SuperSale in a SuperHiperMarket. Every person can take only one object of each kind, i.e.one TV, one carrot, but for extra low price. We are going with a whole family to原创 2015-03-22 10:24:56 · 1189 阅读 · 0 评论 -
UVA - 10341 - Solve It (二分求解)
思路:给你一个公式,求零点,从题目条件可以看出,此函数式是递减的,所以只要从两头往中间二分答案即可,注意精度问题,因为要精确到小数点后4位,这里e的n次方可以用exp(n)表示,也可以用pow(M_E, n)表示以下是math.h中定义的一些常量:/* Definitions of useful mathematical constants* M_E - e* M_原创 2015-04-01 21:41:21 · 676 阅读 · 0 评论 -
UVA - 108 - Maximum Sum (简单贪心)
UVA - 108Maximum SumTime Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %lluSubmit StatusDescriptionBackgroundA problem that is simple原创 2015-04-02 22:28:59 · 969 阅读 · 0 评论 -
UVA - 301 - Transportation (暴力回溯)
UVA - 301TransportationTime Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %lluSubmit StatusDescriptionRuratania is just entering capitalis原创 2015-03-23 14:40:19 · 757 阅读 · 0 评论 -
UVA - 10474 - Where is the Marble? (基数排序)
UVA - 10474Where is the Marble?Time Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %lluSubmit StatusDescriptionRaju and Meena love to play原创 2015-03-20 21:48:35 · 2273 阅读 · 0 评论 -
UVA - 11235 - Frequent values (RMQ)
UVA - 11235Frequent valuesTime Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %lluSubmit StatusDescription2007/2008 ACM International Colle原创 2015-03-09 22:42:35 · 625 阅读 · 0 评论 -
java大数类操作以及应用(UVA)
首先,先看看java大数的基本操作Ⅰ基本函数:1.valueOf(parament); 将参数转换为制定的类型 比如 int a=3; BigInteger b=BigInteger.valueOf(a); 则b=3; String s=”12345”; BigInteger c=BigInteger.valueOf(s); 则c=12345;原创 2015-03-28 13:14:42 · 1150 阅读 · 0 评论 -
UVA - 10420 - List of Conquests (排序 - qsort、STL)
UVA - 10420List of ConquestsTime Limit: 3000MSMemory Limit: Unknown64bit IO Format: %lld & %lluSubmit StatusDescriptionProblem BList of ConquestsInput: standa原创 2015-03-22 13:44:58 · 855 阅读 · 0 评论 -
UVA - 11991 - Easy Problem from Rujia Liu? (STL)
UVA - 11991Easy Problem from Rujia Liu?Time Limit: 1000MS Memory Limit: Unknown 64bit IO Format: %lld & %lluSubmit StatusDescriptionProblem EEasy Pr原创 2015-01-31 22:37:54 · 915 阅读 · 0 评论 -
UVA - 10125 - Sumsets (暴力枚举 + STL)
思路:刚开始的思路是直接暴力枚举O(n3),感觉会超时,不过还是试着敲了下,居然过了,其中用STL中的set来找最后一个数,最好先排下序,然后再枚举d(要求的)和a,b,再用set去找cAC代码:#include #include #include #include #include using namespace std;int a[1005];int flag,原创 2015-03-22 20:03:58 · 555 阅读 · 0 评论 -
UVA - 10700 - Camel trading (简单贪心)
UVA - 10700Camel tradingTime Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %lluSubmit StatusDescriptionProblem E - Camel tradingTime L原创 2015-03-30 23:37:46 · 699 阅读 · 0 评论 -
UVA - 10591 - Happy Number (STL)
UVA - 10591Happy NumberTime Limit: 3000MSMemory Limit: Unknown64bit IO Format: %lld & %lluSubmit StatusDescription Problem CHappy Number原创 2015-03-22 20:22:48 · 864 阅读 · 0 评论 -
UVA - 639 - Don't Get Rooked (暴力回溯)
UVA - 639Don't Get RookedTime Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %lluSubmit StatusDescriptionIn chess, the rook is a piece that原创 2015-03-23 13:25:27 · 1026 阅读 · 0 评论 -
UVA - 10487 - Closest Sums (二分求解)
传送:UVA - 1048710487 Closest SumsGiven is a set of integers and then a sequence of queries. A query gives you a number and asks to finda sum of two distinct numbers from the set, which is原创 2015-04-01 22:27:55 · 642 阅读 · 0 评论 -
UVA - 993 - Product of digits (简单贪心)
993 Product of digitsFor a given non-negative integer number N, find the minimal natural Q such that the product of alldigits of Q is equal N.InputThe first line of input contains one po原创 2015-04-01 23:20:41 · 550 阅读 · 0 评论 -
UVA - 10375 - Choose and divide (组合数)
题目传送:UVA - 10375思路:用double存答案,不过要注意是边乘边除,这样不会爆double,还有记得乘的时候要把int转换成doubleAC代码:#include #include #include #include #include #include #include #include #include #include #inclu原创 2015-04-30 13:49:33 · 694 阅读 · 0 评论 -
UVA - 10183 - How Many Fibs? (斐波那契 + 高精度)
题目传送:UVA - 10183思路:高精度就可以了,因为10^100以内的斐波那契数不多,根据公式来看,估计就500多,开个1000的数组足够啦,实现的话是用的java,注意这里的斐波那契是从1开始的,我一开始是从0开始的,wa了一下AC代码:import java.util.Scanner;import java.math.BigInteger;public原创 2015-04-30 15:08:32 · 1011 阅读 · 0 评论 -
UVA - 10229 - Modular Fibonacci (矩阵快速幂 + fibonacci)
题目传送:UVA - 10229思路:就是简单的矩阵快速幂求fibonacci数列,然后注意可能中间结果会爆int,因为2^19有50多万AC代码:#include #include #include #include #include #include #include #include #include #include #include原创 2015-04-30 19:20:36 · 1121 阅读 · 0 评论 -
UVA - 11029 - Leading and Trailing (快速幂+公式变形)
题目传送: UVA - 11029思路:后三位可以直接快速幂取模,然后前三位可以有两种做法,一个是利用double,一个是利用公式法,具体看代码吧注意,后三位不足三位要补0,即用%03dAC代码①:#include #include #include #include #include #include #include #include #原创 2015-04-28 00:25:18 · 922 阅读 · 0 评论 -
UVA - 571 - Jugs (数论 - 经典倒水问题)
题目传送:UVA - 571思路:A为空时就加满,不空就倒给B,B满了后就全倒掉,直到B的容量为n(参考)AC代码:#include #include #include #include #include #include #include #include #include #include #include #include #define原创 2015-04-28 22:22:30 · 951 阅读 · 0 评论 -
UVA - 10891 - Game of Sum (DP)
题目传送:UVA - 10891思路:定义dp(i,j)表示原序列中的第i~j个元素组成的子序列,在双方都采取最优策略的情况下,先手得分的最大值通过枚举给对方剩下怎样的子序列,有状态转移方程为:dp(i, j) = sum(i, j) - min{d(i+1, j), d(j, j) ,d(i,j-1),...,d(i,i),0};AC代码①(On^原创 2015-05-04 17:43:34 · 506 阅读 · 0 评论 -
UVA - 10635 - Prince and Princess (LCS转化为LIS)
题目传送:UVA - 10635思路:直接思路是两个串的LCS,不过这个题可以转化为LIS,因为说了序列中各个元素互不相同,所以可以来个映射算出第二个字符串中的字符对应第一个字符串中字符的位置(不存在即删去),然后算出这些位置的LIS即可AC代码:#include #include #include #include #include #include #i原创 2015-05-04 14:36:06 · 729 阅读 · 0 评论 -
UVA - 11827 - Maximum GCD,10200 - Prime Time (数学)
两个暴力题。。题目传送:11827 Maximum GCDAC代码:#include #include #include #include #include #include #include #include #include #include #include #include #include #include #define LL l原创 2015-07-27 15:22:39 · 849 阅读 · 0 评论 -
UVA - 11020 - Efficient Solutions (multiset实现BST)
Efficient Solutions题目传送:Efficient SolutionsAC代码:#include <map>#include <set>#include <cmath>#include <deque>#include <queue>#include <stack>#include <cstdio>#include <cctype>#include <string>#原创 2015-08-01 17:04:11 · 752 阅读 · 0 评论 -
UVA - 10820 - Send a Table (欧拉函数)
题目传送:UVA - 10820思路:找出1~n之间的所有互质的整数对,可以用欧拉函数做,先打出50000以内的欧拉函数的表,然后累加即可AC代码:#include #include #include #include #include #include #include #include #include #include #include #i原创 2015-05-02 20:52:40 · 668 阅读 · 0 评论 -
UVA - 10308 - Roads in the North (DFS)
题目传送:UVA - 10308思路:就是树的遍历,DFS即可,注意输入AC代码:#include #include #include #include #include #include #include #include #include #include #include #include #include #include #defi原创 2015-04-30 00:58:50 · 688 阅读 · 1 评论 -
UVA - 11234 - Expressions (栈和队列)
UVA - 11234ExpressionsTime Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %lluSubmit StatusDescription2007/2008 ACM International Collegiat原创 2015-04-18 22:04:09 · 899 阅读 · 0 评论 -
UVA - 10004 - Bicoloring (简单图论-着色判断)
UVA - 10004BicoloringTime Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %lluSubmit StatusDescription Bicoloring In 1976原创 2015-04-18 20:16:48 · 874 阅读 · 0 评论 -
UVA - 11464 - Even Parity
11464 Even ParityWe have a grid of size N × N. Each cell of the grid initially contains a zero(0) or a one(1). The parityof a cell is the number of 1s surrounding that cell. A cell is surrounded b原创 2015-04-11 23:46:09 · 493 阅读 · 0 评论 -
UVA - 10192 - Vacation (LCS)
题目传送:UVA - 10192思路:就是简单的最长公共子序列啦,不过输入居然还包含空格,然后很奇怪的TLE了,不是WA,心想n最大才100居然TLE,,好吧,可能有些数据特殊吧AC代码:#include #include #include using namespace std;char s1[105], s2[105];int dp[10原创 2015-04-20 23:41:04 · 713 阅读 · 0 评论 -
UVA - 116 - Unidirectional TSP (简单DP + 打印路径)
题目传送: UVA - 116思路:可以定义状态为dp[i][j] 为从第i行第j列开始往后走到第n列(总共n列)的最小值(赋初始值为无穷),且状态方程很好推出来:dp[i][j] = a[i][j] + max(dp[i-1][j+1], dp[i][j+1], dp[i+1][j+1]); 最后最优解 ans = max(dp[i][1])(1不过这题难点不在这原创 2015-04-20 20:53:16 · 696 阅读 · 0 评论 -
UVA - 138 - Street Numbers (简单数论)
题目传送: UVA - 138思路:题意好难懂,看了半天,还是搜了题解才搞懂题意,真是给英语跪啦m在家的位置,而n是最后一个位置,直接输出前10组满足1~m-1的和 == m+1 ~ n的和,这是题意;然后通过题意可以得到n*(n+1)/2 - m - m*(m-1)/2 = m*(m-1)/2;化简可得2*m*m = n*(n+1);然后可以通原创 2015-04-26 00:19:03 · 732 阅读 · 0 评论