随笔分类 -  acm

uva 424 - Integer Inquiry
摘要:这是一题大数相加,如果大数相加一定要用数组做。这里提供一段用两个数组进行相加的算法,是刘汝佳老师编写,s1,s2都是反转过的数组,比如大数为123456789,那数组从0-8的应该是 987654321string ssum(string s1,string s2){ char c[100]; int len=0; int temp=MAX(s1.size(),s2.size()); for(int i=0,g=0;g||i#includeusing namespace std;#define MAX(X,Y) ((X)<(Y))?(Y):(X)void revers... 阅读全文

posted @ 2013-12-18 20:46 云在心 阅读(173) 评论(0) 推荐(0)

uva 10115 - Automatic Editing
摘要:这题很简单,就是不停搜索#include#include#includeusing namespace std;int main(){ int n; string words[15],reword[15],l; while(cin>>n){ getchar(); if(n==0) break; for(int i=0;i=0){ l.replace(start,words[i].size(),reword[i]) } } cout<<... 阅读全文

posted @ 2013-12-16 15:22 云在心 阅读(102) 评论(0) 推荐(0)

uva 644 - Immediate Decodability
摘要:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=585可以学习哈弗曼编码,以及二叉树编码,就知道怎么是immediately code#include#includeusing namespace std;int main(){ string code[5000],l; int num=0,temp=0,numNine=0; while(getline(cin,l)){ if(l[0]=='9'){ ... 阅读全文

posted @ 2013-12-16 13:54 云在心 阅读(156) 评论(0) 推荐(0)

uva 10815 - Andy's First Dictionary
摘要:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1756好简单的一道题,居然一直runtime erro,么办法咯 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 vector words; 8 int main(){ 9 string l;10 vector::iterator it;11 while(getline( 阅读全文

posted @ 2013-12-10 21:21 云在心 阅读(143) 评论(0) 推荐(0)

uva 10878 - Decode the tape
摘要:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1819这题很简单,就是一个ascii转换,不过代码写的好丑啊,buff数组开大点,他没说上限多少行,还是要注意的。 1 #include 2 #include 3 #include 4 using namespace std; 5 void string_replace(string &src){ 6 for(int i=0;i<src.size();i++){ 7 阅读全文

posted @ 2013-12-09 20:55 云在心 阅读(169) 评论(0) 推荐(0)

uva 409 - Excuses, Excuses!
摘要:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=350这题没什么难度,一定要注意的地方是单词的判断,比如搜索单词word ,如果出现dword是不算的。这题一次性ac#include#include#includeusing namespace std;void convert(int len,string src[],string dis[]){ //拷贝到复制数组进行大小写转换 for(int i=0;i>k>&g 阅读全文

posted @ 2013-12-09 15:53 云在心 阅读(142) 评论(0) 推荐(0)

uva 537 - Artificial Intelligence?
摘要:这题看题目时要细心,讲一下做题步骤1.得到 P,I,U的double值,可以用string类型中搜索法2.确定精度3.得到目标值因为在输出时忘记打印P=,U=,I=,还wa了一次#include#include#include#include#includeusing namespace std;int main(){ int n,num=1; string annotation[]={"P=","I=","U="}; string character[]={"W","A","V&qu 阅读全文

posted @ 2013-12-09 11:00 云在心 阅读(204) 评论(0) 推荐(0)

uva 10361 - Automatic Poetry
摘要:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1302这次又是没有通过,wawawawawawa,我要疯了,完全不知道错在哪里,感觉应该要把错误的测试数据告诉我们啊#include#include#includeusing namespace std;int main(){ int n; cin>>n; getchar(); string l1,l2; while(n--){ int start,end; ... 阅读全文

posted @ 2013-11-28 21:32 云在心 阅读(153) 评论(0) 推荐(0)

uva 10010 - Where's Waldorf?
摘要:题目地址http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=951这题并不是很难,要在8个方向上做判断,纯属量的问题,做了很多次测试,一直wa,不知道为什么,哎!#include#includeusing namespace std;int m,n;void searchWordlof(string a[],string s){ int x=51,y=51; for(int i=0;i=s.size()&&revtem 阅读全文

posted @ 2013-11-27 19:22 云在心 阅读(196) 评论(0) 推荐(0)

Uva 401 - Palindromes
摘要:题目地址http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=&problem=342&mosmsg=Submission+received+with+ID+虽然把代码写完了,也做了很多测试,还是wa,很心痛,有人能帮我看看代码错哪里吗#include#includeusing namespace std;char ref[100];void Init(){ ref['A']='A'; 阅读全文

posted @ 2013-11-26 21:23 云在心 阅读(193) 评论(1) 推荐(0)

uva start
摘要:最近在看刘汝佳写的《算法竞赛入门经典》做题网址http://uva.onlinejudge.org/index.php 阅读全文

posted @ 2013-11-26 21:00 云在心 阅读(145) 评论(0) 推荐(0)

导航