Codeforces Round #242 (Div. 2) A. Squats
注意题目一次只能改变一个松鼠,Pasha can make some hamster ether sit down or stand up.是单数不是复数
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std; int main(){
int n; cin >> n;
string str; cin >> str;
int num = count(str.begin(),str.end(),'X') -n/;
if(num == ) cout<<<<"\n"<<str<<endl;
else{
cout<<abs(num)<<endl;
int cnt = ;
for(int i = ;i < n && cnt<abs(num); ++ i){
if(num > && str[i]=='X'){
str[i]='x';
cnt++;
}
if(num < && str[i]=='x'){
str[i]='X';
cnt++;
}
}
cout<<str<<endl;
}
}
Codeforces Round #242 (Div. 2) A. Squats的更多相关文章
- Codeforces Round #242 (Div. 2) C题
题目链接:http://codeforces.com/contest/424/problem/C, 想来一个小时,就是做不出,都做出来了,悲剧! 分析:我们知道交换异或的顺序不影响答案! 然后就是求t ...
- Codeforces Round #242 (Div. 2) A~C
题目链接 A. Squats time limit per test:1 secondmemory limit per test:256 megabytesinput:standard inputou ...
- Codeforces Round #242 (Div. 2) <A-D>
CF424 A. Squats 题目意思: 有n(n为偶数)个x和X,求最少的变换次数,使得X的个数为n/2,输出变换后的序列. 解题思路: 统计X的个数ans,和n/2比較,少了的话,须要把n/2- ...
- Codeforces Round #242 (Div. 2) B. Megacity
按照半径排序,然后累加人数直到超过百万 #include <iostream> #include <algorithm> #include <cmath> #inc ...
- Codeforces Round #242 (Div. 2) C. Magic Formulas
解题思路是: Q=q1^q2.......^qn = p1^p2......^pn^((1%1)^....(1%n))^((2%1)^......(2%n))^.... 故Q的求解过程分成两部分 第一 ...
- Codeforces Round #242 (Div. 2) C. Magic Formulas (位异或性质 找规律)
题目 比赛的时候找出规律了,但是找的有点慢了,写代码的时候出了问题,也没交对,还掉分了.... 还是先总结一下位移或的性质吧: 1. 交换律 a ^ b = b ^ a 2. 结合律 (a^b) ^ ...
- Codeforces Round #242 (Div. 2)C(找规律,异或运算)
一看就是找规律的题.只要熟悉异或的性质,可以秒杀. 为了防止忘记异或的规则,可以把异或理解为半加运算:其运算法则相当于不带进位的二进制加法. 一些性质如下: 交换律: 结合律: 恒等律: 归零律: 典 ...
- Codeforces Round #366 (Div. 2) ABC
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
随机推荐
- 转:不再以讹传讹,GET和POST的真正区别
如果有人问你,GET和POST,有什么区别?你会如何回答? 我的经历 前几天有人问我这个问题.我说GET是用于获取数据的,POST,一般用于将数据发给服务器之用. 这个答案好像并不是他想要的.于是他继 ...
- Linux發送郵件
1.直接使用shell當編輯器 [root@phburdb1 mail]# mail -s "Hello World" juncai.chen@innolux.comHello j ...
- iOS 随记
UIImage 走缓存 + (UIImage *)imageNamed:(NSString *)name; 不走缓存 + (UIImage *)imageWithContentsOfFile:(NSS ...
- 一种快速刷新richedit中内嵌动画的方法的实现
在IM中使用动画表情是一种非常有趣的方式,然而选择一种合适的方式来实现却并不容易. 一般来说,除了自己去实现一个富文本控件,目前主要的解决方案有3种: 1.使用浏览器做容器. 2.使用QT提供的Ric ...
- C++ 中 char 与 int 转换问题
itoa 功 能:把一整数转换为字符串 函 数:char *itoa(int value, char *string, int radix); 解 释:itoa 是英文integer to ar ...
- loj 1044(dp+记忆化搜索)
题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=26764 思路:dp[pos]表示0-pos这段字符串最少分割的回文 ...
- ado.net增删改查练习
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.D ...
- 【Tomcat】直接启动tomcat时为tomcat指定JDK 而不是读取环境变量中的配置
在windows环境下以批处理文件方式启动tomcat,只要运行<CATALINA_HOME>/bin/startup.bat这个文件,就可以启动Tomcat.在启动时,startup.b ...
- mysql注入研究
网址: http://www.jb51.net/article/14446.htm http://www.jb51.net/article/29445.htm
- Laravel系列2入门使用
最好的教程是官方文档! homestead安装好,就可以使用了. 安装Laravel composer create-project --prefer-dist laravel/laravel blo ...