标签:
#include<iostream> #include<cctype> #include<cstdlib> #include<cstdio> #include<cstring> using namespace std; char codes[9][12]; int k = 1,num; bool solve(){ for(int i = 0; i < num; i++){ for(int j = 0; j < num; j++){ int flag = 1; if(j!=i && strlen(codes[j]) > strlen(codes[i])){ for(int k = 0; k < strlen(codes[i]); k++) if(codes[i][k] != codes[j][k]) flag = 0; if(flag) return false; } } } return true; } int main(){ num = 0; while(cin >> codes[num]){ if(codes[num][0] == ‘9‘){ if(solve()) cout << "Set " << k++ << " is immediately decodable" << endl; else cout << "Set " << k++ << " is not immediately decodable" << endl; num = 0; }else num++; } return 0; }
uva 644 - Immediate Decodability
标签:
原文地址:http://www.cnblogs.com/yong-hua/p/4652330.html