A。Word每次测试的时间限制2 秒每次测试的内存限制256 兆字节输入标准输入输出标准输出

1.题目

Problem - 59A - Codeforces (Unofficial mirror by Menci)

Vasya is very upset that many people on the Net mix uppercase and lowercase letters in one word. That's why he decided to invent an extension for his favorite browser that would change the letters' register in every word so that it either only consisted of lowercase letters or, vice versa, only of uppercase ones. At that as little as possible letters should be changed in the word. For example, the word HoUse must be replaced with house, and the word ViP — with VIP. If a word contains an equal number of uppercase and lowercase letters, you should replace all the letters with lowercase ones. For example, maTRIx should be replaced by matrix. Your task is to use the given method on one given word.

瓦夏对网上许多人在一个单词中混用大小写字母感到非常不满。因此,他决定为他最喜欢的浏览器发明一个扩展程序,改变每个单词中字母的寄存器,使其要么只包含小写字母,要么只包含大写字母。在这种情况下,单词中应尽可能少地更改字母。例如,HoUse必须替换为house,而ViP则替换为VIP。如果一个单词包含相同数量的大写字母和小写字母,则应将所有字母替换为小写字母。例如,maTRIx 应替换为 matrix。您的任务是在一个给定的单词上使用给定的方法。

Input

The first line contains a word s — it consists of uppercase and lowercase Latin letters and possesses the length from 1 to 100.

输入

第一行包含一个单词 s - 它由大写和小写拉丁字母组成,长度从 1 到 100 不等。

Output

Print the corrected word s. If the given word s has strictly more uppercase letters, make the word written in the uppercase register, otherwise - in the lowercase one.

输出

打印更正后的单词 s 。如果给定的单词 s 有严格意义上更多的大写字母,则将该单词写入大写寄存器,否则写入小写寄存器。

Examples

input

HoUse

output

house

input

ViP

output

VIP

input

maTRIx

output

matrix

2.题解代码

#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int nma[N],nmb[N];
int main(){
	int nmaj=0,nmbj=0;
	string s;
	cin>>s;
	int len=s.length();
	for(int i=0;i<len;i++){
		if(s[i]>='A'&&s[i]<='Z'){
			nma[nmaj]=i;
			nmaj++;
		}
		else{
			nmb[nmbj]=i;
			nmbj++;
		}
	}
	if(nmaj>nmbj){
		for(int i=0;i<nmbj;i++){
			s[nmb[i]]=s[nmb[i]]-'a'+'A';
		}
	}
	else if(nmaj<=nmbj){
		for(int i=0;i<nmaj;i++){
			s[nma[i]]=s[nma[i]]+'a'-'A';
		}
	}
	cout<<s;
	return 0;
}

  • 44
    点赞
  • 26
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值