摘要:
题目说每个相同文件(01串)都被撕裂成两部分,要求拼凑成原来的样子,如果有多种可能输出一种。我标题写着排列组合,其实不是什么高深的数学题,只要把最长的那几个和最短的那几个凑一起,然后去用其他几个验证就行了,反正我的验证是非常暴力的,看起来。。。(其实加了个二维数组判定不是很吃复杂度)代码:#include #include #include #include #include using namespace std;
const int maxn = 150; string p[maxn];
int n, cnt, min, max;
bool flag, used[maxn];
... 阅读全文
摘要:
中文意思不解释。很水,我本来想用switch处理字符串,然后编译不通过。。。原来switch只能处理整数型的啊,我都忘了。然后就有了很挫的一大串if代码了。。。代码:#include #include using namespace std; int digit(string str) { if (str == "zero") return 0; if (str == "one") return 1; if (str == "two") return 2; if (str == "three") return 3; 阅读全文
摘要:
这题是从某个群里听别人在抱怨这题老是PE,打开status果然满眼的Presentation Error。。。于是闲着来做了一下。其实挺水的,不过各种设定多一点,注意一点就行了。一开始以为词数超过80个才换行,原来是字符数。。。样例过了之后提交了结果也PE了。。。于是随便弄了一下输入,胡乱复制,然后输出到文件里面检查,发现了各种字数超过80,原来还是有些细节没处理好。于是又修改了几个地方终于A掉了。这题的确有点恶心,考的是细节问题。代码:#include #include #include using namespace std;
int cnt = 0, ch = 0; void l... 阅读全文
摘要:
题意:給定兩個小寫的字串a與b,請印出皆出現在兩字串中的字母,出現的字母由a~z的順序印出,若同字母出現不只一次,請重複印出但不能超過任一字串中出現的次數。(from Ruby兔)很水,直接比较输出即可。代码:#include #include #include using namespace std;
const int maxn = 1001; int main() { char a[maxn], b[maxn]; while (gets(a) != NULL && gets(b) != NULL) { sort (a, a + strlen(a)); sort (b,.. 阅读全文