Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let input = [
- // '3 1 2'
- '2 6 2'
- ];
- let print = this.print || console.log;
- let gets = this.gets || ((arr, index) => () => arr[index++])(input, 0);
- let nums = gets().split(' ').map(Number);
- nums.sort((a, b) => b - a);
- nums = [... new Set(nums)];
- let counter = 0;
- let index = 0;
- while (true) {
- nums[index] -= nums[nums.length - 1];
- if (nums[index] === 0) {
- index++;
- }
- counter++;
- if (index === nums.length) {
- break;
- }
- }
- print(nums);
- print(counter);
Advertisement
Add Comment
Please, Sign In to add comment