Safecracker 素颜马尾好姑娘i 2022-06-12 02:45 123阅读 0赞 === Op tech briefing, 2002/11/02 06:42 CST === "The item is locked in a Klein safe behind a painting in the second-floor library. Klein safes are extremely rare; most of them, along with Klein and his factory, were destroyed in World War II. Fortunately old Brumbaugh from research knew Klein's secrets and wrote them down before he died. A Klein safe has two distinguishing features: a combination lock that uses letters instead of numbers, and an engraved quotation on the door. A Klein quotation always contains between five and twelve distinct uppercase letters, usually at the beginning of sentences, and mentions one or more numbers. Five of the uppercase letters form the combination that opens the safe. By combining the digits from all the numbers in the appropriate way you get a numeric target. (The details of constructing the target number are classified.) To find the combination you must select five letters v, w, x, y, and z that satisfy the following equation, where each letter is replaced by its ordinal position in the alphabet (A=1, B=2, ..., Z=26). The combination is then vwxyz. If there is more than one solution then the combination is the one that is lexicographically greatest, i.e., the one that would appear last in a dictionary." v - w^2 + x^3 - y^4 + z^5 = target "For example, given target 1 and letter set ABCDEFGHIJKL, one possible solution is FIECB, since 6 - 9^2 + 5^3 - 3^4 + 2^5 = 1. There are actually several solutions in this case, and the combination turns out to be LKEBA. Klein thought it was safe to encode the combination within the engraving, because it could take months of effort to try all the possibilities even if you knew the secret. But of course computers didn't exist then." === Op tech directive, computer division, 2002/11/02 12:30 CST === "Develop a program to find Klein combinations in preparation for field deployment. Use standard test methodology as per departmental regulations. Input consists of one or more lines containing a positive integer target less than twelve million, a space, then at least five and at most twelve distinct uppercase letters. The last line will contain a target of zero and the letters END; this signals the end of the input. For each line output the Klein combination, break ties with lexicographic order, or 'no solution' if there is no correct combination. Use the exact format shown below." Input 1 ABCDEFGHIJKL 11700519 ZAYEXIWOVU 3072997 SOUGHT 1234567 THEQUICKFROG 0 END Output LKEBA YOXUZ GHOST no solution Sample Input 1 ABCDEFGHIJKL 11700519 ZAYEXIWOVU 3072997 SOUGHT 1234567 THEQUICKFROG 0 END Sample Output LKEBA YOXUZ GHOST no solution 题意:一个数字n 和一串只含有大写字母的字符串;求出满足题目给出的等式的字符串组合,要求输出字典序最大的那个组合 #include<cstdio> #include<iostream> #include<cstring> #include<algorithm> using namespace std; int cmp(char str1,char str2) { return str1>str2; } int main() { int n; char str[13]; while(~scanf("%d %s",&n,str),(n||strcmp(str,"END")!=0)) { int ok=0; int len=strlen(str); sort(str,str+len,cmp); for(int i=0; i<len; i++) { for(int j=0; j<len; j++) { if(str[i]==str[j]) continue; for(int k=0; k<len; k++) { if(str[i]==str[j]||str[j]==str[k]) continue; for(int l=0; l<len; l++) { if(str[i]==str[j]||str[j]==str[k]||str[k]==str[l]) continue; for(int h=0; h<len; h++) { if(str[i]==str[j]||str[j]==str[k]||str[k]==str[l]||str[l]==str[h]) continue; int v=str[i]-64; int w=str[j]-64; int x=str[k]-64; int y=str[l]-64; int z=str[h]-64; if(v-w*w+x*x*x-y*y*y*y+z*z*z*z*z==n) { printf("%c%c%c%c%c\n",str[i],str[j],str[k],str[l],str[h]); ok=1; break; } } if(ok) break; } if(ok) break; } if(ok) break; } if(ok) break; } if(!ok) printf("no solution\n"); } return 0; }
相关 杭电-1015Safecracker(DFS) Safecracker Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/ 电玩女神/ 2022年08月09日 14:51/ 0 赞/ 112 阅读
相关 Safecracker === Op tech briefing, 2002/11/02 06:42 CST === "The item is locked in a Klein safe be 素颜马尾好姑娘i/ 2022年06月12日 02:45/ 0 赞/ 124 阅读
相关 HDU1015 Safecracker Problem Description "The item is locked in a Klein safe behind a painting in the second 「爱情、让人受尽委屈。」/ 2022年06月09日 13:11/ 0 赞/ 139 阅读
相关 HDU 1015 Safecracker (DFS) //题意自己看,不会度娘 include <iostream> include <cstdio> include <cstring> àì夳堔傛蜴生んèń/ 2022年06月08日 14:38/ 0 赞/ 135 阅读
相关 Safecracker Safecracker Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/ 谁借莪1个温暖的怀抱¢/ 2022年05月16日 14:04/ 0 赞/ 171 阅读
相关 HDU 1015 Safecracker 原题目链接:[HDU1015][] -------------------- 分类: HDU 暴力 回溯 DFS -------------------- 男娘i/ 2022年04月16日 05:55/ 0 赞/ 150 阅读
相关 Safecracker hdu 1015 Safecracker Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Ja Dear 丶/ 2021年10月15日 11:55/ 0 赞/ 218 阅读
还没有评论,来说两句吧...