A. Recovering a Small String
题意:问给你一个n,找到字符串序列最小的三个字母。
题解:贪心即可。
代码:
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
const int maxn = 2e5 + 7 ;
inline ll read(){
ll x = 0 , f = 1 ;
char c = getchar() ;
while(c > '9' || c < '0'){
if(c == '-')
f = -1 ;
c = getchar() ;
}
while(c >= '0' && c <= '9'){
x = x * 10 + c - '0' ;
c = getchar() ;
}
return x * f ;
}
ll t , n , m , k , a[maxn] , c[maxn] , b[maxn] ;
char s[maxn] ;
void solve(){
n = read() ;
ll x = 3 ;
c[1] = 1 ;
c[2] = 1 ;
c[3] = 1 ;
if(x + 25 <= n){
c[3] = 26 ;
x += 25 ;
}
else{
cout << char(c[1] + 'a' - 1) << char(c[2] + 'a' - 1) << char(c[3] + (n - x) + 'a' - 1) << endl ;
return ;
}
if(x + 25 <= n){
c[2] = 26 ;
x += 25 ;
}
else{
cout << char(c[1] + 'a' - 1) << char(c[2] + (n - x) + 'a' - 1) << char(c[3] + 'a' - 1) << endl ;
return ;
}
cout << char(c[1] + (n - x) + 'a' - 1) << char(c[2] + 'a' - 1) << char(c[3] + 'a' - 1) << endl ;
}
int main(){
t = read() ;
while(t --){
solve() ;
}
return 0 ;
}
B. Make Equal
题意:给你n个数字,n个数字求和一定会被n整除,可以操作