From 438d0d7fe2c8b457716d443d0f3c1bd8432b0725 Mon Sep 17 00:00:00 2001 From: "Rana M. Suleman" Date: Thu, 1 Oct 2020 15:16:30 +0100 Subject: [PATCH 1/3] added NAICHEF solution --- NAICHEF.java | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 NAICHEF.java diff --git a/NAICHEF.java b/NAICHEF.java new file mode 100644 index 0000000..d2028c8 --- /dev/null +++ b/NAICHEF.java @@ -0,0 +1,34 @@ +import java.util.*; +import java.lang.*; +import java.io.*; + +/* Name of the class has to be "Main" only if the class is public. +* @author Rana M. Suleman + */ +class Codechef +{ + public static void main (String[] args) throws java.lang.Exception + { + + Scanner in = new Scanner(System.in); + + int length = in.nextInt(); + do{ + int[] arr = new int[in.nextInt()]; + double a = in.nextDouble(); + double b = in.nextDouble(); + for (int i = 0; i < arr.length ; i++) { + arr[i] = in.nextInt(); + } + + double a_faces=0,b_faces = 0; + for (int value: arr) { + if(value == a) a_faces++; + if(value == b) b_faces++; + } + System.out.println((a_faces/ ((double) arr.length))*(b_faces/ ((double) arr.length))); + length--; + }while(length != 0); + + } +} From e9b117956c7efcde356234d4f1560d026a692af1 Mon Sep 17 00:00:00 2001 From: "Rana M. Suleman" Date: Thu, 1 Oct 2020 15:55:30 +0100 Subject: [PATCH 2/3] Added CHEFRUN,FLOW004,FLOW018 solutions --- CHEFRUN.java | 33 +++++++++++++++++++++++++++++++++ FLOW004.java | 24 ++++++++++++++++++++++++ FLOW018.java | 28 ++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+) create mode 100644 CHEFRUN.java create mode 100644 FLOW004.java create mode 100644 FLOW018.java diff --git a/CHEFRUN.java b/CHEFRUN.java new file mode 100644 index 0000000..0e16258 --- /dev/null +++ b/CHEFRUN.java @@ -0,0 +1,33 @@ +import java.util.*; +import java.lang.*; +import java.io.*; + +/* Name of the class has to be "Main" only if the class is public. */ +class Codechef +{ + public static void main (String[] args) throws java.lang.Exception + { + Scanner in = new Scanner(System.in); + int length = in.nextInt(); + Double x1,x2,x3,v1,v2 ; + Double d1,d2; + for (int i = 0; i < length ; i++) { + x1 = in.nextDouble(); + x2 = in.nextDouble(); + x3 = in.nextDouble(); + v1 = in.nextDouble(); + v2 = in.nextDouble(); + + x1 = x3 -x1; + x2 = x2-x3; + + if((x1/v1) == (x2/v2)){ + System.out.println("Draw"); + }else if((x1/v1) < (x2/v2)){ + System.out.println("Chef"); + }else + System.out.println("Kefa"); + + } + } +} diff --git a/FLOW004.java b/FLOW004.java new file mode 100644 index 0000000..dd48136 --- /dev/null +++ b/FLOW004.java @@ -0,0 +1,24 @@ +import java.util.*; +import java.lang.*; +import java.io.*; + +/* Name of the class has to be "Main" only if the class is public. */ +class Codechef +{ + public static void main (String[] args) throws java.lang.Exception + { + + Scanner in = new Scanner(System.in); + int testCases = in.nextInt(); + int i = 0; + int sum = 0; + while (i < testCases) { + + String number = in.next(); + String[] arr = number.split(""); + sum = Integer.parseInt(arr[0]) + Integer.parseInt(arr[arr.length-1]); + System.out.println(sum); + i++; + } + } +} diff --git a/FLOW018.java b/FLOW018.java new file mode 100644 index 0000000..5d4cc29 --- /dev/null +++ b/FLOW018.java @@ -0,0 +1,28 @@ +/* package codechef; // don't place package name! */ + +import java.util.*; +import java.lang.*; +import java.io.*; + +/* Name of the class has to be "Main" only if the class is public. */ +class Codechef +{ + public static void main (String[] args) throws java.lang.Exception + { + + Scanner in = new Scanner(System.in); + int testCases = in.nextInt(); + int i = 0; + int sum = 1; + int num = 0; + while (i < testCases) { + num = in.nextInt(); + for (int j = 1; j <= num; j++) { + sum=sum*j; + } + System.out.println(sum); + sum = 1; + i++; + } + } +} From d7c3606cf21cfe7790686bba100321cd30015fe7 Mon Sep 17 00:00:00 2001 From: "Rana M. Suleman" Date: Sun, 4 Oct 2020 00:30:11 +0100 Subject: [PATCH 3/3] Added Flow006 solution --- FLOW006.java | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 FLOW006.java diff --git a/FLOW006.java b/FLOW006.java new file mode 100644 index 0000000..289b2ec --- /dev/null +++ b/FLOW006.java @@ -0,0 +1,32 @@ +/* package codechef; // don't place package name! */ + +import java.util.*; +import java.lang.*; +import java.io.*; + +/* Name of the class has to be "Main" only if the class is public. */ +class Codechef +{ + public static void main (String[] args) throws java.lang.Exception + { + + Scanner in = new Scanner(System.in); + int testCases = in.nextInt(); + int i = 0; + int sum = 0; + while (i < testCases) { + + String number = in.next(); + String[] arr = number.split(""); + + for (int j = 0; j < arr.length; j++) { + sum += Integer.parseInt(arr[j]); + } + + System.out.println(sum); + sum = 0; + + i++; + } + } +}