Codeforces April Fools Day Contest 2020 记录

Codeforces April Fools Day Contest 2020 记录

地址

比赛地址:https://codeforces.com/contest/1331

A Is it rated?

#1 思路

我第一次交的是NO,it isn't.

直接输出NO就好了,大小写没有限制(应该是),多WA几次就好了。

B Limericks

#1 思路

可以看出是一首藏头诗:TWO FACTORS。所以输出两个最大的质因数就可以了。

#2 程序1(C++)

#include<bits/stdc++.h>
using namespace std;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    long long n;
    while (cin>>n)
    {
        for (long long i=n-1;i>=1;i--)
        {
            if (n%i==0)
            {
                cout <<n/i<<i<<'\n';
                break;
            }
        }
    }
    return 0;
}

C ...And after happily lived ever they

#1 思路

and(5) they(4) lived(3) happily(2) ever(1) after(0)
and(5) after(0) happily(2) lived(3) ever(1) they(4)

这题完全被带的,将输入进来的数转换成二进制之后交换0,4位和2,3位之后再转换成十进制输出就可以了。

#2 程序1(C++)

#include<bits/stdc++.h>
using namespace std;
#define INS(x) x.begin(),x.end()
    
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    long long n;
    cin>>n;

    string s(64,'0');
    for(int i=0;n;i++,n>>=1)
        s[i]=(n&1)+'0';
    swap(s[0],s[4]);
    swap(s[2],s[3]);
	reverse(INS(s));
    long long sum=0;
    for(int i=0;i<64;i++)
        sum+=(s[i]&1)?(1<<(63-i)):0;
    cout<<sum<<'\n';
    return 0;
}

D Again?

#1 思路

直接判断最后一个数字的奇偶性就行了,这道题用python写的。

#2 程序1(Python)

s = input()
if int(s[len(s)-1]) % 2:
    print(1)
else:
    print(0)

E Jordan Smiley

#1 思路

写4000行代码的人未免也太强了👍吧。用软件的点子也不错,我觉得是个鬼才。

sb画图题,因为这道题我现学了pythonpillowmatplotlib库🌚。我的策略是用python打表然后用C++来提交。用此法先需安装pillowmatplotlib库。

首先需要对图片进行处理,先把外围的地方全部涂黑,然后就可以打表了。

#2 程序1(Python,C++)

打表代码

from PIL import Image
from pylab import *

im = array(Image.open(
    "1.png"))

i = 7.5
while i < 964:
    print("{", end="")
    j = 7.5
    while j < 964:
        print(im[int(i), int(j), 0], end=",")
        j = j+15.0
    i = i+15.0
    print("},")

提交代码

#include<bits/stdc++.h>
using namespace std;
    
