Created
July 17, 2016 13:30
-
-
Save Jack-Saleem/0bc3eb8cceaafceae3d8da03b75bf3e1 to your computer and use it in GitHub Desktop.
Codeforces 424A Squats program in java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class Squats | |
{ | |
public static void main(String[] args) | |
{ | |
Scanner z=new Scanner(System.in); | |
short n=z.nextShort(); | |
String x=z.next(); | |
int a=Math.max(x.replaceAll("X", "").length(), x.replaceAll("x", "").length())-n/2; | |
System.out.println(a); | |
if(x.replaceAll("X", "").length() >= x.replaceAll("x", "").length()){ | |
for(int i=0;i<a;i++) | |
x=x.replaceFirst("x", "X"); | |
System.out.println(x); | |
} else { | |
for(int i=0;i<a;i++) | |
x=x.replaceFirst("X", "x"); | |
System.out.println(x); | |
}z.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment