ACdream HUT新生摸底训练赛 A 娜娜梦游仙境系列——诡异的钢琴 水

解题思路:

排序以后求gcd较判断即可。

解题代码:

// File Name: a.cpp
// Author: darkdream
// Created Time: 2015年04月12日 星期日 19时30分44秒

#include<vector>
#include<list>
#include<map>
#include<set>
#include<deque>
#include<stack>
#include<bitset>
#include<algorithm>
#include<functional>
#include<numeric>
#include<utility>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<ctime>
#define LL long long

using namespace std;
int a[4];
int gcd(int a, int b)
{
  return b == 0 ?a:gcd(b,a%b);
}
int main(){
  int t; 
  scanf("%d",&t);
  while(t--)
  {
      for(int i = 1;i <= 3; i ++)
          scanf("%d",&a[i]);
      sort(a+1,a+1+3);
      int x , y ; 
      x = gcd(a[1],a[2]);
      y = gcd(a[2],a[3]);
      if(a[1]/x == 4 && a[2]/x == 5)
      {
          if(a[2]/y == 5 && a[3]/y == 6)
          {
              printf("major
");
              continue;
          }else{
              printf("noise
");
          }
          continue;
      }else if(a[1]/x == 5 && a[2]/x == 6){
         if(a[2]/y == 4 && a[3]/y == 5)
         {
              printf("minor
");
         }else
              printf("noise
");
         continue;
      }else{
              printf("noise
");
              continue;
          
      }
  }
return 0;
}
View Code
原文地址:https://www.cnblogs.com/zyue/p/4423036.html