|
//#region Important Character Codes |
|
"A".charCodeAt(0) == 65; // code of capital A |
|
"Z".charCodeAt(0) == 90; // code of capital Z |
|
"a".charCodeAt(0) == 97; // code of a small |
|
"z".charCodeAt(0) == 122; // code of z small |
|
|
|
// Do - 96 to make [a] small = 1; |
|
// Do - 65 to make [A] capital = 1; |
|
//#endregion |
|
|
|
//#region To check if char is capital, it'll be true on both if it's not a char |
|
var character = "Z"; |
|
if (character === character.toUpperCase()) { |
|
console.log("upper case true"); |
|
} |
|
|
|
if (character === character.toLowerCase()) { |
|
console.log("lower case true"); |
|
} |
|
//#endregion |
|
|
|
//#region sum mod of list of numbers |
|
const M = parseInt(readline()); // (number) |
|
const N = parseInt(readline()); // (number) |
|
var inputs = readline().split(" "); // (string[]) |
|
var sum = 0; |
|
|
|
for (let i = 0; i < N; i++) { |
|
const E = parseInt(inputs[i]); |
|
sum += E % M; |
|
} |
|
console.log(sum); |
|
//#endregion |
|
|
|
//#region substring |
|
// substring(start, end (not included)) |
|
// http://net-informations.com/js/iq/substr.htm#:~:text=The%20substr()%20method%20extracts,the%20end%20of%20the%20string. |
|
// Don't use substr() |
|
// #endregion substr |
|
|
|
//#region Given two numbers, A and B, return the number of squares between A and B inclusive. |
|
/* |
|
|
|
|
|
Between A = 1 and B = 9 inclusive are 3 squares: 1, 4, and 9 |
|
Between A = 10 and B = 25 inclusive are 2 squares: 16 and 25 |
|
Between A = 26 and B = 35 inclusive are 0 squares |
|
*/ |
|
|
|
// https://www.geeksforgeeks.org/find-number-perfect-squares-two-given-numbers/ |
|
const a = parseInt(readline()); |
|
const b = parseInt(readline()); |
|
var c = 0; |
|
for (var i = a; i <= b; i++) { |
|
for (var j = 1; j * j <= i; j++) { |
|
if (j * j == i) { |
|
c++; |
|
} |
|
} |
|
} |
|
console.log(); |
|
// #endregion |
|
|
|
// Array rotation code: https://www.geeksforgeeks.org/array-rotation/ |
|
|
|
// Rest of the important Useful JS Methods on my Notion: |
|
// https://www.notion.so/maddada/Useful-JS-Methods-Algorithms-07192cd3faaf44b4a596331916d23b98 |