Home | Problems | Status | Contest | Register | Login |
B题要套一个数论的模版,注意m=1!! C题可以二分匹配,把行列看作点; 不能开百度,开谷歌搜题解,再次强调!一经发现,取消成绩!
ECJTU_ACM 11级队员2012年暑假训练赛(8)
4:30:00
FAQ | About Virtual Judge | Forum | Discuss | Open Source Project
All Copyright Reserved ©2010-2012 HUST ACM/ICPC TEAM
Anything about the OJ, please ask in the forum, or contact author: Isun
Server Time: 2012-08-13 10:55:21
1 // Project name : J ( Word Problem ) 2 // File name : main.cpp 3 // Author : iCoding 4 // E-mail : honi.linux@gmail.com 5 // Date & Time : Fri Aug 10 12:32:18 2012 6 7 8 #include <iostream> 9 #include <stdio.h> 10 #include <string> 11 #include <cmath> 12 #include <algorithm> 13 using namespace std; 14 15 /*************************************************************************************/ 16 /* data */ 17 18 #ifndef MAXN 19 #define MAXN 100 20 #endif 21 22 string iList[MAXN]; 23 int iTop; 24 25 string s; 26 int sTop; 27 28 char s_tmp[MAXN]; 29 int s_tmp_top; 30 /*************************************************************************************/ 31 /* procedure */ 32 33 void iShowList() 34 { 35 for (int i = 0; i <= iTop; i++) 36 { 37 cout << iList[i] << endl; 38 } 39 } 40 41 void iInit() 42 { 43 iTop = -1; 44 45 sTop = s.length() - 1; 46 if ((s[sTop] >= 'a' && s[sTop] <= 'z') || (s[sTop] >= 'A' && s[sTop] <= 'Z')) 47 { 48 sTop++; 49 s[sTop] = '_'; 50 } 51 } 52 53 void iInitTmp() 54 { 55 for (int i = 0; i < MAXN; i++) 56 { 57 s_tmp[i] = '\0'; 58 } 59 s_tmp_top = -1; 60 } 61 62 void iCal() 63 { 64 iInitTmp(); 65 bool hasword = false; 66 67 for (int i = 0; i <= sTop; i++) 68 { 69 if ((s[i] >= 'a' && s[i] <= 'z') || (s[i] >= 'A' && s[i] <= 'Z')) 70 { 71 s_tmp_top++; 72 s_tmp[s_tmp_top] = s[i]; 73 hasword = true; 74 //cout << s[i] << endl; 75 } 76 else 77 { 78 if (hasword) 79 { 80 // go search 81 string sss = s_tmp; 82 bool iFound = false; 83 for (int i = 0; !iFound && i <= iTop; i++) 84 { 85 if (iList[i] == sss) 86 { 87 iFound = true; 88 } 89 } 90 if (!iFound) 91 { 92 iTop++; 93 iList[iTop] = sss; 94 } 95 iInitTmp(); 96 hasword = false; 97 } 98 99 } 100 } 101 } 102 103 /*************************************************************************************/ 104 /* main */ 105 int main() 106 { 107 while (cin >> s) 108 { 109 iInit(); 110 iCal(); 111 iShowList(); 112 } 113 return 0; 114 } 115 116 // end 117 // Code by Sublime text 2 118 // iCoding@CodeLab