int a[64][64]={{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,0,255,0,255,255,255,255,255,255,0,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,0,255,255,255,0,255,0,255,0,255,0,0,255,0,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,0,255,0,0,0,255,0,0,0,255,255,0,255,0,0,0,0,255,0,0,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,0,255,0,255,0,255,255,255,255,255,0,0,0,0,255,255,255,255,0,255,0,255,255,255,0,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,0,0,0,0,0,0,255,0,255,0,0,0,0,0,255,255,255,255,0,0,0,0,255,0,255,0,255,0,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,0,0,255,255,0,255,255,255,255,255,0,255,255,255,0,255,255,255,0,255,0,0,255,0,255,255,0,0,0,255,0,0,255,0,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
{0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,0,0,255,0,0,255,0,0,0,0,0,0,255,0,255,0,0,0,255,255,255,255,0,0,255,255,0,255,255,0,255,255,0,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,},
{0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,0,255,255,0,255,255,0,255,255,255,0,255,255,255,0,255,255,255,0,0,0,0,255,255,0,0,255,0,0,255,0,0,0,255,255,255,0,0,0,0,0,0,0,0,0,0,0,},
{0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,0,255,0,0,0,0,0,255,0,0,0,255,0,255,255,0,0,255,255,0,255,255,0,255,0,0,255,255,255,0,0,0,0,0,0,0,0,0,0,},
{0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,255,255,255,255,0,0,255,255,255,255,0,0,255,255,255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0,0,},
{0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0,},
{0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,},
{0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,},
{0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,0,0,0,},
{0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,0,0,},
{0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,0,0,},
{0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,0,},
{0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,},
{0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,},
{0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,255,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,255,0,255,0,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,0,0,},
{0,0,255,255,0,0,0,0,0,255,255,255,255,255,255,255,255,255,0,0,255,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0,},
{0,0,255,255,255,255,0,0,0,0,0,255,255,255,255,255,0,0,0,255,255,0,255,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,0,255,255,0,0,255,0,255,255,0,0,0,0,0,0,0,255,255,0,0,},
{0,255,255,255,255,255,255,255,0,0,0,0,0,255,0,0,0,255,255,255,0,0,255,255,255,0,0,255,255,255,255,255,255,255,255,255,255,255,0,255,0,0,255,0,0,0,255,255,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,0,},
{0,255,255,255,255,255,255,255,255,255,0,0,0,0,0,255,0,0,255,0,0,255,255,0,255,255,0,0,0,255,255,255,255,255,255,255,255,255,0,255,255,0,255,255,255,255,255,0,0,255,0,0,0,0,255,255,255,255,255,255,255,255,255,0,},
{0,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,0,255,255,255,0,0,0,0,0,255,255,255,0,0,255,255,255,255,255,255,255,0,0,0,255,0,0,255,0,0,0,0,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,0,},
{0,255,255,255,255,255,255,255,255,255,0,0,0,0,0,255,0,0,0,255,255,255,0,255,255,255,0,0,0,255,255,255,255,255,255,255,255,0,255,0,255,255,255,255,255,0,255,0,0,0,255,0,0,255,0,255,255,255,255,255,255,255,255,0,},
{255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,0,255,0,0,255,0,0,255,0,0,0,255,0,0,255,255,255,255,255,255,0,0,255,0,0,255,0,0,0,0,255,255,0,255,255,255,0,0,0,255,255,255,255,255,255,255,255,255,},
{255,255,255,255,255,255,255,255,255,255,255,0,0,0,255,0,0,255,0,255,255,0,255,255,255,0,255,255,255,0,255,255,255,255,0,255,0,255,255,255,0,255,255,255,255,0,0,255,255,255,0,0,0,255,0,255,255,255,255,255,255,255,255,255,},
{255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,255,255,255,0,255,255,255,255,0,0,0,0,255,0,0,255,0,255,0,0,0,0,255,0,255,0,0,255,0,255,255,255,255,0,0,0,255,255,255,0,255,255,255,255,255,255,255,255,255,},
{255,255,255,255,255,255,255,255,255,255,255,0,0,0,0,0,255,0,0,255,0,0,255,255,255,0,255,255,255,0,0,0,255,0,255,0,255,255,0,255,255,0,255,0,0,255,0,0,0,255,0,0,255,0,0,255,255,255,255,255,255,255,255,255,},
{255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,0,255,255,255,255,0,255,255,0,255,255,255,0,0,0,255,0,255,255,255,0,0,0,0,0,255,255,255,255,0,255,0,255,255,255,255,255,255,0,255,255,255,255,255,255,255,255,255,255,},
{255,255,255,255,255,255,255,255,255,255,255,0,0,0,255,255,255,0,0,255,0,0,255,0,0,0,255,255,255,0,255,0,0,255,255,255,0,255,255,255,255,0,0,255,0,255,255,255,0,0,0,255,0,0,0,255,255,255,255,255,255,255,255,255,},
{255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,0,0,255,255,0,255,255,255,0,255,255,0,255,255,255,0,255,255,0,0,0,0,0,255,0,0,255,255,0,255,255,0,0,255,0,0,0,255,0,255,255,255,255,255,255,255,255,255,},
{255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,0,255,0,0,0,0,255,0,255,0,0,0,0,255,0,255,0,0,255,0,255,0,255,255,0,255,0,0,0,255,255,0,255,255,0,255,255,255,255,255,255,255,255,255,255,255,255,},
{255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,0,255,255,255,255,0,255,0,255,0,255,0,255,0,255,255,255,255,0,255,255,0,255,0,0,255,0,255,255,255,0,0,255,255,255,0,0,0,255,255,255,255,255,255,255,255,255,255,255,},
{255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,0,0,255,0,0,0,255,255,255,0,0,0,255,255,255,255,0,0,0,255,0,0,255,255,0,0,0,0,255,0,0,255,255,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,},
{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,255,255,255,0,0,0,255,0,255,255,0,255,255,0,255,255,0,255,255,0,0,255,0,255,255,255,0,255,0,0,255,0,0,255,255,255,255,255,255,255,255,255,255,255,255,},
{255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,255,0,255,255,255,255,255,255,0,0,0,0,0,255,255,255,255,255,255,255,0,0,0,255,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,},
{0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,255,0,0,0,0,255,255,255,255,255,0,255,0,255,255,255,255,255,255,255,255,255,255,255,0,0,0,255,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,},
{0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,},
{0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,0,0,255,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,},
{0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,},
{0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,255,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,},
{0,0,255,255,255,255,255,255,255,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,},
{0,0,0,255,255,255,255,255,255,255,0,255,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,255,255,255,255,0,0,0,},
{0,0,0,255,255,255,255,255,255,255,0,0,0,255,0,0,0,255,255,255,255,255,255,255,255,255,255,255,0,0,255,0,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,255,255,0,255,0,0,0,0,255,255,255,255,255,255,0,0,0,},
{0,0,0,255,255,255,255,255,255,255,0,255,0,255,0,255,0,0,255,0,255,0,0,0,255,255,0,255,0,255,255,0,0,255,0,255,0,0,255,0,255,255,0,0,0,255,255,0,0,0,0,0,255,0,255,255,255,255,255,255,255,0,0,0,},
{0,0,0,0,255,255,255,255,255,255,255,255,0,0,0,255,255,0,0,0,0,0,255,0,0,0,0,0,0,0,255,255,0,0,0,255,255,0,0,0,0,0,0,255,0,255,0,0,255,255,255,0,255,255,255,255,255,255,255,255,0,0,0,0,},
{0,0,0,0,0,255,255,255,255,255,255,255,0,255,0,0,255,255,255,255,0,255,255,255,255,0,255,255,255,0,0,255,255,255,0,0,0,0,255,255,255,0,255,255,255,255,255,0,255,0,255,255,255,255,255,255,255,255,255,0,0,0,0,0,},
{0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,0,255,0,0,255,0,0,255,0,0,0,255,0,255,255,255,255,0,255,255,255,0,255,255,0,255,0,0,0,0,0,255,0,0,0,255,255,255,255,255,255,255,255,255,0,0,0,0,0,},
{0,0,0,0,0,0,255,255,255,255,255,255,255,255,0,0,0,0,255,255,0,255,255,0,255,0,0,0,0,255,0,0,0,255,0,255,0,0,0,0,255,255,255,0,255,0,0,0,255,255,255,255,255,255,255,255,255,255,0,0,0,0,0,0,},
{0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,0,255,255,0,0,0,255,255,255,255,255,0,255,255,0,255,0,255,0,0,0,255,0,255,255,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,},
{0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,0,0,255,255,255,0,0,255,0,255,0,0,0,255,255,255,0,0,0,255,0,255,255,255,0,0,255,0,0,0,255,255,255,255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,},
{0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,0,0,0,255,255,255,255,0,0,0,255,255,255,0,255,255,0,255,255,255,255,0,255,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0,},
{0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,0,255,255,0,0,0,0,255,0,255,0,0,0,0,0,0,255,0,0,0,0,255,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0,0,},
{0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,0,255,0,255,255,255,255,0,255,255,0,255,255,0,255,0,255,255,0,0,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,},
{0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,0,255,255,255,255,0,0,0,0,255,0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,},
{0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,}, 
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,},};
    
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int r,c;
    cin>>r>>c;

    if (a[r][c]) cout<<"IN\n";
    else cout<<"OUT\n";
    return 0;
}

