随笔分类 - Greedy
摘要:Google BookTime Limit:1 Second Memory Limit:32768 KBYou, the best hacker in the world, want to download the books published on Google Book. After some investigation, you found that the address of each page consists of two parts. The first part is the page number, the second part is the signature whi
阅读全文
摘要:1 2 //坐标精度是int 3 /* 4 圆心位于 5 */ 6 #include <iostream> 7 #include <cstdlib> 8 #include <cstring> 9 #include <cmath>10 using namespace std; 11 12 const int N = 1005;13 typedef struct Part 14 {15 int a, b;16 };17 Part q[N];18 19 typedef struct Node 20 {21 int left, right;22 };23
阅读全文
摘要:1 /* 2 先按右端点由小到大排序,相等的话左端点由大到小(否则会少算) 3 */ 4 #include <iostream> 5 #include <cstdlib> 6 #include <cstring> 7 using namespace std; 8 9 const int N = 10000;10 /**下面的不会用 11 typedef struct Node 12 {13 int a, b;14 bool operator < (const Node &node) const//此时使用sort排序 15 {16 return
阅读全文
摘要:1 #include <iostream> 2 #include <stdio.h> 3 #include <string.h> 4 #include <algorithm> 5 #include <set> 6 using namespace std; 7 8 const int N=100010; 9 struct Node{10 int x,y,type;11 bool operator<(const Node &b) const {12 if(x!=b.x) return x<b.x;13 if(y!=b.
阅读全文
摘要:Crixalis's EquipmentTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1491 Accepted Submission(s): 611Problem DescriptionCrixalis - Sand King used to be a giant scorpion(蝎子) in the deserts of Kalimdor. Though he's a guardian of Lich King now
阅读全文
摘要:最少拦截系统Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)Total Submission(s) : 40 Accepted Submission(s) : 16Font: Times New Roman | Verdana | GeorgiaFont Size: ← →Problem Description某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统.但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能超过前一发的高度.某天,雷达捕捉到
阅读全文
摘要:1 /* 2 键盘输入一个高精度的正整数n(<=240位),去掉任意s个数字后剩下的数字按原左右次序将组成一个新的正整数。 3 编程对给定的n和s,寻找一种方案,使得剩下的数最小。 4 Simple Input 5 178543 6 4 7 Simple Output 8 13 9 */10 #include <iostream>11 #include <string>12 using namespace std;13 string s;14 int num;15 void fun()16 {17 int i,j,k,t;18 int size = s...
阅读全文
摘要:无线网络覆盖时间限制:3000 ms | 内存限制:65535 KB难度:3描述我们的乐乐同学对于网络可算得上是情有独钟,他有一个计划,那就是用无线网覆盖郑州大学。现在学校给了他一个机会,因此他要购买很多的无线路由。现在他正在部署某条大道的网络,而学校只允许把他的无线路由器放在路的正中间。我们默认这条大道是笔直的并且它在任何地方的宽度都一样。并且所有的路由器的覆盖面积是相同的。现在乐乐计算出这条大道的长和宽,以及路由器的覆盖半径,想请你帮忙,帮他计算出他最少要购买的路由器的数量。注意:为了防止某种干扰,两台无线路由之间的最小距离不能小于1米图1中为一条矩形的道路,中间的虚线代表中线。图2为最小
阅读全文
摘要://此为背包问题 ,289为0-1背包 #include<stdio.h>#include<stdlib.h> typedef struct data { int w; int v; }data; int cmp(const void *a,const void *b){ return ((data*)a)->v-((data*)b)->v; }//不加括号不行啊 int main(){ data a[10]; int T,v,w,sum,s,m; scanf("%d",&T); while(T--) { sum=0; sca..
阅读全文
摘要:#include<stdio.h>#include<stdlib.h>#include<math.h>int cmp(const void *a,const void *b){ return *(int *)b-*(int *)a;}int main(){ int T,num;int i,j,k,p; float s,sum,a[600]; scanf("%d",&T); while(T--) { scanf("%d",&num); for(j=0;j<num;j++) scanf("%
阅读全文
摘要:#include<stdio.h>#include<stdlib.h>typedef struct { int begin;//开始时间**// int end;//**结束时间**//}Node;int cmp(const void *p1,const void *p2){ return (*(Node *)p1).end-(*(Node *)p2).end;}int main(){ int T,num;int i,p,count; Node a[10001]; scanf("%d",&T); while(T--) { p=0;c...
阅读全文
摘要:寻找最大数时间限制:1000 ms | 内存限制:65535 KB 难度:2描述 请在整数 n 中删除m个数字, 使得余下的数字按原次序组成的新数最大,比如当n=92081346718538,m=10时,则新的最大数是9888输入 第一行输入一个正整数T,表示有T组测试数据每组测试数据占一行,每行有两个数n,m(n可能是一个很大的整数,但其位数不超过100位,并且保证 数据首位非0,m小于整数n的位数) 输出 每组测试数据的输出占一行,输出剩余的数字按原次序组成的最大新数 样例输入 292081346718538 101008908 5样例输出 988898#include<stdio.
阅读全文