“蔚来杯“2022牛客暑期多校训练营6,签到题GJBMA

Posted 小哈里

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了“蔚来杯“2022牛客暑期多校训练营6,签到题GJBMA相关的知识,希望对你有一定的参考价值。

题号 标题 已通过代码 通过率 团队的状态
A Array 点击查看 388/4063
B Eezie and Pie 点击查看 1042/2840
C Forest 点击查看 38/144 未通过
D Fourier and Theory for the Universe 点击查看 11/61
E From AtCoder 点击查看 6/47
F Hash 点击查看 31/264
G Icon Design 点击查看 1499/1873
H Jumping Steps 点击查看 2/12
I Line 点击查看 211/1576
J Number Game 点击查看 1372/6243
K SolarPea and Inversion 点击查看 3/13
L Striking String Problem 点击查看 0/37
M Z-Game on grid 点击查看 694/3648

文章目录

G.Icon Design

链接:https://ac.nowcoder.com/acm/contest/33191/G
来源:牛客网

题目描述
What’s the feeling of designing an icon for a school as a programmer? Now you have a chance doing it!

The icon of Nanjing Foreign Language School (NFLS for short) is not complicated, it can be represented as an ASCII art.

Since the icon might be used in different places, you need to print the icon in different size.

Given size nn, print the icon of size nn.

Detailed format is shown below, you can also look at the sample output to confirm it.

Like which is shown in the picture, ‘*’ is used on the boundary, and ‘@’ is used for the letters.

(n+1)(n+1) '.'s are used to seperate letters and the boundary horizontally, and nn '.'s are used vertically.

Each letter is (2n+3)(2n+3) characters wide and (2n+3)(2n+3) characters in height.

The icon’s size is (4n+5) × (13n+19)(4n+5)×(13n+19).
输入描述:
The first line contains a positive integer n(1\\leq n\\leq 5)n(1≤n≤5), representing the size of the icon.
输出描述:
Print the icon of size nn.
示例1
输入
复制
1
输出
复制



…@…@…@@@@@…@…@@@@@…
…@@…@…@…@…@…
…@.@.@…@@@@@…@…@@@@@…
…@…@@…@…@…@…
…@…@…@…@@@@@…@@@@@…


示例2
输入
复制
3
输出
复制





…@…@…@@@@@@@@@…@…@@@@@@@@@…
…@@…@…@…@…@…
…@.@…@…@…@…@…
…@…@…@…@…@…@…
…@…@…@…@@@@@@@@@…@…@@@@@@@@@…
…@…@…@…@…@…@…
…@…@.@…@…@…@…
…@…@@…@…@…@…
…@…@…@…@@@@@@@@@…@@@@@@@@@…



题意

  • 给出一个NFLS的图案,按照题意规则模拟 n 属于1-5时的图案,输出即可。

思路:

  • 可以按照题意打印输出,py做法代码相对短一点,cpp也行。
  • 而且因为数据只有5,非常的小,也可以直接手动画出图案后存到数组里输出即可。
//C++
#include<bits/stdc++.h>
using namespace std;

int main()
    int n;  cin>>n;
    for(int i = 0; i < 4*n+5; i++)
        for(int j=0; j < 13*n+19; j++)
            if(i==0||j==0||i==4*n+4||j==13*n+18)printf("*");
            else if((j==n+2||j==i+1||j==3*n+4||j==4*n+6||(j<=6*n+8&&j>4*n+6&&(i==n+1||i==2*n+2))||j==7*n+10||(j>7*n+10&&j<9*n+13&&(i==3*n+3))||((j==10*n+14)&&(i>=n+1&&i<=2*n+2||(i==3*n+3))||(j==12*n+16)&&(i>=2*n+2&&i<=3*n+3||(i==n+1)))||((j>10*n+14&&j<12*n+16)&&(i==n+1||i==2*n+2||i==3*n+3)))&&i>n&&i<3*n+4)
                printf("@");
            else printf(".");
        
        printf("\\n");
    
    return 0;

# python3
n=int(input())
print("*"*(13*n+19))
for i in range(n):
    print("*"+"."*(13*n+17)+"*")
print("*"+"."*(n+1)+"@"+"."*(2*n+1)+"@"+"."*(n+1)+"@"*(2*n+3)+"."*(n+1)+"@"+"."*(3*n+3)+"@"*(2*n+3)+"."*(n+1)+"*")
for i in range(n):
    print("*"+"."*(n+1)+"@"+'.'*i+"@"+"."*(2*n-i)+"@"+"."*(n+1)+("@"+"."*(3*n+3))*3+"*")
print("*"+"."*(n+1)+"@"+"."*n+"@"+"."*n+"@"+"."*(n+1)+"@"*(2*n+3)+"."*(n+1)+"@"+"."*(3*n+3)+"@"*(2*n+3)+"."*(n+1)+"*")
for i in range(n):
    print("*"+"."*(n+1)+"@"+'.'*(i+n+1)+"@"+"."*(n-i-1)+"@"+"."*(n+1)+"@"+"."*(3*n+3)+"@"+"."*(5*n+5)+"@"+"."*(n+1)+"*")
