null
文章目录
  1. A. Is it rated?
    1. 题目描述
    2. 解法
  • B. Limericks
    1. 题目描述
    2. 解法
  • C. And after happily lived ever they
    1. 题目描述
    2. 解法
  • D. Again?
    1. 题目描述
    2. 解法
  • E. Jordan Smiley
    1. 题目描述
    2. 解法
  • F. Elementary!
    1. 题目描述
    2. 解法
  • G. Lingua Romana
    1. 题目描述
    2. 解法
  • H. It’s showtime
    1. 题目描述
    2. 解法
  • CodeForces April Fools Day Contest 2020

    CodeForces 一年一度的愚人节场。

    一场比赛学了两种奇怪的语言,我赚了 CodeForces 亏了

    A. Is it rated?

    题目描述

    一道全空白的题。

    解法

    print('No')

    B. Limericks

    题目描述

    There was once young lass called Mary,  
    Whose jokes were occasionally scary.
    On this April's Fool
    Fixed limerick rules
    Allowed her to trip the unwary.

    Can she fill all the lines
    To work at all times?
    On juggling the words
    Right around two-thirds
    She nearly ran out of rhymes.

    输入一个数,输出一个数。

    解法

    藏头诗,提取首字母可以得到「TWO FACTORS」,结合样例可推测需要将输入分解质因数然后从小到大不加空格输出。

    n = int(input())
    for i in range(2, n):
    if n % i == 0:
    print(str(i) + str(n//i))
    break

    C. And after happily lived ever they

    题目描述

    输入一个数($0\le a \le 63$),输出一个数。

    解法

    题目突破口在 a 的范围($2^6$ 以内)和题目标题。标题经过搜索可知其顺序是乱序,恢复成原序为「and they lived happily ever after」,且标题单词个数刚好也为 6。猜测题目是想让我们将输入的数的二进制重复进行标题的置换方式,将第 2 位和第 6 位互换,将第 3 位和第 4 位互换,最后输出。

    p = [4, 1, 3, 2, 0, 5]
    s = str(bin(int(input())+64))
    print(int(''.join(s[8-p[5-i]] for i in range(6)), 2))

    D. Again?

    题目描述

    给一个类似「Axxxxxx」格式的数,输出一个数。

    解法

    好像是以前愚人节的套路,和 OEIS 无关。实际上对这个十六进制数取模 2 后的值输出就行了。

    print(int(input(),16)%2)

    E. Jordan Smiley

    题目描述

    给一张图和坐标,询问坐标是否在闭合曲线内。

    img

    解法

    简单点的做法就是打开图片编辑工具,将曲线内的色块填充成除了白色以外的其他色,然后再写一个图像处理程序把图片处理成大小为 64*64 的 01 矩阵(Python 可以使用 matplotlib),最后便可以用算出的矩阵进行判断。

    小科普:图像为若当曲线。相关链接:http://www2.oberlin.edu/math/faculty/bosch/making-tspart-page.html

    F. Elementary!

    题目描述

    给一个字符串,输出 Yes 或 No。

    解法

    标题乍一看还以为和美剧《Elementary》有关,但实际上 Elementary 也有和化学元素相关的含义。结合样例判断,如果字符串是可以被分割成由各个元素构成的字符串的话输出 YES,否则输出 NO。

    s = 'H,HE,LI,BE,B,C,N,...,MC,LV,TS,OG'.split(',')
    x = input()
    a = 1
    b = 0
    for i in range(len(x)):
    a, b = x[i] in s and a or x[i-1:i+1] in s and b, a
    print(['NO','YES'][a])

    G. Lingua Romana

    题目描述

    per nextum in unam tum XI conscribementis fac sic
    vestibulo perlegementum da varo.
    morde varo.
    seqis cumula varum.
    cis

    per nextum in unam tum XI conscribementis fac sic
    seqis decumulamenta da varo.
    varum privamentum fodementum da aresulto.
    varum tum III elevamentum tum V multiplicamentum da bresulto.
    aresultum tum bresultum addementum da resulto.

    si CD tum resultum non praestantiam fac sic
    dictum sic f(%d) = %.2f cis tum varum tum resultum egresso describe.
    novumversum egresso scribe.
    cis
    si CD tum resultum praestantiam fac sic
    dictum sic f(%d) = MAGNA NIMIS! cis tum varum egresso describe.
    novumversum egresso scribe.
    cis
    cis

    解法

    题目是用 Perligata 写的程序(拉丁语版的 Perl),任务就是翻译代码,翻译完可知这是 Trabb Pardo–Knuth algorithm。(或者可以尝试插值求得计算公式……)

    t = []
    while True:
    try: x = int(input()); t += [x]
    except: break
    for x in t[::-1]:
    print('f(%d) = %s'%(x, '%.2f'%(5 * x**3 + abs(x)**.5) if x<5 else 'MAGNA NIMIS!'))

    H. It’s showtime

    题目描述

    给一个数 $n=1000\times n+a(1 \le n,a \le 999)$,求 $n!!\pmod a$。

    其中 $n!!=n(n-2)(n-4)\times…4·2$ 或 $n!!=n(n-2)(n-4)\times…3·1$。

    题目要求使用一种未知的语言 UnknownX 完成题目。

    解法

    首先随便提交一个文本,当然啦肯定会编译错误,主要是要看编译错误:

    Can't compile file:
    WHAT THE FUCK DID I DO WRONG:
    Invalid input 'H', expected Root (line 1, pos 1):
    Hello World!
    ^

    结合题目和搜索引擎可以知道这是一种叫做 ArnoldC 的语言,代码非常大白话,具体语法可见于 https://github.com/lhartikk/ArnoldC。

    IT'S SHOWTIME
    // begin

    HEY CHRISTMAS TREE a
    YOU SET US UP 0
    HEY CHRISTMAS TREE b
    YOU SET US UP 0
    HEY CHRISTMAS TREE c
    YOU SET US UP 0
    HEY CHRISTMAS TREE d
    YOU SET US UP 0
    HEY CHRISTMAS TREE e
    YOU SET US UP 0
    HEY CHRISTMAS TREE f
    YOU SET US UP 1
    # a = b = c = d = e = 0, f = 1

    GET YOUR ASS TO MARS a
    DO IT NOW
    I WANT TO ASK YOU A BUNCH OF QUESTIONS AND I WANT TO HAVE THEM ANSWERED IMMEDIATELY
    # a = read()

    GET TO THE CHOPPER b
    HERE IS MY INVITATION a
    HE HAD TO SPLIT 1000
    ENOUGH TALK
    # b = a // 1000

    GET TO THE CHOPPER c
    HERE IS MY INVITATION b
    YOU'RE FIRED 1000
    ENOUGH TALK
    # c = b * 1000

    GET TO THE CHOPPER a
    HERE IS MY INVITATION a
    GET DOWN c
    ENOUGH TALK
    # a = a - c
    # a, b = a % 1000, a // 1000

    HEY CHRISTMAS TREE isGreetThan0
    YOU SET US UP @NO PROBLEMO
    # isGreetThan0 = True

    HEY CHRISTMAS TREE n
    YOU SET US UP b
    # n = b

    STICK AROUND isGreetThan0
    # while isGreetThan0 is True

    GET TO THE CHOPPER e
    HERE IS MY INVITATION f
    YOU'RE FIRED n
    ENOUGH TALK
    # e = f * n

    GET TO THE CHOPPER d
    HERE IS MY INVITATION e
    HE HAD TO SPLIT a
    ENOUGH TALK
    # e = e // a

    GET TO THE CHOPPER c
    HERE IS MY INVITATION d
    YOU'RE FIRED a
    ENOUGH TALK
    # c = d * a

    GET TO THE CHOPPER f
    HERE IS MY INVITATION e
    GET DOWN c
    ENOUGH TALK
    # f = e - c
    # f = f * n % a

    GET TO THE CHOPPER n
    HERE IS MY INVITATION n
    GET DOWN 2
    ENOUGH TALK
    # n -= 2

    GET TO THE CHOPPER isGreetThan0
    HERE IS MY INVITATION n
    LET OFF SOME STEAM BENNET 0
    ENOUGH TALK
    # isGreetThan0 = n > 0

    CHILL
    # end while

    TALK TO THE HAND f
    # output(f)

    YOU HAVE BEEN TERMINATED
    # end
    支持一下
    资助 Nano 让 Nano 吃得更胖!
    • 微信扫一扫
    • 支付宝扫一扫