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

 

1712번: 손익분기점

월드전자는 노트북을 제조하고 판매하는 회사이다. 노트북 판매 대수에 상관없이 매년 임대료, 재산세, 보험료, 급여 등 A만원의 고정 비용이 들며, 한 대의 노트북을 생산하는 데에는 재료비와

www.acmicpc.net

const fs = require('fs');
const input = fs.readFileSync('/dev/stdin').toString().split(" ");
 
const A = Number(input[0]);
const B = Number(input[1]);
const C = Number(input[2]);
 
// B >= C 손익분기점 없음
if(B >= C) console.log(-1);
else {
    let D = Math.abs((A/(B-C))-1);
    console.log(Math.floor(D));
}
728x90

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

 

9093번: 단어 뒤집기

첫째 줄에 테스트 케이스의 개수 T가 주어진다. 각 테스트 케이스는 한 줄로 이루어져 있으며, 문장이 하나 주어진다. 단어의 길이는 최대 20, 문장의 길이는 최대 1000이다. 단어와 단어 사이에는

www.acmicpc.net

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

const N = Number(input[0])

for(let i = 1 ; i <= N ; i++) {
    const string = input[i].split(" ");
    string.forEach((s, index) => {
        const tmp = s.split("");
        tmp.reverse();
        string[index] = tmp.join("");
    });
    console.log(string.join(" "));
};
728x90

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

 

10808번: 알파벳 개수

단어에 포함되어 있는 a의 개수, b의 개수, …, z의 개수를 공백으로 구분해서 출력한다.

www.acmicpc.net

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

const dic = {
    a: 0,
    b: 0,
    c: 0,
    d: 0,
    e: 0,
    f: 0,
    g: 0,
    h: 0,
    i: 0,
    j: 0,
    k: 0,
    l: 0,
    m: 0,
    n: 0,
    o: 0,
    p: 0,
    q: 0,
    r: 0,
    s: 0,
    t: 0,
    u: 0,
    v: 0,
    w: 0,
    x: 0,
    y: 0,
    z: 0,
}

input.forEach((d) => {
    if(dic[d] !== undefined ) dic[d]++;
});

const keyList = Object.keys(dic);

keyList.forEach((key) => {
    answer.push(dic[key]);
});

console.log(answer.join(" "));
728x90

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

 

2744번: 대소문자 바꾸기

영어 소문자와 대문자로 이루어진 단어를 입력받은 뒤, 대문자는 소문자로, 소문자는 대문자로 바꾸어 출력하는 프로그램을 작성하시오.

www.acmicpc.net

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

input.forEach((i, index) => {
    if(i.charCodeAt() >= 65 && i.charCodeAt() <= 90) {
        input[index] = String.fromCharCode(i.charCodeAt()+32);
    } else {
        input[index] = String.fromCharCode(i.charCodeAt()-32);
    }
})

console.log(input.join(""));
728x90

+ Recent posts