F Elementary!

#1 思路

注意题目名字,元素周期表,所以我们需要一张元素周期表。于是手动打表:

string ta[]= {"H","HE","LI","BE","B","C","N","O","F","NE","NA","MG","AL","SI","P","S","CL","AR","K","CA","SC","TI","V","CR","MN","FE","CO","NI","CU","ZN","GA","GE","AS","SE","BR","KR","RB","SR","Y","ZR","NB","MO","TC","RU","RH","PD","AG","CD","IN","SN","SB","TE","I","XE","CS","BA","LA","CE","PR","ND","PM","SM","EU","GD","TB","DY","HO","ER","TM","YB","LU","HF","TA","W","RE","OS","IR","PT","AU","HG","TL","PB","BI","PO","AT","RN","FR","RA","AC","TH","PA","U","NP","PU","AM","CM","BK","CF","ES","FM","MD","NO","LR","RF","DB","SG","BH","HS","MT","DS","RG","CN","NH","FL","MC","LV","TS","OG"};

然后题意是问一个字符串是否是由元素周期表中元素组成的,所以只需要dfs就可以了。

#2 程序1(C++)

#include<bits/stdc++.h>
using namespace std;
#define INS(x) x.begin(),x.end()
    
string ta[] = {"H","HE","LI","BE","B","C","N","O","F","NE","NA","MG","AL","SI","P","S","CL","AR","K","CA","SC","TI","V","CR","MN","FE","CO","NI","CU","ZN","GA","GE","AS","SE","BR","KR","RB","SR","Y","ZR","NB","MO","TC","RU","RH","PD","AG","CD","IN","SN","SB","TE","I","XE","CS","BA","LA","CE","PR","ND","PM","SM","EU","GD","TB","DY","HO","ER","TM","YB","LU","HF","TA","W","RE","OS","IR","PT","AU","HG","TL","PB","BI","PO","AT","RN","FR","RA","AC","TH","PA","U","NP","PU","AM","CM","BK","CF","ES","FM","MD","NO","LR","RF","DB","SG","BH","HS","MT","DS","RG","CN","NH","FL","MC","LV","TS","OG"};

