随笔分类 -  ACM

摘要:这题是一个字符串模拟水题,给12级学弟学妹们找找自信的,嘿嘿;题目意思就是要你讲身份证的上的省份和生日解析出来输出就可以了:http://acm.hdu.edu.cn/showproblem.php?pid=2629 1 #include 2 #include 3 using namespace std; 4 int main() 5 { 6 int n,t; 7 string home,a; 8 cin>>n; 9 for(int k = 0 ; k >a;12 t = (a[0]-'0')*10+a[1]-'0';13 s... 阅读全文
posted @ 2013-12-10 14:34 crazy_apple 阅读(2021) 评论(0) 推荐(0)
摘要:1 #include 2 #include 3 #include 4 #include 5 6 using namespace std; 7 8 #define eps 1e-8 9 #define zero(x) (((x)>0?(x):-(x)) 0 ? 1 : -1) : (ret > 0 ? 1 : -1);26 }27 void _graham(int n, point* p, int& s, point* ch){28 int i, k = 0;29 for (p1 = p2 = p[0], i = 1; ieps || (zero(p1.y - p[i]... 阅读全文
posted @ 2013-11-13 20:01 crazy_apple 阅读(460) 评论(0) 推荐(0)
摘要:1 #include 2 const int MAX = 500000; 3 int a[MAX]; 4 int swap[MAX]; //临时数组 5 int n; //数组a的长度 6 __int64 result; //数组a中的逆序数 7 8 //归并两个已经有序的段:a[low]—a[mid]和a[mid+1]—a[high],使得a[low]—a[high]有序。 9 void merge(int low, int mid, int high)10 {11 int i = low;12 int ... 阅读全文
posted @ 2013-11-09 14:35 crazy_apple 阅读(271) 评论(0) 推荐(0)
摘要:http://www.bnuoj.com/bnuoj/problem_show.php?pid=25659 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 8 using namespace std; 9 10 int main()11 {12 int n,cas=1;13 while(~scanf("%d",&n))14 {15 int i;16 stack stk;17 stk.push(-1);18 ... 阅读全文
posted @ 2013-11-04 16:38 crazy_apple 阅读(206) 评论(0) 推荐(0)
摘要:#include#include#includeusing namespace std;char str[20000];int work(int m){ int i,j,l; i=0; j=1; while(im) break; if(str[(i+l)%m] > str[(j+l)%m]) i=i+l+1; else j=j+l+1; if(i==j) j=i+1; } if(i<j) return i; return j;}int main(){ int text... 阅读全文
posted @ 2013-10-30 17:13 crazy_apple 阅读(648) 评论(0) 推荐(0)
摘要:http://www.bnuoj.com/bnuoj/problem_show.php?pid=4207【题意】:中文题,略【题解】:模拟【code】: 1 #include 2 #include 3 #include 4 5 using namespace std; 6 7 struct Nod 8 { 9 int t,sh; 10 }node[3][10]; 11 12 void init() 13 { 14 //XsugarX 15 node[0][0].t = 15; 16 node[0][0].sh = 650; 17 ... 阅读全文
posted @ 2013-10-10 19:30 crazy_apple 阅读(303) 评论(0) 推荐(0)
摘要:http://www.bnuoj.com/bnuoj/problem_show.php?pid=4208【题意】:如题,求冒泡排序遍历趟数【题解】:这题开始2B了,先模拟TLE,然后想了一下,能不能根据始末状态来得到点什么。。。 3 24 1 |==>如果开始的位置在 i 最后位置在 j ,如果 i>j那么最少遍历次数为 i-j 1 2 3 4【code】: 1 #include 2 #include 3 #include 4 #include 5 6 using namespace std; 7 8 struct Nod 9 {10 int a;11... 阅读全文
posted @ 2013-10-10 19:28 crazy_apple 阅读(284) 评论(0) 推荐(0)
摘要:http://www.bnuoj.com/bnuoj/problem_show.php?pid=4209题意:如题题解:公式直接计算,或者角平分线求交点【code1】: 1 #include 2 #include 3 #include 4 #include 5 #include 6 7 using namespace std; 8 //定义点 9 struct point10 {11 double x,y;12 };13 14 typedef struct point point;15 16 17 double fabs(double x)18 {19 return ... 阅读全文
posted @ 2013-10-10 19:12 crazy_apple 阅读(211) 评论(0) 推荐(0)
摘要:http://www.bnuoj.com/bnuoj/problem_show.php?pid=33656【题解】:暴力搜索题【code】: 1 #include 2 #include 3 #include 4 #include 5 #include 6 7 using namespace std; 8 9 char map[100][100]; 10 int vis[100][100]; 11 int n,m; 12 int B,F; 13 int cx[]={0,-1,1,-1,1,-1,0,1}; 14 int cy[]={1,0,1,-1,-1,1,-1... 阅读全文
posted @ 2013-10-05 15:06 crazy_apple 阅读(251) 评论(0) 推荐(0)
摘要:http://www.bnuoj.com/bnuoj/problem_show.php?pid=33648【题解】:结果先对MOD*2取模,才能得到结果是否是正确的奇偶问题,得到最后结果之后再对MOD取模。。。【code】: 1 #include 2 #include 3 #include 4 #include 5 #include 6 7 using namespace std; 8 #define MOD 1000000007 9 10 struct Nod11 {12 int parent;13 long long sum;14 int edge;15... 阅读全文
posted @ 2013-10-05 14:57 crazy_apple 阅读(215) 评论(0) 推荐(0)
摘要:http://www.bnuoj.com/bnuoj/problem_show.php?pid=33647【题意】:字符串匹配,暴力配就行了【题解】:截出单词,然后进行匹配就行了【code】: 1 #include 2 #include 3 #include 4 #include 5 6 using namespace std; 7 8 char tstr[100][100]; 9 10 int main()11 {12 int t;13 scanf("%d",&t);14 getchar();15 while(t--)16 {17 ... 阅读全文
posted @ 2013-10-05 14:50 crazy_apple 阅读(278) 评论(0) 推荐(0)
摘要:http://www.bnuoj.com/bnuoj/problem_show.php?pid=16493【题解】:矩阵快速幂【code】: 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 int N; 8 struct matrix 9 { 10 double a[100][100]; 11 }origin,res; 12 13 14 matrix multiply(matrix x,matrix y) 15 { 16 matrix tem... 阅读全文
posted @ 2013-10-04 14:31 crazy_apple 阅读(379) 评论(0) 推荐(0)
摘要:http://www.bnuoj.com/bnuoj/problem_show.php?pid=29368【题解】:模拟,然后对x,进行枚举,看是否所有都满足条件【code】: 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 9 using namespace std; 10 11 12 double stack[1000]; 13 int s_cnt; 14 15 double fabs(double a) 16 { 17 return... 阅读全文
posted @ 2013-10-04 14:28 crazy_apple 阅读(210) 评论(0) 推荐(0)
摘要:http://www.bnuoj.com/bnuoj/problem_show.php?pid=29373【题意】:模拟光标输入【题解】:用双向列表模拟实现,这里用其他模拟会超时,注意内存的释放【code】: 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 9 using namespace std;10 11 struct Nod12 {13 char ch;14 Nod * second;15 Nod * first;16 Nod()... 阅读全文
posted @ 2013-10-04 14:24 crazy_apple 阅读(273) 评论(0) 推荐(0)
摘要:http://www.bnuoj.com/bnuoj/problem_show.php?pid=29375【题意】:可以对两字符串进行如下操作: 1、可以无损耗交换相邻两个字符(可以理解成交换任意字符) 2、可以改变一个字符 x->y,花费为 x-y 的绝对值 求花费最少,将两字符串变成一样【题解】: 排序字符串,然后对应相减【code】: 1 #include 2 #include 3 #include 4 #include 5 6 using namespace std; 7 8 char str1[100010],str2[100010]; 9 10 int abs(int... 阅读全文
posted @ 2013-10-04 14:18 crazy_apple 阅读(280) 评论(0) 推荐(0)
摘要:Problem A: Small change题解:http://www.cnblogs.com/crazyapple/p/3349469.htmlProblem B: Scoop water题解:http://www.cnblogs.com/crazyapple/p/3349478.htmlProblem D: CX and girls题解:http://www.cnblogs.com/crazyapple/p/3349480.htmlProblem F: ZZY and his little friends题解:http://www.cnblogs.com/crazyapple/p/334 阅读全文
posted @ 2013-10-02 17:29 crazy_apple 阅读(161) 评论(0) 推荐(0)
摘要:http://acm.csu.edu.cn/OnlineJudge/problem.php?cid=2037&pid=9【题解】: 这题卡了一下,卡在负数的情况,负数输出 0 这题主要找到一个个相邻重复的位置,然后加1上去,看是否进位,直到满足条件为止【code】: 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 8 void inttostr(int n,char *str) 9 { 10 int cnt=0; 11 while(n) 12 { 13... 阅读全文
posted @ 2013-10-02 17:20 crazy_apple 阅读(265) 评论(0) 推荐(0)
摘要:http://acm.csu.edu.cn/OnlineJudge/problem.php?cid=2037&pid=5【题解】:没想通这题暴力可以过。。。。【code】: 1 #include 2 #include 3 #include 4 using namespace std; 5 6 int arr[100010]; 7 8 int main() 9 {10 int n,m;11 while(~scanf("%d%d",&n,&m))12 {13 int i,j;14 for(i=0;im)20 ... 阅读全文
posted @ 2013-10-02 17:14 crazy_apple 阅读(221) 评论(0) 推荐(0)
摘要:【题解】:最短路径问题,保证距离最短的同时,学妹权值最大,哈哈【code】: 1 #include 2 #include 3 #include 4 #include 5 #include 6 7 #define N 50005 8 #define INF 100000000 9 using namespace std; 10 11 struct Edge 12 { 13 int to; 14 int next; 15 int w; 16 int num; 17 }edge[Nb.dis; 30 return a.num p_q; 5... 阅读全文
posted @ 2013-10-02 17:13 crazy_apple 阅读(240) 评论(0) 推荐(0)
摘要:http://acm.csu.edu.cn/OnlineJudge/problem.php?cid=2037&pid=1【题解】:卡特兰数取模h(n) = h(n-1)*(4*n-2)/(n+1)这题我们公式选择错了,不过还是能AC的因为要取模,应该选 h(n)=h(0)*h(n-1)+h(1)*h(n-2)+...+h(n-1)*h(0) (n>=2)【code-java】: 1 import java.math.BigInteger; 2 import java.util.Scanner; 3 4 public class Main { 5 6 public stati... 阅读全文
posted @ 2013-10-02 17:10 crazy_apple 阅读(338) 评论(0) 推荐(0)