06 2012 档案

摘要://做这种题我知道了,以后数字能定多大就定多大,最后就long long int,前面都是把数字定义为int,老是WA#include <iostream>#include <string>#include <sstream>#include <algorithm>using namespace std;int main(){ string str1,str2,str3; while(cin>>str1>>str2>>str3) { unsigned long int p = 0; unsigned long 阅读全文
posted @ 2012-06-30 22:46 godjob 阅读(228) 评论(0) 推荐(0) 编辑
摘要:没做,没感觉,做这类题提不起劲#include <stdio.h> #include <string.h> long long p[10001]; char num[10001]; int main() { long long i,j,k,len,n,mod; char lat[3]; while(scanf("%s%s%lld",num,lat,&n)!=EOF) { memset (p,0,sizeof(p)); len = strlen(num); for(i = 0;i <= len-1;i ++) ... 阅读全文
posted @ 2012-06-28 22:53 godjob 阅读(179) 评论(0) 推荐(0) 编辑
摘要:这题没做,直接在网上看了别人的代码,对数字的一些问题不是很了解学习一下istringstream的用法:#include <iostream>#include <string>#include <sstream>//使用istringstream()需要调入的头文件using namespace std;string getMaxStr(){ int n=0x7fffffff; string s=""; while(n!=0) { s=(char)(n%10+'0')+s; n=n/10; } return s;}bool 阅读全文
posted @ 2012-06-27 23:14 godjob 阅读(234) 评论(0) 推荐(0) 编辑
摘要:#include <iostream>#include <algorithm>#include <cstring>using namespace std;int mutil(char * x, char * y , char * z){ char * px = x; char * py = y; int carry =0 , temp; if(strcmp(x,"0") == 0 || strcmp(y,"0") == 0) { z[0] = 0; return 1; } int i,j; for(i = 0 ; *( 阅读全文
posted @ 2012-06-27 21:53 godjob 阅读(134) 评论(0) 推荐(0) 编辑
摘要:水题,就是把非常大的数组进行相加#include <iostream>#include <algorithm>#include <cstring>using namespace std;char table_atoi[128];//下标字母 对应 数字int main(){ int i =0; char c = '0'; for( ; i < 10 ; ++i ,++c) { table_atoi[c] = i; } char buff[100]; char result[100] = {0}; char carry = 0; int 阅读全文
posted @ 2012-06-25 22:51 godjob 阅读(194) 评论(0) 推荐(0) 编辑
摘要:该题有ANSI C写了一遍,通过使用二叉树的思想可以很好的解决这个问题,该题是用UVa系统测评的,发现如果用标准的C写代码的话,语法要求真的很严格,提交了几次都是语法错误,单行注释都报错,最要紧的是连内建的bool类型都没有,所以我用int型代替,下面是AC的代码#include <stdio.h>#define Nil -1char left[50], right[50], tree_index[50];char code[40];int top = 0;int tree_root = -1;char* out_buff_is = "Set %d is immediat 阅读全文
posted @ 2012-06-25 17:20 godjob 阅读(228) 评论(0) 推荐(0) 编辑
摘要:Text-processing tools like awk and sed allow you to automatically perform a sequence of editing operations based on a script. For this problem we consider the specific case in which we want to perform a series of string replacements, within a single line of text, based on a fixed set of rules. Each 阅读全文
posted @ 2012-06-24 23:17 godjob 阅读(222) 评论(0) 推荐(0) 编辑
摘要:Immediate DecodabilityAn encoding of a set of symbols is said to be immediately decodable if no code for one symbol is the prefix of a code for another symbol. We will assume for this problem that all codes are in binary, that no two codes within a set of codes are the same, that each code has at l. 阅读全文
posted @ 2012-06-24 20:54 godjob 阅读(302) 评论(0) 推荐(0) 编辑
摘要:Artificial Intelligence?Physics teachers in high school often think that problems given as text are more demanding than pure computations. After all, the pupils have to read and understand the problem first!So they don't state a problem like ``U=10V, I=5A, P=?" but rather like ``You have an 阅读全文
posted @ 2012-06-16 15:42 godjob 阅读(189) 评论(0) 推荐(0) 编辑
摘要:Problem IAutomatic Poetry Input: standard inputOutput: standard outputTime Limit: 2 secondsMemory Limit: 32 MB“Oh God”, Lara Croft exclaims, “it’s one of these dumb riddles again!”In Tomb Raider XIV, Lara is, as ever, gunning her way through ancient Egyptian pyramids, prehistoric caves and medival h 阅读全文
posted @ 2012-06-16 14:40 godjob 阅读(318) 评论(0) 推荐(0) 编辑
摘要:Q10010: Where's Waldorf?給你一個m*n的字元方塊(1 <= m,n <=50),以及一些字串,請你找出這些字串在字元方塊中出現的位置。請參考Sample Output。我們在字元方塊中尋找字串的方向可以有8個:往左、往右、往上、往下、往左上、往左下、往右上、往右下。另外,請忽略字元大小寫,即 A 和 a 應被視為相同的字元。Input輸入的第一列有一個整數代表以下有幾組測試資料。每組測試資料的第1列,有2個整數m,n(1 <= m,n <=50),代表接下來的文字方塊有m列,每列有n個字元。在文字方塊之後的一列有一個整數 k,代表接下來的 阅读全文
posted @ 2012-06-15 23:55 godjob 阅读(371) 评论(0) 推荐(0) 编辑
摘要:PalindromesA regular palindrome is a string of numbers or letters that is the same forward as backward. For example, the string "ABCDEDCBA" is a palindrome because it is the same when the string is read from left to right as when the string is read from right to left. A mirrored string is 阅读全文
posted @ 2012-06-15 18:06 godjob 阅读(229) 评论(0) 推荐(0) 编辑
摘要:A*寻路初探(转载)作者:Patrick Lester译者:Panic2005年译者序:很久以前就知道了A*算法,但是从未认真读过相关的文章,也没有看过代码,只是脑子里有个模糊的概念。这次决定从头开始,研究一下这个被人推崇备至的简单方法,作为学习人工智能的开始。这篇文章非常知名,国内应该有不少人翻译过它,我没有查找,觉得翻译本身也是对自身英文水平的锻炼。经过努力,终于完成了文档,也明白的A*算法的原理。毫无疑问,作者用形象的描述,简洁诙谐的语言由浅入深的讲述了这一神奇的算法,相信每个读过的人都会对此有所认识(如果没有,那就是偶的翻译太差了--b)。现在是年月日的版本,应原作者要求,对文中的某些 阅读全文
posted @ 2012-06-08 17:16 godjob 阅读(233) 评论(0) 推荐(1) 编辑
摘要:Q489: Hangman JudgeHangman Judge是一個猜英文單字的小遊戲(在電子字典中常會看到),遊戲規則如下: 答案單字寫在紙上(每個字元一張紙),並且被蓋起來,玩家每次猜一個英文字元(letter)。 如果這個英文字元猜中(在答案的英文單字中有出現),被猜中的字元就被翻開。例如:答案是book,如果你猜o,book中的兩個o就會被視為已猜中。 如果這個英文字元未出現在答案的單字中,就會在hangman的圖中多加一劃。要完成hangman圖共需7劃,如下圖。注意:同一個猜錯的字元只能再圖上畫一劃,例如:答案是book,第一次你猜a(未猜中)會在圖上畫一劃,但第二次... 阅读全文
posted @ 2012-06-03 22:51 godjob 阅读(345) 评论(0) 推荐(0) 编辑
摘要:Q445: Marvelous Mazes本題中你的任務是寫一支可以畫迷宮的程式,這個迷宮將由A-Z26個字母及*(星號)和空白字元組成。Input and Output你的程式必須從input讀入迷宮的資訊,輸入將包含數列字元,你的程式必須依照指示畫出迷宮。迷宮的每一列都會藉由一系列的數字和字元來表達,數字代表這個字元被使用多少次。如果數字超過一位數則這個字元重複出現的次數為每一位數相加的總合。在input中小寫的"b"代表空白字元,驚嘆號(!)以及換行都代表結束一列。迷宮的列數並沒有限制,但是每一列不會超過132個字元。Sample Input1T1b5T!1T2b1T 阅读全文
posted @ 2012-06-03 21:31 godjob 阅读(268) 评论(0) 推荐(0) 编辑
摘要:Q490: Rotating Sentences在這個問題中你必須將數列文字往順時針方向旋轉90度。也就是說將原本由左到右,由上到下的句子輸出成由上到下,由右到左。Input and Output輸入最多不會超過100列,每列最多不會超過100個字元。 合法的字元包括:換行,空白,所有的標點符號,數字,以及大小寫字母。(注意:Tabs並不算是合法字元。)最後一列輸入必須垂直輸出在最左邊一行,輸入的第一列必須垂直輸出在最右邊一行。請參考sample intput/output。Sample InputRene Decartes once said,"I thin... 阅读全文
posted @ 2012-06-03 16:45 godjob 阅读(377) 评论(0) 推荐(0) 编辑
摘要:Kindergarten Counting GameEverybody sit down in a circle. Ok. Listen to me carefully.``Woooooo, you scwewy wabbit!''Now, could someone tell me how many words I just said?Input and OutputInput to your program will consist of a series of lines, each line containing multiple words (at least one 阅读全文
posted @ 2012-06-03 16:41 godjob 阅读(354) 评论(0) 推荐(0) 编辑
摘要:3*x^4+6*x^3+2*x^2+5*x+6求值的过程为33*x + 63*x^2 +6*x+23*x^3 +6*x^2+2*x+53*x^4 +6*x^3+2*x^2+5*x+6#include <iostream>#include <stdlib.h>#include <stdio.h>using namespace std;int main(){ printf("多项式求值的Horner算法n"); printf("n说明:对于求多项式3*x^4+6*x^3+2*x^2+5*x+6当x=2 时的值,应该按以下输入n&qu 阅读全文
posted @ 2012-06-03 14:48 godjob 阅读(1033) 评论(0) 推荐(0) 编辑
摘要:在网上看到的一个比较好的The 3n+1 problem,通过中间变量来保存结果集,较少了运算数量 1 #include <iostream> 2 3 #include <vector> 4 5 6 7 #define SIZE 100000 8 9 10 11 using namespace std;12 13 14 15 int Count(vector<int> &viRec, int iNum)16 17 {18 19 int iTemp=iNum, iResult=0;20 21 22 23 if (viRec[iTemp]!=0) ret 阅读全文
posted @ 2012-06-03 14:43 godjob 阅读(215) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示