Kangaroo .. sum

Run Settings
LanguageJavaScript
Language Version
Run Command
function processData(input) { var arr,k_1_speed,k_2_speed,k_1,k_2; arr = input.split(' '); k_1_speed = arr[1]; k_1 = arr[0]; k_2_speed = arr[3]; k_2 = arr[2]; for (let i = k_1 ; i < 100 ; i += k_1_speed ) { console.log(i); } console.log(k_1); } function processData(input) { var arr,k_1_speed,k_2_speed,k_1,k_2,i,arr1,arr2; arr = input.split(' '); arr1 = []; arr2 = []; k_1_speed = Number(arr[1]); k_1 = Number(arr[0]); k_2_speed = Number(arr[3]); k_2 = Number(arr[2]); for ( i = k_1 ; i < 100000; i += k_1_speed ) { arr1.push(i); } for ( i = k_2 ; i < 100000 ; i += k_2_speed ) { arr2.push(i); } for (let k = 0; k < 10001; k++) { if (Number(arr1[k]) == Number(arr2[k])) { console.log("YES"); break; } if (k==10000){ console.log("NO"); } } } process.stdin.resume(); process.stdin.setEncoding("ascii"); _input = ""; process.stdin.on("data", function (input) { _input += input; }); process.stdin.on("end", function () { processData(_input); });
process.stdin.resume(); process.stdin.setEncoding('ascii'); var input_stdin = ""; var input_stdin_array = ""; var input_currentline = 0; process.stdin.on('data', function (data) { input_stdin += data; }); process.stdin.on('end', function () { input_stdin_array = input_stdin.split("\n"); main(); }); function readLine() { return input_stdin_array[input_currentline++]; } /////////////// ignore above this line //////////////////// function main() { var x1_temp = readLine().split(' '); var x1 = parseInt(x1_temp[0]); var v1 = parseInt(x1_temp[1]); var x2 = parseInt(x1_temp[2]); var v2 = parseInt(x1_temp[3]); var l1 = x1; var l2 = x2; for (var i=0; i< 10001; i++){ l1+=v1; l2+=v2; if(l1 == l2){ console.log("YES"); return; } } console.log("NO"); }
Editor Settings
Theme
Key bindings
Full width
Lines