• AtCoder Beginner Contest 058 ABCD题


    A - ι⊥l


    Time limit : 2sec / Memory limit : 256MB

    Score : 100 points

    Problem Statement

    Three poles stand evenly spaced along a line. Their heights are ab and c meters, from left to right. We will call the arrangement of the poles beautiful if the tops of the poles lie on the same line, that is, ba=cb.

    Determine whether the arrangement of the poles is beautiful.

    Constraints

    • 1≤a,b,c≤100
    • ab and c are integers.

    Input

    Input is given from Standard Input in the following format:

    a b c
    

    Output

    Print YES if the arrangement of the poles is beautiful; print NO otherwise.


    Sample Input 1

    Copy
    2 4 6
    

    Sample Output 1

    Copy
    YES
    

    Since 4−2=6−4, this arrangement of poles is beautiful.


    Sample Input 2

    Copy
    2 5 6
    

    Sample Output 2

    Copy
    NO
    

    Since 5−2≠6−5, this arrangement of poles is not beautiful.


    Sample Input 3

    Copy
    3 2 1
    

    Sample Output 3

    Copy
    YES
    

    Since 1−2=2−3, this arrangement of poles is beautiful.

    题意:额。。

    解法:额

     1 #include<bits/stdc++.h>
     2 using namespace std;
     3 typedef long long ll;
     4  
     5 ll an[100010],am[100010];
     6 int main()
     7 {
     8     int a,b,c;
     9     cin>>a>>b>>c;
    10     if(b-a==c-b)
    11     {
    12         cout<<"YES"<<endl;
    13     }
    14     else
    15     {
    16         cout<<"NO"<<endl;
    17     }
    18     return 0;
    19 }

    B - ∵∴∵


    Time limit : 2sec / Memory limit : 256MB

    Score : 200 points

    Problem Statement

    Snuke signed up for a new website which holds programming competitions. He worried that he might forget his password, and he took notes of it. Since directly recording his password would cause him trouble if stolen, he took two notes: one contains the characters at the odd-numbered positions, and the other contains the characters at the even-numbered positions.

    You are given two strings O and EO contains the characters at the odd-numbered positions retaining their relative order, and E contains the characters at the even-numbered positions retaining their relative order. Restore the original password.

    Constraints

    • O and E consists of lowercase English letters (a - z).
    • 1≤|O|,|E|≤50
    • |O|−|E| is either 0 or 1.

    Input

    Input is given from Standard Input in the following format:

    O
    E
    

    Output

    Print the original password.


    Sample Input 1

    Copy
    xyz
    abc
    

    Sample Output 1

    Copy
    xaybzc
    

    The original password is xaybzc. Extracting the characters at the odd-numbered positions results in xyz, and extracting the characters at the even-numbered positions results in abc.


    Sample Input 2

    Copy
    atcoderbeginnercontest
    atcoderregularcontest
    

    Sample Output 2

    Copy
    aattccooddeerrbreeggiunlnaerrccoonntteesstt
    题意:额
    解法:额
     1 #include<bits/stdc++.h>
     2 using namespace std;
     3 typedef long long ll;
     4 string s1,s2,s3;
     5 int main()
     6 {
     7     int num1=0;
     8     int num2=0;
     9     cin>>s1;
    10     cin>>s2;
    11     for(int i=0;i<s1.size()+s2.size();i++)
    12     {
    13         if(i%2)
    14         {
    15             cout<<s2[num1++];
    16         }
    17         else
    18         {
    19             cout<<s1[num2++];
    20         }
    21     }
    22     cout<<endl;
    23     return 0;
    24 }

    C - 怪文書 / Dubious Document


    Time limit : 2sec / Memory limit : 256MB

    Score : 300 points

    Problem Statement

    Snuke loves "paper cutting": he cuts out characters from a newspaper headline and rearranges them to form another string.

    He will receive a headline which contains one of the strings S1,…,Sn tomorrow. He is excited and already thinking of what string he will create. Since he does not know the string on the headline yet, he is interested in strings that can be created regardless of which string the headline contains.

    Find the longest string that can be created regardless of which string among S1,…,Sn the headline contains. If there are multiple such strings, find the lexicographically smallest one among them.

    Constraints

    • 1≤n≤50
    • 1≤|Si|≤50 for every i=1,…,n.
    • Si consists of lowercase English letters (a - z) for every i=1,…,n.

    Input

    Input is given from Standard Input in the following format:

    n
    S1
    
    Sn
    

    Output

    Print the lexicographically smallest string among the longest strings that satisfy the condition. If the answer is an empty string, print an empty line.


    Sample Input 1

    Copy
    3
    cbaa
    daacc
    acacac
    

    Sample Output 1

    Copy
    aac
    

    The strings that can be created from each of cbaadaacc and acacac, are aaaacacacaa and so forth. Among them, aacaca andcaa are the longest, and the lexicographically smallest of these three is aac.


    Sample Input 2

    Copy
    3
    a
    aa
    b
    

    Sample Output 2

    Copy
    
    

    The answer is an empty string.

    题意:选择字符串公共的字母,哪个字母出现次数最少就加进去,比如a在第一个字符串只出现了次,于是有aa

    解法:模拟

     1 #include <bits/stdc++.h>
     2 
     3 using namespace std;
     4 string s[100];
     5 int n;
     6 map<char,int>q;
     7 string s1;
     8 int main()
     9 {
    10     cin>>n;
    11     for(int i=0; i<n; i++)
    12     {
    13         cin>>s[i];
    14     }
    15     for(char i='a'; i<='z'; i++)
    16     {
    17         int flag=0;
    18         for(int j=0; j<n; j++)
    19         {
    20             if(s[j].find(i)==-1)
    21             {
    22                 flag=1;
    23             }
    24         }
    25         if(flag==0)
    26         {
    27             int minn=100;
    28            // cout<<i<<endl;
    29             for(int j=0; j<n; j++)
    30             {
    31                 int cnt=0;
    32                 for(int z=0;z<s[j].size();z++)
    33                 {
    34                     if(s[j][z]==i)
    35                     {
    36                         cnt++;
    37                     }
    38                 }
    39                 minn=min(minn,cnt);
    40             }
    41             for(int j=0;j<minn;j++)
    42             {
    43                 s1+=i;
    44             }
    45         }
    46     }
    47     cout<<s1<<endl;
    48     return 0;
    49 }

    D - 井井井 / ###


    Time limit : 2sec / Memory limit : 256MB

    Score : 500 points

    Problem Statement

    On a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis. Among the lines parallel to the x axis, the i-th from the bottom is represented by y=yi. Similarly, among the lines parallel to the y axis, the i-th from the left is represented by x=xi.

    For every rectangle that is formed by these lines, find its area, and print the total area modulo 109+7.

    That is, for every quadruple (i,j,k,l) satisfying 1≤i<jn and 1≤k<lm, find the area of the rectangle formed by the lines x=xix=xjy=yk and y=yl, and print the sum of these areas modulo 109+7.

    Constraints

    • 2≤n,m≤105
    • −109x1<…<xn≤109
    • −109≤y1<…<ym≤109
    • xi and yi are integers.

    Input

    Input is given from Standard Input in the following format:

    n m
    x1 x2  xn
    y1 y2  ym
    

    Output

    Print the total area of the rectangles, modulo 109+7.


    Sample Input 1

    Copy
    3 3
    1 3 4
    1 3 6
    

    Sample Output 1

    Copy
    60
    

    The following figure illustrates this input:

    sample1-1

    The total area of the nine rectangles A, B, ..., I shown in the following figure, is 60.

    sample1-2


    Sample Input 2

    Copy
    6 5
    -790013317 -192321079 95834122 418379342 586260100 802780784
    -253230108 193944314 363756450 712662868 735867677
    

    Sample Output 2

    Copy
    835067060
    题意:把这里面所有的正方形面积都加一次
    解法: ∑∑(xi-xj)(yi-yj)1<=i<=n 1<=j<=m
    把上面分开有:

    于是...就出来了

     1 #include<bits/stdc++.h>
     2 //std::ios::sync_with_stdio(false);
     3 using namespace std;
     4 typedef long long ll;
     5 ll n,m;
     6 ll sx;
     7 ll sy;
     8 ll mod=1e9+7;
     9 ll x[200000],y[200000];
    10 int main()
    11 {
    12     cin>>n>>m;
    13     for(ll i=1;i<=n;i++)
    14     {
    15         cin>>x[i];
    16     }
    17     for(ll i=1;i<=m;i++)
    18     {
    19         cin>>y[i];
    20     }
    21     for(ll i=1;i<=n;i++)
    22     {
    23         sx+=((i-1)*x[i]-(n-i)*x[i])%mod;
    24         sx%=mod;
    25     }
    26     for(ll i=1;i<=m;i++)
    27     {
    28         sy+=((i-1)*y[i]-(m-i)*y[i])%mod;
    29         sy%=mod;
    30     }
    31     cout<<sx%mod*sy%mod<<endl;
    32     return 0;
    33 }
    
    

  • 相关阅读:
    WPF:DataGrid 自动生成行号
    C#:WinForm之Command
    i.MX RT1010之FlexIO模拟SSI外设
    i.MX RT1010之FlexIO模拟I2S外设
    i.MX RT600之DSP开发环境调试篇
    i.MX RT600之DSP调试环境搭建篇
    i.MX RT600之DMIC外设介绍及应用
    i.MX RT600之I2S外设介绍及应用
    ssm框架思维-登录
    idea里面搭建SSM框架-crud
  • 原文地址:https://www.cnblogs.com/yinghualuowu/p/6702034.html
Copyright © 2020-2023  润新知