题目链接
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;<