set<string> ms;
int l;
string s;
bool flag;

void dfs(int x) 
{
    if (flag)
        return;
    if (x==l) 
        {flag=true; return;}
    string str;
    for (int i=1;i<3;i++) 
    {
        str=s.substr(x,i);
        if (ms.count(str)) dfs(x+i);
    }
}
int main() 
{
    for(int i=0;i<=118;i++) 
        ms.insert(ta[i]);
    cin>>s;

    l=s.size();
    dfs(0);
    
    if (flag) cout<<"YES";
    else cout<<"NO";
    return 0;
}

G Lingua Romana

#1 思路

题目中的红色字体文本是一个由Perl语言写的程序的一部分源代码。你用Perl运行或者直接翻译文本之后就可以知道这是TPK算法,直接写上去即可。

#2 程序1(C++)

#include<bits/stdc++.h>
using namespace std;
 
int main( ) 
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    vector<double> input(11),results(11);
    for (int i=0;i<input.size( );i++ ) 
        cin>>input[i];
 
    transform(input.begin(),input.end( ),results.begin( ),
        [](double n)->double{return sqrt(abs(n))+5*pow(n,3);});
    
    for (int i=10;i>-1;i--)  
    {
        cout<<"f("<<int(input[i])<<") = " ; 
        if (results[i]>400) 
            cout<<"MAGNA NIMIS!" ;
        else 
            cout<<setiosflags(ios::fixed)<<setprecision(2)<<results[i];
        cout<<endl;
    }
    return 0;
}

H It's showtime

#1 思路

参考ArnoldC编程语言即可。


感谢浏览😝!

此文章可能会在后续更新,欢迎纠错。