print("*"+"."*(n+1)+"@"+"."*(2*n+1)+"@"+"."*(n+1)+"@"+"."*(3*n+3)+("@"*(2*n+3)+"."*(n+1))*2+"*")
for i in range(n):
    print("*"+"."*(13*n+17)+"*")
print("*"*(13*n+19))

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

int main()
    int n;  cin>>n;
    if(n==1)
        cout<<"********************************"<<endl;
        cout<<"*..............................*"<<endl;
        cout<<"*..@...@..@@@@@..@......@@@@@..*"<<endl;
        cout<<"*..@@..@..@......@......@......*"<<endl;
        cout<<"*..@.@.@..@@@@@..@......@@@@@..*"<<endl;
        cout<<"*..@..@@..@......@..........@..*"<<endl;
        cout<<"*..@...@..@......@@@@@..@@@@@..*"<<endl;
        cout<<"*..............................*"<<endl;
        cout<<"********************************"<<endl;
    
    if(n==2)
        cout<<"*********************************************"<<endl;
        cout<<"*...........................................*"<<endl;
        cout<<"*...........................................*"<<endl;
        cout<<"*...@.....@...@@@@@@@...@.........@@@@@@@...*"<<endl;
        cout<<"*...@@....@...@.........@.........@.........*"<<endl;
        cout<<"*...@.@...@...@.........@.........@.........*"<<endl;
        cout<<"*...@..@..@...@@@@@@@...@.........@@@@@@@...*"<<endl;
        cout<<"*...@...@.@...@.........@...............@...*"<<endl;
        cout<<"*...@....@@...@.........@...............@...*"<<endl;
        cout<<"*...@.....@...@.........@@@@@@@...@@@@@@@...*"<<endl;
        cout<<"*...........................................*"<<endl;
        cout<<"*...........................................*"<<endl;
        cout<<"*********************************************"<<endl;    
    
    if(n==3)
        cout<<"**********************************************************"<<endl;
        cout<<"*........................................................*"<<endl;
        cout<<"*........................................................*"<<endl;
        cout<<"*........................................................*"<<endl;
        cout<<"*....@.......@....@@@@@@@@@....@............@@@@@@@@@....*"<<endl;
        cout<<"*....@@......@....@............@............@............*"<<endl;
        cout<<"*....@.@.....@....@............@............@............*"<<endl;
        cout<<"*....@..@....@....@............@............@............*"<<endl;
        cout<<"*....@...@...@....@@@@@@@@@....@............@@@@@@@@@....*"<<endl;
        cout<<"*....@....@..@....@............@....................@....*"<<endl;
        cout<<"*....@.....@.@....@............@....................@....*"<<endl;
        cout<<"*....@......@@....@............@....................@....*"<<endl;
        cout<<"*....@.......@....@............@@@@@@@@@....@@@@@@@@@....*"<<endl;
        cout<<"*........................................................*"<<endl;
        cout<<"*........................................................*"<<endl;
        cout<<"*........................................................*"<<endl;
        cout<<"**********************************************************"<<endl;
    
    if(n==4)
        cout<<"***********************************************************************"<<endl;
        cout<<"*.....................................................................*"<<endl;
        cout<<"*.....................................................................*"<<endl;
        cout<<"*.....................................................................*"<<endl;
        cout<<"*.....................................................................*"<<endl;
        cout<<"*.....@.........@.....@@@@@@@@@@@.....@...............@@@@@@@@@@@.....*"<<endl;
        cout<<"*.....@@........@.....@...............@...............@...............*"<<endl;
        cout<<"*.....@.@.......@.....@...............@...............@...............*"<<endl;
        cout<<"*.....@..@......@.....@...............@...............@...............*"<<endl;
        cout<<"*.....@...@.....@.....@...............@...............@...............*"<<endl;
        cout<<"*.....@....@....@.....@@@@@@@@@@@.....@...............@@@@@@@@@@@.....*"<<endl;
        cout<<"*.....@.....@...@.....@...............@.........................@.....*"<<endl;
        cout<<"*.....@......@..@.....@...............@.........................@.....*"<<endl;
        cout<<"*.....@.......@.@.....@...............@.........................@.....*"<<endl;
        cout<<"*.....@........@@.....@...............@.........................@.....*"<<endl;      
        cout<<"*.....@.........@.....@...............@@@@@@@@@@@.....@@@@@@@@@@@.....*"<<endl;      
        cout<<"*.....................................................................*"<<endl;
        cout<<"*.....................................................................*"<<endl;
        cout<<"*.....................................................................*"<<endl;
        cout<<"*.....................................................................*"<<endl;
        cout<<"***********************************************************************"<<endl;
       
    if(n==5)
        cout<<"************************************************************************************"<<endl;
        cout<<"*..................................................................................*"<<endl;
        cout<<"*..................................................................................*"<<endl;
        cout<<"*..................................................................................*"<<endl;
        cout<<"*..................................................................................*"<<endl;
        cout<<"*..................................................................................*"<<endl;
        cout<<"*......@...........@......@@@@@@@@@@@@@......@..................@@@@@@@@@@@@@......*"<<endl;
        cout<<"*......@@..........@......@..................@..................@..................*"<<endl;
        cout<<"*......@.@.........@......@..................@..................@..................*"<<endl;
        cout<<"*......@..@........@......@..................@..................@..................*"<<endl;
        cout<<"*......@...@.......@......@..................@..................@..................*"<<endl;
        cout<<"*......@....@......@......@..................@..................@..................*"<<endl;
        cout<<"*......@.....@.....@......@@@@@@@@@@@@@......@..................@@@@@@@@@@@@@......*"<<endl;
        cout<<"*......@......@....@......@..................@..............................@......*"<<endl;
        cout<<"*......@.......@...@......@..................@..............................@......*"<<endl;
        cout<<"*......@........@..@......@..................@..............................@......*"<<endl;     
        cout<<"*......@.........@.@......@..................@..............................@......*"<<endl; 
        cout<<"*......@..........@@......@..................@..............................@......*"<<endl;     
        cout<<"*......@...........@......@..................@@@@@@@@@@@@@......@@@@@@@@@@@@@......*"<<endl;         
        cout<<"*..................................................................................*"<<endl;
        cout<<"*..................................................................................*"<<endl;
        cout<<"*..................................................................................*"<<endl;
        cout<<"*..................................................................................*"<<endl;
        cout<<"*..................................................................................*"<<endl;
        cout<<"************************************************************************************"<<endl;
    
    return 0;



