-
-
Save Jack-Saleem/83274c9a310bf0b11b24 to your computer and use it in GitHub Desktop.
| import java.util.Scanner; | |
| public class Team | |
| { | |
| public static void main(String args[]) | |
| { | |
| Scanner ip = new Scanner(System.in); | |
| int x=ip.nextInt(); | |
| int ctr=0,s=0; | |
| int[] a = new int[3]; | |
| int[] b = new int[1001]; | |
| for(int i=1;i<=x;i++) | |
| { | |
| for(int j=0;j<=2;j++) | |
| { | |
| a[j]=ip.nextInt(); | |
| s=a[0]+a[1]+a[2]; | |
| } | |
| b[i]=s; | |
| if(b[i]>=2) | |
| ctr++; | |
| } | |
| System.out.println(ctr); | |
| } | |
| } |
Jack-Saleem
commented
May 16, 2020
via email
Hi monick,
This particular program is for the below question on codeforces site
https://codeforces.com/problemset/problem/231/A
Please refer to the above site and you will understand the question, for that question this program is a solution.(then you will understand wht I am storing the inputs in to an array of integer)
Hi @Jack-Saleem, i tried my own code and was like this, but didn't know why the compiler accepts yours and not mine, can you tell?
`import java.util.Scanner;
public class Team {
//program on codeforces.com
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
Scanner scanner2 = new Scanner(System.in);
int n = scanner.nextInt();
int arr[] = new int[n];
int count, fin = 0;
if (n >= 1 && n <= 1000) {
//loop for problems num
for (int i = 0; i < arr.length; i++) {
String[] arrItems = scanner2.nextLine().split(" ");
count = 0;
//loop for player num
for (int j = 0; j < 3; j++) {
int arrItem = Integer.parseInt(arrItems[j]);
int x = arrItem;
if (x == 1)
count++;
}
if (count >= 2) {
fin++;
}
}
}
System.out.println(fin);
scanner.close();
}
}`
import java.util.Scanner;
public class CodeForces {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int count = 0 ;
for (int i = 0; i < n; i++) {
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
if ((a ==1 && b == 1) || (a ==1 && c == 1) || (b ==1 && c == 1))
count ++ ;
}
System.out.println(count);
}
}
import java.util.Scanner;
public class CodeForces {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int count = 0 ;
for (int i = 0; i < n; i++) {
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
if ((a ==1 && b == 1) || (a ==1 && c == 1) || (b ==1 && c == 1))
count ++ ;
}
System.out.println(count);
}
}
import java.util.*;
public class TwohundthrityoneA {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n=sc.nextInt();
int count =0; // to count result
for(int i=0;i<n;i++){
int idcount=0; // for indiviual dicision
int a = sc.nextInt();
if(a==1){
idcount++;
}
int b = sc.nextInt();
if(b==1){
idcount++ ;
}
int c = sc.nextInt();
if(c==1){
idcount++ ;
}
if(idcount>=2){
count++ ;
}
}
System.out.println(count);
sc.close();
}
}
here is my code for this problem hope helps