2020吉林省程序设计竞赛题解

题目链接


A . C h o r d A.Chord A.Chord
S o l u t i o n Solution Solution
签到。
C o d e Code Code

#include<bits/stdc++.h>
using namespace std;
const int N=1e6+5;
typedef long long ll;
string N1,N2,N3;
int main(){
   
        map<string,int>p={
   {
   "C",0},{
   "C#",1},{
   "D",2},{
   "D#",3},{
   "E",4},{
   "F",5},{
   "F#",6},{
   "G",7},{
   "G#",8},{
   "A",9},{
   "A#",10},{
   "B",11}};
        int t;cin>>t;
        while(t--){
   
                cin>>N1>>N2>>N3;
                int x=p[N1],y=p[N2],z=p[N3];
                if(y<x){
   
                        y+=12;
                }
                while(z<y)z+=12;
                if(y-x==4&&z-y==3){
   
                        puts("Major triad");
                }
                else if(y-x==3&&z-y==4){
   
                        puts("Minor triad");
                }else{
   
                        puts("Dissonance");
                }
        }
}

B . P r o b l e m S e l e c t B.Problem Select B.ProblemSelect
S o l u t i o n Solution Solution
签到。
C o d e Code Code

#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
typedef long long ll;
int main(){
   
    int t;cin>>t;
    while(t--){
   
        vector<int>v;
        int n,k;
        scanf("%d%d",&n,&k);
        for(int i=0;i<n;i++){
   
            int x=0;
            string s;
            cin>>s;
            for(auto c:s){
   
                if (isdigit(c)){
   
                    x=x*10+(c-'0');
                }
            }
            v.push_back(x);
        }
        sort(v.begin(),v.end());
        for(int i=0;i<k-1;i++){
   
            printf("%d ",v[i]);
        }
        printf("%d\n",v[k-1]);
    }
}

C . S t r i n g G a m e C.String Game C.StringGame
S o l u t i o n Solution Solution
签到 d p dp dp,原题。
C o d e Code Code

#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
typedef long long ll;
string s,t;
ll dp[5005][5005];
const int mod=1e9+7;
int main(){
   
    while(cin>>s>>t){
   
        int n=s.size(),m=t.size();
        for(int i=0;i<=n;i++)dp[0][i]=1;
        for(int j=1;j<=m;j++)
        for(int i=1;i<=n;i++){
   
            dp[j][i]=0;
        }
        for(int i=1;i<=m;i++){
   
            for(int j=1;j<=n;j++){
   
                dp[i][j]=dp[i][j-1];
                if(t[i-1]==s[j-1]){
   
                    dp[i][j]+=dp[i-1][j-1];
                }
                dp[i][j]%=mod;
            }
        }
        cout<<dp[m][n]<<endl;
    }
}

E . S h o r t e n t h e A r r a y E.Shorten the Array E.ShortentheArray
S o l u t i o n Solution Solution
除以它们的 g c d gcd gcd,最后状态只跟 1 1 1有关。
C o d e Code Code

#include<bits/stdc++.h>
using namespace std;
const int N=1e6+5;
typedef long long ll;
int a[N];
int main(){
   
    int t;cin>>t;
    while(t--){
   
        int n;<
  • 9
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值