UVa
文章平均质量分 52
h1021456873
这个作者很懒,什么都没留下…
展开
-
UVO 120 Stacks of Flapjacks (整行输入+构造函数)
Description Background Stacks and Queues are often considered the bread and butter of data structures and find use in architecture, parsing, operating systems, and discrete event simulation.原创 2015-08-26 15:58:01 · 602 阅读 · 0 评论 -
UVA 10006 Carmichael Numbers (暴力+快速幂取模)
#include #include using namespace std; typedef long long ll; int prime[70000]; void is_prime() { for(int i=2;i<=70000;i++) { if(!prime[i]) { for(int j=2*i;j<=70000;j+=i) prime[j]=1; } } }原创 2015-09-21 15:16:37 · 435 阅读 · 1 评论 -
UVA 11729 任务安排 (贪心)
题意:给出n个部下交待任务所需要的时间和完成任务所需要的时间,求出完成所有任务所需要的总时间数 #include #include #include #include #include #include #include #include using namespace std; const int maxn=1e4+100; paira[maxn]; int main() { int原创 2015-12-02 23:01:17 · 524 阅读 · 0 评论 -
UVa 11078 Ai-Aj(i<j)的最大值
已知序列A0,A1...An-1,使得Ai-Aj(i #include #include #include using namespace std; const int maxn=1e5+100; int pre[maxn],back[maxn],a[maxn]; int main() { int n,ans,i,j; int t; scanf("%d",&t); while(t原创 2015-12-03 01:00:54 · 1473 阅读 · 0 评论 -
UVA 11384 最少操作使数列变为零 (找规律)
用最少的操作次数把序列1,2,....,n 中的所有数都变成0. #include #include #include #include #include #include #include #include using namespace std; int a[100]; int init() { int i; a[1]=1; for( i=2;;i++) { a[i]=2*原创 2015-12-03 00:12:24 · 1078 阅读 · 0 评论 -
UVA 562 分钱(01背包)
Description It's commonly known that the Dutch have invented copper-wire. Two Dutch men were fighting over a nickel, which was made of copper. They were both so eager to get it and the fighting原创 2016-03-13 00:05:12 · 335 阅读 · 1 评论 -
uva 1640 The Counting Problem (数位dp||统计0-9的个数)
Given two integers a and b , we write the numbers between a and b , inclusive, in a list. Your task is to calculate the number of occurrences of each digit. For example, if原创 2017-01-15 13:37:33 · 406 阅读 · 0 评论 -
UVA - 11624 Fire! (2次bfs)
题目:一个平面迷宫中有一个人,迷宫中有些点起火了,火和人每个单位时间只能向相邻的格子移动, 其中有一些空间被墙壁占据,问这个人在不背或烧到的情况下,离开迷宫的最快时间。 解题思路: 先更新火的扩展,然后在进行人的走迷宫.... 注意人走后,当前的路要改成‘#’(墙),,不该会超时 #### #J..# #....# #### #include #in原创 2017-01-16 10:01:40 · 207 阅读 · 0 评论 -
uva 10047 The Monocycle (bfs||思维数组标记状态)
献上题意:个你一个转轮,有5种颜色,为了5中颜色的位置是确定的,为了方便处理我们用01234来表示绿,黑,红,蓝,白。轮子可以沿着它的方向滚动(只能是它当前的方向不能相反方向),每滚动一次会到达另一个格子,着地的颜色会改变,变了之前颜色的下一个,例如当前是绿色着地下一次就是黑色,依次是红蓝白。也可以原地转动(顺逆时针都可以),原地转动其实就是改变了轮子的滚动方向,原地转动每次能转90度。原地转动一原创 2017-01-16 11:53:10 · 279 阅读 · 1 评论 -
UVALive - 4256 Salesmen (简单DP)
题意: 给定一个包含n个点的无向连通图和一个长度为L的序列A,你的任务是修改尽量少的数,使序列中任意两个相邻数或者相同,或者对应图中相邻的两个点。 思路:dp【i】【j】 第i个数为j时的最小修改数。 状态想到了,题目就很好写了。。。转移方程也ok的 #include using namespace std; const int N = 222; int G[N][N原创 2017-03-11 17:26:58 · 247 阅读 · 0 评论 -
uva 437 The Tower of Babylon (DAG_变形 ,dp)
Perhaps you have heard of the legend of the Tower of Babylon. Nowadays many details of this tale have been forgotten. So now, in line with the educational nature of this contest, we will tell you the原创 2015-10-02 12:56:42 · 360 阅读 · 0 评论 -
UVa 10954 Add All (石子合并_优先队列)
#include #include #include #include using namespace std; priority_queue,greater >qq; int main() { int sum,i,j,num,n,ans; while(cin>>n && n) { for(i=0;i<n;i++) { cin>>num; qq.push(num); }原创 2015-09-04 19:50:03 · 580 阅读 · 1 评论 -
uva 1152 4 Values whose Sum is 0(二分_中途相遇|| hash)
#include #include #include #include using namespace std; const int maxn=1e5+100; struct node { int index; int num; int book; } a[maxn]; bool cmp(node x,node y) { if(x.num<y.num) return true; el原创 2015-08-28 16:40:48 · 457 阅读 · 0 评论 -
UVa 11572 - Unique Snowflakes (滑动窗口STL_map||set) 好题!!!
题目大意: 给n个数, n set容器的新技能get√ #include #include #include #include #include using namespace std; const int maxn=1e6+100; int a[maxn]; int main() { int t,n,i,j; setset; cin>>t; while(t-原创 2015-09-01 19:21:32 · 895 阅读 · 1 评论 -
UVa 11054 - Wine trading in Gergovia (等价转化_水题吧)
【原题】 As you may know from the comic "Asterix and the Chieftain's Shield", Gergovia consists of one street, and every inhabitant of the city is a wine salesman. You wonder how this economy works原创 2015-09-01 16:34:25 · 457 阅读 · 1 评论 -
UVa 传说中的车(白书P11134_放棋子+set)
题意: 给你一个n*n的棋盘,让你在棋盘上放n个棋子,要求是所有棋子不能相互攻击(同行或者同列就会攻击),并且每个棋子都有一个限制,那就是必须在给定的矩形r[i]里,输出每个棋子的位置,special Jude。 思路: 看完后第一反应就是匈牙利(哎!惭愧啊。)结果想着怎么建图,想了一会呵呵了,果断想别的方法,其实这个题目设计到一个小思想非常好,那就是把整体分原创 2015-09-03 16:12:43 · 538 阅读 · 1 评论 -
滑动窗口_单调队列入门 (白书P241)
#include #include using namespace std; #define MAX 1000001 int A[MAX]; //存储数据 int Q[MAX]; //队列 int P[MAX]; //存储A[i]中的下标i int Min[MAX]; //输出最小 int Max[MAX]; //输出最大 int n,k; void get_min() {原创 2015-09-03 16:42:35 · 455 阅读 · 1 评论 -
VUa 10976 Fractions Again?! (枚举+暴力水题)
白书上的一道水题,暴力时我们要找到x||y的范围,因为>y,则1/x 下面附上代码: #include #include #include using namespace std; int a[10000]; int main() { int x,y,k,i,num; while(scanf("%d",&k)!=EOF) { num=0; for(y=k+1;y<=2*k;y++)原创 2015-08-19 19:21:46 · 490 阅读 · 0 评论 -
UVa 714 Copying Books (最大值尽量小_二分+贪心)
原题: Before the invention of book-printing, it was very hard to make a copy of a book. All the contents had to be re-written by hand by so called scribers. The scriber had been given a book and原创 2015-09-04 15:35:04 · 495 阅读 · 1 评论 -
UVa 12627 Erratic Expansion 奇怪的气球膨胀 (分治_递归) 白书P245
Piotr found a magical box in heaven. Its magic power is that if you place any red balloon inside it then, after one hour, it will multiply to form 3 red and 1 blue colored balloons. Then in the next h原创 2015-09-04 17:41:56 · 597 阅读 · 1 评论 -
uva 11093 Just Finish it up (环形跑道水题_模拟)
题目大意:就是环形的路上,路上有n个加油站,每个加油站可以加一定量的油pi,到达下一个加油站需要消耗qi升油,现在问可以从出发点驶出然后能够到达起点的出发点序号最小是多少,如果不可能输出不可能。 #include #include #include using namespace std; const int maxn=101001; int a[maxn],b[maxn]; int mai原创 2015-09-04 20:26:14 · 509 阅读 · 2 评论 -
UVA 11882 Biggest Number (搜索+剪枝(dfs+bfs))
题意:在一个R行C列(2≤R,C≤15,R∗C≤30)的矩阵里有障碍物和数字格(包含1~9的数字)。你可以从任意一个数字格出发,每次沿着上下左右之一的方向走一格,但不能走到障碍格中,也不能重复经过一个数字格,然后把沿途经过的所有数字连起来,如图所示。如图可以得到9784,4832145等整数。问:能得到的最大整数是多少?(本段摘自《算法竞赛入门经典(第2版)》) 分析: 枚举起点原创 2017-04-02 20:38:32 · 595 阅读 · 0 评论