Skip to content
This repository has been archived by the owner on Oct 19, 2020. It is now read-only.

Competitive: Java solution #7

Open
wants to merge 2 commits into
base: competitive
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions CodeChef/LTIME88B/astonizer/gcdops.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/* 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 sc = new Scanner(System.in);
PrintWriter pw = new PrintWriter(System.out);
int t = sc.nextInt();
while (t-- > 0) {
int n = sc.nextInt();
int[] b = new int[n];
boolean check = false;
for (int i = 0; i < n; i++) {
b[i] = sc.nextInt();
}
for (int i = 0; i < n; i++) {
if ((i+1) % b[i] != 0) {
check = true;
break;
}
}
if(!check) {
pw.println("YES");
} else {
pw.println("NO");
}
}
pw.flush();
}
}
36 changes: 36 additions & 0 deletions CodeChef/LTIME88B/astonizer/watmelon.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/* 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 sc = new Scanner(System.in);
PrintWriter pw = new PrintWriter(System.out);
int t = sc.nextInt();
while(t-- > 0) {
int n = sc.nextInt();
int[] arr = new int[n];
int flag = 0;
for(int i = 0; i < n; i++) {
arr[i] = sc.nextInt();
}

int sum = 0;
for(int i = 0; i < n; i++) {
sum += arr[i];
}

if(sum < 0) {
System.out.println("NO");
} else {
System.out.println("YES");
}
}
pw.flush();
}
}