2011年5月6日

PKU ACM 1131 Octal Fractions http://acm.pku.edu.cn/JudgeOnline/problem?id=1131

摘要: 此题不用到高精度!跟踪double型数在计算机中的存储就很容易得到解题的方法!代码很简单:#include <iostream>#include <cmath>using namespace std;int main (){char str[65535]; while (scanf("%s",&str)!=EOF){ double sum=0; int n=strlen(str); for (int i=2;i<n;i++) { int temp=str[i]-'0'; sum+=(double)temp/pow(8.0 阅读全文

posted @ 2011-05-06 19:16 _Clarence 阅读(176) 评论(0) 推荐(0) 编辑

PKU ACM 1258 Agri-Net http://acm.pku.edu.cn/JudgeOnline/problem?id=1258

摘要: 熟悉了prim算法后这样的题目在十分钟内真的可以解决!最小生成树,prim真的很有用!#include <iostream>using namespace std;const int Max = 1000000;int edge_min (int a[],int n){int min =Max;int index=0;for (int i=0;i<n;i++){ if (a[i]<min&&a[i]!=0) { min = a[i]; index = i; }}return index;}int main (){ int n; while (scanf( 阅读全文

posted @ 2011-05-06 19:15 _Clarence 阅读(146) 评论(0) 推荐(0) 编辑

ACM PKU Catch That Cow 3278 http://acm.pku.edu.cn/JudgeOnline/problem?id=3278

摘要: 宽搜这道题我花了两天的时间写代码,只是本人比较笨,每次都wa或是re了,这道题我总共wa了11次,虽然对高手来说都只认为是没有什么好说的题,但我感觉自己把题做出来真的能学到很多东西,像宽搜一样使我对队列的知识有了更深的理解,人家都是0ms,AC的,我用了219ms,技不如人自当努力学习啊,第一个宽搜题还是要展示一下代码的嘛,呵呵#include <iostream>#include <queue>#include <cmath>//注意到0 1这组数据不能过所以我要用到绝对值函数;using namespace std;int n,k;struct Node 阅读全文

posted @ 2011-05-06 19:14 _Clarence 阅读(156) 评论(0) 推荐(0) 编辑

汇编语言小型程序设计代码

摘要: 1 STACK SEGMENT STACK 2 DB 128 DUP(0) 3 STACK ENDS 4 DATA SEGMENT 5 N = 90 6 A DB 0 7 BUF DB N DUP(' '),13,10,'$' 8 TEMPBUF DB 3,0,3 DUP(0),13,10,'$' 9 SCORE DB 30 DUP(0) 10 HSCORE DB 2 DUP(' '),13,10,'$' 11 HSCORESTR DB 'High score: $' 12 TITLESTR DB 阅读全文

posted @ 2011-05-06 19:13 _Clarence 阅读(360) 评论(0) 推荐(0) 编辑

我的汇编程序设计代码

摘要: 1 STACK SEGMENT STACK 2 DB 1 DUP(?) 3 STACK ENDS 4 DATA SEGMENT 5 STR1 DB 'Please input the scores of N(0<n<=30) students!',10,13,'$' 6 STR2 DB 'The largest score is:',10,13,'$' 7 SCORE DB 91,0,91 DUP (?) 8 BCD DB 30,0,30 DUP (?) 9 DATA ENDS10 CODE SEGMENT11 ASS 阅读全文

posted @ 2011-05-06 19:11 _Clarence 阅读(105) 评论(0) 推荐(0) 编辑

ACM PKU 1298 The Hardest Problem Ever http://acm.pku.edu.cn/JudgeOnline/problem?id=1298

摘要: 人有的时候真的很可鄙,可鄙就变成了可耻,可耻就喜欢做水题,我今天也可耻了一把,1298没什么好说的,水题一道:#include <iostream>#include <string>using namespace std;char S[] = "START";char E[] = "END";char final[] ="ENDOFINPUT";int main (){while (1){ char sentence[256]; gets(sentence); if(strcmp(final,sentence) 阅读全文

posted @ 2011-05-06 19:09 _Clarence 阅读(138) 评论(0) 推荐(0) 编辑

ACM PUK 1088 滑雪 http://acm.pku.edu.cn/JudgeOnline/problem?id=1088

摘要: 人家都说这是一道动态规划题,而我认为这不过是一道广搜题,递归就完全可以解决,而且还不需要用队列,代码很简单也很容易懂,说太多没用,大家都知道,我的代码:#include <iostream>using namespace std;int slope[100][100];int changdu[100][100];int R , C ;int fuc (int i,int j){int max = 0 ;if ( changdu[i][j] > 0 ) return changdu[i][j];if ( i-1>=0){if ( slope[i-1][j] > sl 阅读全文

posted @ 2011-05-06 19:09 _Clarence 阅读(133) 评论(0) 推荐(0) 编辑

最大子串和----经典动态规划

摘要: 假如对于子段:9 2 -16 2temp[i]表示以ai结尾的子段中的最大子段和。在已知temp[i]的情况下,求temp [i+1]的方法是:如果temp[i]>0 temp [i+1]= temp[i]+ai(继续在前一个子段上加上ai),否则temp[i+1]=ai(不加上前面的子段),也就是说状态转移方程:temp[i] = (temp[i-1]>0?temp[i-1]:0)+buf[i];int getMax(int buf[100],int n){int temp[101],max=n*(-127);memset(temp,0,4*(n+1));for(int i=1; 阅读全文

posted @ 2011-05-06 19:08 _Clarence 阅读(164) 评论(0) 推荐(0) 编辑

ACM PKU 1159 Palindrome http://acm.pku.edu.cn/JudgeOnline/problem?id=1159

摘要: 原问题为求回文数需要插入的最少字母,转化为求最长公共子序列!经典的DP问题,算法有固定的模板,动态规划+滚动数组解决问题:#include <iostream>using namespace std;char str[5001];char un_str[5001];int len[2][5001];int main (){int n;cin >> n;int i = 1;int j = n;while (i <= n){ char temp; cin >> temp; str[i] = temp; un_str[j] = temp; i++; j--; 阅读全文

posted @ 2011-05-06 19:07 _Clarence 阅读(116) 评论(0) 推荐(0) 编辑

ACM PKU 1080 Human Gene Functions http://acm.pku.edu.cn/JudgeOnline/problem?id=1080

摘要: 做了几天的一道题,一步一步向前推进,现在看着都想吐了,什么解题报告我也不想写了,就这样吧!只有继续加油!!!#include <iostream>using namespace std;char in_st[101];char in_ed[101];int gene[5][5] = {5,-1,-2,-1,-3, -1,5,-3,-2,-4, -2,-3,5,-2,-2, -1,-2,-2,5,-1, -3,-4,-2,-1,0};int change( char c ){if( c == 'A' ) return 0;if( c == 'C' ) 阅读全文

posted @ 2011-05-06 19:06 _Clarence 阅读(123) 评论(0) 推荐(0) 编辑

导航