Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. //703A : MISHKA AND GAME
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.IOException;
  5. import java.io.InputStream;
  6. import java.io.InputStreamReader;
  7. import java.io.OutputStream;
  8. import java.io.PrintWriter;
  9. import java.util.StringTokenizer;
  10.  
  11. //Your code goes here
  12. public class Main {
  13.  
  14. static class ProblemSolver{
  15. public void solveTheProblem(InputReader in,PrintWriter out){
  16.  
  17. //Declare all the necessary variables
  18. int n=in.nextInt();//no of turns
  19. int m=0,c=0;//m to be incremented in Mishka wins and c if Chris wins
  20.  
  21. //Calculation of number of wins
  22. /*
  23. * Note:-
  24. * - Declaring a variable inside the for loop is memory efficient
  25. * so it is recommended use this style of declaration whereever possible
  26. */
  27. for(int i=1;i<=n;++i){
  28. int M,C;
  29. M=in.nextInt();
  30. C=in.nextInt();
  31. if(M>C)++m;
  32. else if(M<C)++c;
  33. else continue;
  34. }
  35.  
  36. //Display the result
  37. if(m>c)System.out.println("Mishka");
  38. else if(c>m)System.out.println("Chris");
  39. else System.out.println("Friendship is magic!^^");
  40. }
  41. }
  42.  
  43. //Default template for all the codes
  44. static class InputReader {
  45. public BufferedReader reader;
  46. public StringTokenizer tokenizer;
  47.  
  48. public InputReader(InputStream stream) {
  49. reader = new BufferedReader(new InputStreamReader(stream),32768);
  50. tokenizer = null;
  51. }
  52.  
  53. public String next() {
  54. while (tokenizer == null || !tokenizer.hasMoreTokens()) {
  55. try {
  56. tokenizer = new StringTokenizer(reader.readLine());
  57. } catch (IOException e) {
  58. throw new RuntimeException(e);
  59. }
  60. }
  61. return tokenizer.nextToken();
  62. }
  63.  
  64. public int nextInt() {
  65. return Integer.parseInt(next());
  66. }
  67.  
  68. }
  69.  
  70. //Main method for all the codes
  71. public static void main(String[] args) {
  72. InputStream inputStream = System.in;
  73. OutputStream outputStream = System.out;
  74. InputReader in = new InputReader(inputStream);
  75. PrintWriter out = new PrintWriter(outputStream);
  76. ProblemSolver problemSolver = new ProblemSolver();
  77. problemSolver.solveTheProblem(in, out);
  78. out.close();
  79. }
  80.  
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement