- Chord
题目大意是有12个符号,多个循环在一块。任意给三个,他们之间距离如果为3.4就为minor triad chord或者4.3就为a major triad chord.其余均为Dissonance。
- #include<bits/stdc++.h>
- using namespace std;
- int i,j;
- string res[3];
- string b[]={"C","C#","D","D#","E","F","F#","G","G#","A","A#","B","C","C#","D","D#","E","F","F#","G","G#","A","A#","B"};
- int show(string x,string y){
- int a=0,d=0,c=0;
- for(i=0;i<24;i++){
- if(x==b[i]){
- for(j=i;j<24;j++){
- if(y==b[j]){
- int tol=j-i;
- return tol;
- break;
- }
- }
- }
- }
- }
- int main(){
- int r,n,m;
- cin>>r;
- while(r--){
- for(j=0;j<3;j++)cin>>res[j];
- n=show(res[0],res[1]);
- m=show(res[1],res[2]);
- if(n==4&&m==3)printf("Major triad\n");
- else if(n==3&&m==4)printf("Minor triad\n");
- else printf("Dissonance\n");
- }
- return 0;
- }
L. Swimmer
- #include <bits/stdc++.h>
- using namespace std;
- int n, k;
- string a[1010];
- int b[1010];
- int main(){
- int t;
- cin >> t;
- while( t -- ){
- cin >> n >> k;
- memset(b, 0, sizeof(b));
- for(int j = 0; j < n; j ++)
- cin >> a[j];
- for(int i = 0; i < n; i ++){
- for(int j = 0; j < a[i].size(); j ++){
- if(a[i][j] >= '0' && a[i][j] <= '9'){
- b[i] *= 10;
- b[i] += a[i][j] - '0';
- }
- }
- }
- sort(b, b + n);
- for(int i = 0; i < k; i ++)cout << b[i] << " ";
- cout << endl;
- }
- return 0;
- }
G. Matrix
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long LL;
- long long a, b;
- LL binary_search(LL a)
- {
- LL l = 1, r = 1e9;
- while(l < r)
- {
- LL mid = l + r + 1 >> 1;
- if(mid * mid <= a) l = mid;
- else r = mid - 1;
- }
- return l;
- }
- void solve(){
- cin >> a >> b;
- cout << binary_search(a) * binary_search(b) << endl;
- }
- int main()
- {
- int _ = 1;
- ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
- cin >> _;
- while(_ -- ){
- solve();
- }
- return 0;
- }