-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
vishal
authored and
vishal
committed
Jul 25, 2024
1 parent
2ff4dd5
commit f469346
Showing
4 changed files
with
29 additions
and
24 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,26 @@ | ||
[ | ||
{ | ||
"input": 0, | ||
"output": 32 | ||
}, | ||
{ | ||
"input": -40, | ||
"output": -40 | ||
}, | ||
{ | ||
"input": 100, | ||
"output": 212 | ||
}, | ||
{ | ||
"input": 37, | ||
"output": 98.6 | ||
}, | ||
{ | ||
"input": -17.78, | ||
"output": 0 | ||
function intersect(A) { | ||
function gcd(a, b) { | ||
while (b) { | ||
[a, b] = [b, a % b]; | ||
} | ||
return a; | ||
} | ||
] | ||
|
||
let g = A[0]; | ||
for (let i = 1; i < A.length; i++) { | ||
g = gcd(g, A[i]); | ||
if (g === 1) { | ||
break; | ||
} | ||
} | ||
|
||
return g === 1 ? "Yes" : "No"; | ||
} | ||
|
||
|
||
const input = require('fs').readFileSync('/Users/vishal/Desktop/PROJECTS/algoearth/apps/problems/Intersting-Arrays/tests/inputs/5.txt', 'utf8').trim().split('\n').join(' ').split(' '); | ||
const size_A = parseInt(input.shift()); | ||
const A = input.splice(0, size_A).map(Number); | ||
const result = intersect(A); | ||
console.log(result); | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
Yes | ||
No |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
No | ||
Yes |