AISing Programming Contest 2021(AtCoder Beginner Contest 202)(A-C)D待补

简介: 算法

链接:


A - Three Dice

题意:给你三个整数分别对应其骰子的大小,在这里,每一个骰子都是一个标准的立方骰子,其中相对面上的数字之和是7,求对面的和.

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    cout<<abs(7-a)+abs(7-b)+abs(7-c)<<endl;
}


B - 180°


题意:将字符串反转,并且把6换成9,把9换成6.

#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s1;
    cin>>s1;
    reverse(s1.begin(),s1.end());
    for(int i=0;i<s1.length();i++){
        if(s1[i]=='9') cout<<6;
         else if(s1[i]=='6')    cout<<9;
         else cout<<s1[i];
    }
    cout<<endl;
}


C - Made Up


题意:

1.png

#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxn=1e5+100;
int a[maxn];
int b[maxn];
int c1[maxn];
signed  main()
{
    int n,m,i,j;
    int ans=0;
    cin>>n;
    map<int ,int >ma,mp;
    for(i=0;i<n;i++){
        cin>>a[i];
        ma[a[i]]++;
    }
    for(i=0;i<n;i++){
        cin>>b[i];
        mp[i]=b[i];
    }
    for(i=0;i<n;i++){
        cin>>m;
        c1[i]=mp[m-1];
        ans+=(ma[mp[m-1]]);
    }
    cout<<ans<<endl;
}


D - aab aba baa


题意:给你a个字符‘a’和b个字符’b’,输出按照字典序排列后第k大的

思路:

听说是dp,但是我没看太懂,再想一想,dp太弱鸟~

2.png

相关文章
German Collegiate Programming Contest 2019 B . Bouldering (最短路)
German Collegiate Programming Contest 2019 B . Bouldering (最短路)
103 0
German Collegiate Programming Contest 2019 B . Bouldering (最短路)
|
机器学习/深度学习 人工智能 BI
The 15th Chinese Northeast Collegiate Programming Contest
The 15th Chinese Northeast Collegiate Programming Contest
146 0
|
人工智能
Nordic Collegiate Programming Contest 2020 D.Damsindistress (dp)
Nordic Collegiate Programming Contest 2020 D.Damsindistress (dp)
94 0
|
机器学习/深度学习 人工智能 Java
AtCoder Beginner Contest 215 D - Coprime 2 (质因子分解 gcd)
AtCoder Beginner Contest 215 D - Coprime 2 (质因子分解 gcd)
108 0
|
人工智能
atcoder AtCoder Beginner Contest 210 D - National Railway(dp)
atcoder AtCoder Beginner Contest 210 D - National Railway(dp)
116 0
|
算法
AtCoder Beginner Contest 213 E - Stronger Takahashi(01BFS)
AtCoder Beginner Contest 213 E - Stronger Takahashi(01BFS)
136 0
AtCoder Beginner Contest 133 E - Virus Tree 2(组合数学)
AtCoder Beginner Contest 133 E - Virus Tree 2(组合数学)
107 0
|
机器学习/深度学习
AtCoder Beginner Contest 218 C - Shapes (模拟)
AtCoder Beginner Contest 218 C - Shapes (模拟)
147 0
|
机器学习/深度学习
AtCoder Beginner Contest 215 E - Chain Contestant (状压dp)
AtCoder Beginner Contest 215 E - Chain Contestant (状压dp)
120 0
|
定位技术
German collegiate programming contest 2012 - Ski Jumping
首先用动能定理算出平抛的初速度v0,然后分三种情况,0~L/2,L/2~L,L~无穷远。
138 0
German collegiate programming contest 2012 - Ski Jumping