码迷,mamicode.com
首页 > 其他好文 > 详细

Secret Research UVA 621

时间:2014-08-07 15:41:30      阅读:333      评论:0      收藏:0      [点我收藏+]

标签:acm   c   uva   源代码   算法   

说说:这道题非常之坑!开始还以为要递归判断的,其实根本不用,只要判断第一层的S即可,其中内嵌的S肯定是正确的。居然还有这样的题目,真的很无语╮(╯_╰)╭


题目:

Secret Research

At a certain laboratory results of secret research are thoroughly encrypted. A result of a single experiment is stored as an information of

实验室关于一些秘密研究成果都是进行完全加密的。实验的结果按照它的完成情况分为:

 its completion:


`positive result‘, `negative result‘, `experiment failed‘ or `experiment not completed‘

‘积极结果’,‘消极结果’,‘实验失败’,‘实验未完成’


The encrypted result constitutes a string of digits S, which may take one of the following forms:

加密的结果组成了一个数字串S,它将采用以下的某种形式

bubuko.com,布布扣 positive result 		 S = 1 or S = 4 or S = 78 bubuko.com,布布扣 negative result 		 S = S35 bubuko.com,布布扣 experiment failed 		 S = 9S4 bubuko.com,布布扣 experiment not completed 		 S = 190S 


(A sample result S35 means that if we add digits 35 from the right hand side to a digit sequence then we shall get the digit sequence corresponding to a failed experiment)

(如结果S35意思是如果我们把数字35加到一个数字串的右边那么这就是个消极结果(译:原文为实验失败,我认为有误))


You are to write a program which decrypts given sequences of digits.

你需要写一个程序对数字串进行解密

Input 

A integer n stating the number of encrypted results and then consecutive n lines, each containing a sequence of digits given as ASCII strings.

整数n代表加密结果的数目,接下来的连续的n行,每行都是用ASCII码表示的数字串

Output 

For each analysed sequence of digits the following lines should be sent to output (in separate lines):

分析完数字串后需要输出结果,且一行一个结果

+ for a positive result - for a negative result * for a failed experiment ? for a not completed experiment 

In case the analysed string does not determine the experiment result, a first match from the above list should be outputted.

万一数字串并为决定实验结果,输出上表中第一个匹配的项。

Sample Input 

4
78
7835
19078
944

Sample Output 

+
-
?
*

源代码:

#include <stdio.h>
#include <string.h>

int main(){
 int N,len;
 char S[1000];
 //freopen("data.txt","r",stdin);
 scanf("%d",&N);

 while(N--){
    scanf("%s",S);
    len=strlen(S);
    if(len<=2){//是否为positive
        printf("+\n");
        continue;
    }
    if(S[0]=='9'&&S[len-1]=='4'){//是否为failed
        printf("*\n");
        continue;
    }
    if(S[len-1]=='5'){//是否为negative
        printf("-\n");
        continue;
    }
    printf("?\n");
 }
 return 0;
}


Secret Research UVA 621,布布扣,bubuko.com

Secret Research UVA 621

标签:acm   c   uva   源代码   算法   

原文地址:http://blog.csdn.net/u011915301/article/details/38406469

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!