2012年10月22日

UVA112-Tree Summing

摘要: 二叉树的第一题,看大神的代码,学到了许多。理解以后。自己又写了一遍;代码如下:#include using namespace std; bool ScanfTree(int sum,int nDest, bool *pNull) { int d; char ch; bool br = false, bNull1 = false, bNull2 = false;//br用于递归子节点的计算结果,bNull表示左右子是否为空 cin>>ch; if(!(*pNull = ((cin>>d) == 0))){//如果读入成功 sum+=d;... 阅读全文
posted @ 2012-10-22 07:16 Primo... 阅读(141) 评论(0) 推荐(0)
2012年8月25日

uva 工具网站 顶 顶!!!

摘要: UVa Online Judge工具網站 转自http://www.csie.ntnu.edu.tw/~u91029/uva.htmlLucky貓的ACM園地,Lucky貓的 ACM 中譯題目 Mirror這個站專門提供UVa Online Judge中譯題目。非常棒!非常棒!非常棒!我在搜尋引擎輸入過上百次的Luckycat!UVa Online Judge: Electronic BoardUVa Online Judge的問題討論版。由於主頁上沒有放連結,所以可能有人不知道。發問時請遵守板規,善用搜尋功能,找到問題的討論串,發問時採用回覆文章方式。讓後人可以容易找到相關討論。UVA to 阅读全文
posted @ 2012-08-25 09:33 Primo... 阅读(196) 评论(0) 推荐(0)
2012年8月24日

uva10050-罢工

摘要: #include #include using namespace std; int main () { int a[4000], count, b, t, n, p; cin>>t; while(t--) { count = 0; memset(a,0,sizeof(a)); cin>>n>>p; for(int i = 0; i >b; for(int j = b; j <= n; j+=b) a[j] = 1; } ... 阅读全文
posted @ 2012-08-24 13:31 Primo... 阅读(129) 评论(0) 推荐(0)
2012年8月23日

UVA11111-一般Matrioshka

摘要: 这个题开始的时候是一点思路也没有,后来按照自己不成熟的思路写,总是写了删,删了再写。浪费时间不说,还大大打击了我的自信心。后来想到了递归,比较符合这个题的思路。每个玩偶用一个递归中的一步来表示,层层递进,正好符合题意说的玩偶层层相包,思路酝酿成熟了,再写代码,就比较顺手。但是我还是wa了一遍。我把这个题想的太简单了。考虑的不全面,例如:每行输入可以包含多个最大的玩偶的情况我就给忽略了测试样例为-9 -7 7 -9 9 -9 :::结果是“:-) Matrioshka!”;代码如下:#include using namespace std; int flag2; int stack (in... 阅读全文
posted @ 2012-08-23 14:00 Primo... 阅读(153) 评论(0) 推荐(0)
2012年8月21日

hdu4119-Isabella's Message

摘要: 这个题是我水出来的,水了一天才水出来的,代码有点乱。思路:1,读矩阵,2,从不同方向四种翻转,每种翻转翻三个90°3,读入m个单词4,找出不合要求的情况做好标记5,输出字典序最小的 明文代码如下:(由于变量很多,命名命的我头都大了,所以有点乱)#include #include #include #include using namespace std; const int N = 55; char a[N][N], b[N][N]; string word[4][105]; string s[4], s2[105]; void trans (int n) { char c[... 阅读全文
posted @ 2012-08-21 13:43 Primo... 阅读(141) 评论(0) 推荐(0)

UVA10115-自动编辑

摘要: 01.#include 02.#include 03. 04.using namespace std; 05. 06.int main () 07.{ 08. int n; 09. while(cin>>n&&n) 10. { 11. cin.get(); 12. string s[n],t[n]; 13. for(int i = 0; i "<<t[j]<<endl; 38. st.replace(i,l,t[j]); 39. ... 阅读全文
posted @ 2012-08-21 10:24 Primo... 阅读(155) 评论(0) 推荐(0)

URAL1102

摘要: 此题最佳算法是倒着做,正着做太麻烦,反例inputon,倒着做更好做一些,01.#include 02.#include 03.using namespace std; 04.int main () 05.{ 06. int n; 07. cin>>n; 08. while(n) 09. { 10. string s; 11. cin>>s; 12. int flag = 1; 13. for(int i = (int)s.size()-1; flag&&i >=0 ; i--) ... 阅读全文
posted @ 2012-08-21 10:23 Primo... 阅读(130) 评论(0) 推荐(0)

UVA575-斜二进制

摘要: #include #include #include using namespace std;int main (){ string s; while(getline(cin,s)) { if(s.size()== 1&&s[0] == '0')break; long long int sum = 0; for(int i = s.size()-1; i >= 0; i--) { sum+=(s[i]-'0')*(pow(2,s.size()-i)-1); } cout<... 阅读全文
posted @ 2012-08-21 10:22 Primo... 阅读(129) 评论(0) 推荐(0)

UVA755- 487-3279

摘要: 对于这个题,花费的时间也不少。错误一;由于考虑不全1400U--4N712---X2-KN-U-75VR-J37G--385W-0Y6-V85W-0Y6-V85W-0Y6-V--N-6AV4-NK--XL----F-PO--B-0-P-10167P7--R8YME-NP-U-1O6W-----1X-KFK87--LYFX63K-N-3-73G---ELH--2RD-6-IJ-YP2--SJ9G9P2--SJ9G9O-1----2287-2-DC-C1L-3V7963V68U-66X52MU-66X52M-8-16F5TG---YN-32E5-K---YN-32E5-K4--KDJ-PV24-- 阅读全文
posted @ 2012-08-21 10:21 Primo... 阅读(166) 评论(0) 推荐(0)

UVA673-括号平衡

摘要: #include #include using namespace std;struct point{ char ch; point *next;};int main (){ int n, len, flag = 0, flag2 = 0; string s; cin>>n; cin.get(); while(n--) { point *p, *q, *head, *bridge; getline(cin,s); if(!s.size()) { coutch = s[i... 阅读全文
posted @ 2012-08-21 10:21 Primo... 阅读(111) 评论(0) 推荐(0)