https://www.acmicpc.net/problem/1271

 

1271번: 엄청난 부자2

첫째 줄에는 최백준 조교가 가진 돈 n과 돈을 받으러 온 생명체의 수 m이 주어진다. (1 ≤ m ≤ n ≤ 101000, m과 n은 10진수 정수)

www.acmicpc.net

const fs = require('fs');
const input = fs.readFileSync('/dev/stdin').toString().split(" ");

const n = BigInt(input[0]);
const m = BigInt(input[1]);

console.log((n/m).toString());
console.log((n%m).toString());
728x90

https://www.acmicpc.net/problem/10828

 

10828번: 스택

첫째 줄에 주어지는 명령의 수 N (1 ≤ N ≤ 10,000)이 주어진다. 둘째 줄부터 N개의 줄에는 명령이 하나씩 주어진다. 주어지는 정수는 1보다 크거나 같고, 100,000보다 작거나 같다. 문제에 나와있지

www.acmicpc.net

const fs = require('fs');
const input = fs.readFileSync('/dev/stdin').toString().trim().split("\n");

const N = Number(input[0]);
const stack = [];
const result = [];

for(let i = 0 ;i < N ; i++) {
    const command = input[i+1].split(" ");
    if(command[0] === 'push') {
        stack.push(Number(command[1]));
    } else if(command[0] === 'pop') {
        result.push(stack.length === 0 ? -1 : stack.pop());
    } else if(command[0] === 'size') {
        result.push(stack.length);
    } else if(command[0] === 'empty') {
        result.push(stack.length === 0 ? 1 : 0);
    } else if(command[0] === 'top'){
        result.push(stack.length === 0 ? -1 : stack[stack.length-1]);
    }
}

console.log(result.join("\n"));
728x90

+ Recent posts