J.Number Game

链接:https://ac.nowcoder.com/acm/contest/33191/J
来源:牛客网

题目描述
There are three integers A, BA,B and CC written on the blackboard.

You can perform the following two operations as many times as you like:

  1. Change BB to A-BA−B.
  2. Change CC to B-CB−C.

Please note that each time you don’t need to perform all two operations. You can choose one type of operation to perform.

You are given an integer xx. Answer whether you can change CC into xx using these operations.

You need to answer TT queries independently.
输入描述:
The first line contains a positive integer T(1\\leq T\\leq 10 ^ 5)T(1≤T≤10
5
).

Each of the next TT lines contains four integers A, B, C, x(-10 ^ 8 \\leq A, B, C, x \\leq 10 ^ 8)A,B,C,x(−10
8
≤A,B,C,x≤10
8
).
输出描述:
For each test case, output “Yes” if CC can become xx, and “No” otherwise (without quotes).
示例1
输入
复制
3
2 4 3 1
2 4 3 2
4 2 2 0
输出
复制
Yes
No
Yes
说明
Please note that A, B, C, xA,B,C,x could be negative.
备注:
Please note that A, B, C, xA,B,C,x could be negative.

题意:

  • 给出ABCx四个数,每次操作可以令B=A-B,或C=B-C。
  • 两种操作都可以操作任意次,求最后能否存在令C=x的情况出现。

思路:

  • 发现做两次 𝐵=𝐴−𝐵 等于没做,做两次 𝐶=𝐵−𝐶 等于没做,所以两个操作必然会交替的进行
    b1 = a-b
    c1 = b-c
    c2 = b1-c1 = (a-b)-(b-c)=a-2b+c = c+(a-2b)
    可见每次操作会多出一个a-2b。若干次操作就是多出k个。
  • 若两个操作使用次数相等,则 𝐶 可以成为的集合 𝑆=𝑥∣𝑥=𝐶+𝑘×(𝐴−2×𝐵),若次数不等,则 𝑆=𝑥∣𝑥=𝐵−𝐶+𝑘×(𝐴−2×𝐵)
  • 注意特判 𝐴=2×𝐵 的情况
#include<bits/stdc++.h>
using namespace std;

int main()
    int T;  cin>>T;
    while(T--)
        int a, b, c, x;  cin>>a>>b>>c>>x;
        if(a-2*b!=0)
            if((x-c)%(a-2*b)==0 || (x-(b-c))%(a-2*b)==0)
                cout<<"Yes\\n";
            else
                cout<<"No\\n";
            
        else
            if((x-c)==0 || (x-(b-c))==0以上是关于“蔚来杯“2022牛客暑期多校训练营6,签到题GJBMA的主要内容,如果未能解决你的问题,请参考以下文章

“蔚来杯“2022牛客暑期多校训练营7,签到题CFGJ

“蔚来杯“2022牛客暑期多校训练营5,签到题KBGHFCD

“蔚来杯“2022牛客暑期多校训练营2,签到题GJK

“蔚来杯“2022牛客暑期多校训练营9,签到题ABGIE

“蔚来杯“2022牛客暑期多校训练营4,签到题NDKHL

“蔚来杯“2022牛客暑期多校训练营1,签到题GADI