NC219802. Codeforces
描述
≥3000 | Legendary Grandmaster |
2400 - 2999 | Grandmaster |
2100 - 2399 | Master |
1900 - 2099 | Candidate Master |
1600 - 1899 | Expert |
1400 - 1599 | Specialist |
1200 - 1399 | Pupil |
0 - 1199 | Newbie |
输入描述
The first line contains an integer — the number of test cases, each test case contains two integers and representing contestant's rating before and after the contest.
输出描述
If the title has changed, please output in the form of “ to ”, otherwise output “No”.
示例1
输入:
3 1145 1419 1981 0 3000 4000
输出:
Newbie to Specialist Candidate Master to Newbie No
Python3(3.9) 解法, 执行用时: 20ms, 内存消耗: 2824K, 提交时间: 2021-03-22 09:44:05
def dw(x): if x>=3000: return 'Legendary Grandmaster' elif x>=2400: return 'Grandmaster' elif x>=2100: return 'Master' elif x>=1900: return 'Candidate Master' elif x>=1600: return 'Expert' elif x>=1400: return 'Specialist' elif x>=1200: return 'Pupil' else:return 'Newbie' for _ in range(int(input())): a,b=map(int,input().split()) if dw(a)==dw(b): print('No') else: print(dw(a),'to',dw(b))
C++(clang++11) 解法, 执行用时: 3ms, 内存消耗: 396K, 提交时间: 2021-03-25 20:53:35
#include<bits/stdc++.h> using namespace std; string s; string fun(int n){ if(n>=3000)return "Legendary Grandmaster"; if(n>=2400)return "Grandmaster"; if(n>=2100)return "Master"; if(n>=1900)return "Candidate Master"; if(n>=1600)return "Expert"; if(n>=1400)return "Specialist"; if(n>=1200)return "Pupil"; return "Newbie"; } int main(){ int t; int a,b; cin>>t; while(t--){ cin>>a>>b; if(fun(a)!=fun(b)){ cout<<fun(a)<<" to "<<fun(b)<<endl; }else{ cout<<"No"<<endl; } } }