摘要: 对于每一个点,可以找到他在x轴上的可行区域,这样的话就变为了对区间的贪心。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include10 #include11 #include12 using namespace std;13 #define MAX(a,b) (a > b ? a : b)14 #define MIN(a,b) (a a.s);39 }40 41 int main()42 {43 int ca = 1;44 while(... 阅读全文
posted @ 2013-07-22 23:53 再见~雨泉 阅读(242) 评论(0) 推荐(0) 编辑
摘要: 链接:http://acm.timus.ru/problem.aspx?space=1&num=1303按照贪心的思想,每次找到覆盖要求区间左端点时,右端点最大的线段,然后把要求覆盖的区间改为这个右端点到M这个区间。依次类推下去,这样的话就只需要扫一遍就可以找去来。要做的预备工作就是将线段按照左端点的升序排序就可以了。它的时间复杂度就是O(n)代码一直WA,望大神指教 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include10 #include1 阅读全文
posted @ 2013-07-22 23:09 再见~雨泉 阅读(868) 评论(4) 推荐(0) 编辑
摘要: 模运算:(a+b)modn = ((amodn)+(bmodn))modn(a-b)modn = ((amodn)-(bmodn)+n)modn(a*b)modn = ((amodn)*(bmodn))modnint mul_mod(int a,int b,int n){ a%=n; b%=n; return (int)((long long) a*b % n);}例1:大整数取模nmodm,你<10^100,m<10^91234 = ((1*10+2)*10+3)*10+4;依次取模即可1 int ans = 0;2 for(int i=0;i<len;i++)3 {4 . 阅读全文
posted @ 2013-07-22 13:33 再见~雨泉 阅读(549) 评论(0) 推荐(0) 编辑