随笔分类 -  ACM_知识点

摘要:4-point polyline大意:给你一个网格,从(0, 0)到(n, m)。在网格中选出4个不相同的点,按序相连成3段,求3段想加之和最长的情况是什么,输出这种情况。思路:当时做的时候各种蛋疼,主要是没想对方向,导致一直WA在第3组。今天看到了一个比较清晰的思路。首先,确定一个短边,我取了m为... 阅读全文
posted @ 2014-07-28 20:22 GLSilence 阅读(432) 评论(0) 推荐(0)
摘要:能被1整除的数: 好像是所有数都行能被2整除的数: 末位数字是偶数的数能被3整除的数: 各位数字之和能被3整除能被4整除的数: 末尾两位数字能被4整除能被5整除的数: 末位是0或5的数能被6整除的数: 既能被2整除,又能被3整除★能被7整除的数: 方法1(割尾法):(适用于数字位数较少)一个数割去末位数字,从留下的数中减去割掉数字的两倍,减过之后如果能被7整除,原数能被7整除,如果不能直接判断,重复操作。Eg:133:13-3*2=7,所以133是7的倍数; 6139: 613-9*2=595,59-5*2=49,所以6139是7的倍数。 方法2(末三法):(适用于位数大于... 阅读全文
posted @ 2013-12-25 14:28 GLSilence 阅读(2902) 评论(0) 推荐(0)
摘要:ID CodesSTL知识点:给你一个字符串,求用这个字符串重新组合后,比这个字符串大的下一个字符串。例:abaacb -> ababaccba -> abc C++: next_permutation(a, a+len); 当然,prev_permutation就是求前一种排列组合的了。POJ 1146 Code: 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include 10 #define LL long lon... 阅读全文
posted @ 2013-12-06 20:30 GLSilence 阅读(247) 评论(0) 推荐(0)
摘要:Bad Hair Day开个标记数组记录,记录右边第一个比它大的位置。#include #include #define N 80001long long p[N],left[N],sum;int main(){ int n,i,j; scanf("%d",&n); for(i = 1; i = 1; i--) { j = i+1; while(j #include using namespace std;const int N = 80005;int stack[N];int top, n;int main(){ int num; ... 阅读全文
posted @ 2013-10-24 21:35 GLSilence 阅读(255) 评论(0) 推荐(0)
摘要:struct node{ char data[100];} s[100010];bool cmp(const node &x, const node &y){ if(strcmp(x.data, y.data) < 0) return true; return false;}sort(s, s+n, cmp); 阅读全文
posted @ 2013-10-22 20:01 GLSilence 阅读(336) 评论(0) 推荐(0)