HUNNU11354:Is the Name of This Problem

32 篇文章 1 订阅

http://acm.hunnu.edu.cn/online/?action=problem&type=show&id=11354&courseid=0

Problem description

  The philosopher Willard Van Orman Quine (1908–2000) described a novel method of constructing a sentence in order to illustrate the contradictions that can arise from self-reference. This operation takes as input a single phrase and produces a sentence from that phrase. (The author Douglas R. Hofstadter refers to this process as to Quine a phrase.) We can define the Quine operation like so:

Quine(A) = "A" A

In other words, if A is a phrase, then Quine(A) is A enclosed in quotes ("), followed by a space, followed by A. For example:

Quine(HELLO WORLD) = "HELLO WORLD" HELLO WORLD

Below are some other examples of sentences that can be created by the Quine operation. Note that Quining allows sentences to be indirectly self-referential, such as the last sentence below.

"IS A SENTENCE FRAGMENT" IS A SENTENCE FRAGMENT"IS THE NAME OF THIS PROBLEM" IS THE NAME OF THIS PROBLEM"YIELDS FALSEHOOD WHEN QUINED" YIELDS FALSEHOOD WHEN QUINED

Your goal for this problem is to take a sentence and decide whether the sentence is the result of a Quine operation.

Input

  The input will consist of a sequence of sentences, one sentence per line, ending with a line that has the single word, END. Each sentence will contain only uppercase letters, spaces, and quotation marks. Each sentence will contain between 1 and 80 characters and will not have any leading, trailing, or consecutive spaces.

You must decide whether each sentence is the result of a Quine operation. To be a Quine, a sentence must match the following pattern exactly:

  1. A quotation mark
  2. Any nonempty sequence of letters and spaces (call this phrase A)
  3. A quotation mark
  4. A space
  5. Phrase A—exactly as it appeared in (2)

If it matches this pattern, the sentence is a Quine of the phrase A. Note that phrase A must contain the exact same sequence of characters both times it appears.

Output

  There will be one line of output for each sentence in the data set. If the sentence is the result of a Quine operation, your output should be of the form, Quine(A), where A is the phrase to Quine to create the sentence.

If the sentence is not the result of a Quine operation, your output should be the phrase, not a quine.

Sample Input

"HELLO WORLD" HELLO WORLD"IS A SENTENCE FRAGMENT" IS A SENTENCE FRAGMENT"IS THE NAME OF THIS PROBLEM" IS THE NAME OF THIS PROBLEM"YIELDS FALSEHOOD WHEN QUINED" YIELDS FALSEHOOD WHEN QUINED"HELLO" I SAIDWHAT ABOUT "WHAT ABOUT"" NO EXTRA SPACES " NO EXTRA SPACES"NO"QUOTES" NO"QUOTES""END

Sample Output

Quine(HELLO WORLD)Quine(IS A SENTENCE FRAGMENT)Quine(IS THE NAME OF THIS PROBLEM)Quine(YIELDS FALSEHOOD WHEN QUINED)not a quinenot a quinenot a quinenot a quinenot a quine

Judge Tips

  A review of quotation marks in strings:  As a reminder, the quotation mark character is a regular character, and can be referred to in C, C++, and Java using the standard single-quote notation, like so:

'"'

However, to place a quotation mark inside a double-quoted string in C, C++, and Java, you must place a backslash (\) in front of it. If you do not it will be interpreted as the end of the string, causing syntax errors. For example:

"This quotation mark \" is inside the string""\"""\"SAID SHE\" SAID SHE"

 

题意:给出一个字符串,符合"A"A的状况输出Quine(A),否则输出not a quine

思路:首先从左到右找出第一对双引号里的字符串,然后从右到左找出一个双引号后面的字符串,处理好好比较即可

 

#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;

char s1[10005],s2[10005];
char str[20005];

int main()
{
    int len,i,l1,l2;
    while(gets(str))
    {
        if(!strcmp(str,"END"))
            break;
        len = strlen(str);
        l1 = l2 = 0;
        if(str[0] != '"')//第一个必须为“
        {
            printf("not a quine\n");
            continue;
        }
        for(i = 1; i<len; i++)//找到第一对引号内的字符串
        {
            if(str[i]!=34)
                s1[l1++] = str[i];
            else
            {
                s1[l1] = '"';
                break;
            }
        }
        for(i = len-1; i>=0; i--)//从后面开始找到第一个引号出现的位置为止
        {
            if(str[i] == ' ' && str[i-1] == '"')
            {
                s2[l2] = '\0';
                break;
            }
            else
                s2[l2++] = str[i];
        }
        char tem;
        for(i = 0; i<l2/2; i++)//翻转字符串
        {
            tem = s2[l2-1-i];
            s2[l2-1-i] = s2[i];
            s2[i] = tem;
        }
        if(!strcmp(s1,s2))
            printf("Quine(%s)\n",s1);
        else
            printf("not a quine\n");
    }


    return 0;
}


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
if __name__ == '__main__': # -------------Adjustable global parameters---------- n=512 # pixel number m=10 # number of time phases angle = 5 # #sample points = 360/angle on the boundary numOfAngles = int(180/angle) numOfContourPts = int(360/angle) labelID = 1 # 勾画的RS文件中第几个轮廓为GTV # path of the input data folder = 'E:\\MedData\\4DCT-202305\\' #patient = '0007921948' # 缺少时间信息 patient = '0000726380' # 病人的编号 # 呼吸曲线数据文件 vxpPath = folder+patient+'\\0000726380\\0000726380_20230420_143723.vxp' # Save the generated figures to the latex file path figPath = "D:\\HUNNU\\Research\\DMD\\4D-CT\\latex-DMD插值\\modify202305\\figure\\" # -------------Auto generated global parameters---------- # 每个dicom文件包含多少横截面 name = os.listdir(folder+patient+'\\0') cuts = [] for i in range(len(name)): if 'CT' in name[i][0:2]: cuts.append(i+1) cuts = np.array(cuts) # phase name times = np.linspace(0,90,10) # image pixel coordinate nums = np.linspace(0,n-1,n) x,y = np.meshgrid(nums,nums) # 输出dicom头文件信息 filename = folder+patient+'\\0\\CT.{}'.format(patient)+'.Image 1.dcm' print('CT dicom file information:') info = loadFileInformation(filename) # 像素之间的间距,包括列间距和行间距,单位mm SliceThickness = info['SliceThickness'] # Z轴的扫描分辨率,单位mm pixelSpace = info['pixelSpace'] # 一个像素所占的实际体积 pixelVol = float(pixelSpace[0])*float(pixelSpace[0])*float(SliceThickness) print('sliceThickness=',SliceThickness,' pixelSpace=',pixelSpace)
最新发布
06-02
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值