本文主要是介绍UVA-644 Immediate Decodability,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
原题链接:
https://vjudge.net/problem/UVA-644
AC代码:
#include <bits/stdc++.h>
using namespace std;int main()
{string a[26];int t = 0;int flag = 0;int cases = 1;while (getline(cin, a[t])){if (a[t][0] == '9'){for (int i = 0; i < t; i++){for (int j = 0; j < t; j++){if (i == j)continue;int len = min(a[i].length(), a[j].length());int cnt = 0;for (int k = 0; k < len; k++){if (a[i][k] == a[j][k]){cnt++;}elsebreak;}if (cnt == len){flag = 1;}}}if (flag)cout << "Set " << cases << " is not immediately decodable" << endl;elsecout << "Set " << cases << " is immediately decodable" << endl;cases++;t = 0;flag = 0;}elset++;}return 0;
}
直接暴力
这篇关于UVA-644 Immediate Decodability的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!