๋ฌธ์ œ

์ปดํ“จํ„ฐ๋ฅผ ์ด์šฉํ•˜๋ฉด ์ˆ˜ํ•™ ๊ณ„์‚ฐ์ด ์กฐ๊ธˆ ์‰ฌ์›Œ์ง„๋‹ค. ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์˜ˆ๋ฅผ ์‚ดํŽด๋ณด์ž. ์„ธ ๋ณ€์˜ ๊ธธ์ด๊ฐ€ a, b, c(c๋Š” ๋น—๋ณ€)์ด๋ฉด์„œ a2+b2=c2๋ฅผ ๋งŒ์กฑํ•˜๋Š” ์‚ผ๊ฐํ˜•์„ ์ง๊ฐ์‚ผ๊ฐํ˜•์ด๋ผ๊ณ  ํ•œ๋‹ค. ์ด ๊ณต์‹์€ ํ”ผํƒ€๊ณ ๋ผ์Šค์˜ ๋ฒ•์น™์ด๋ผ๊ณ  ํ•œ๋‹ค.

์ง๊ฐ ์‚ผ๊ฐํ˜•์˜ ๋‘ ๋ณ€์˜ ๊ธธ์ด๊ฐ€ ์ฃผ์–ด์กŒ์„ ๋•Œ, ํ•œ ๋ณ€์˜ ๊ธธ์ด๋ฅผ ๊ตฌํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค.

 

 

์ž…์ถœ๋ ฅ ์˜ˆ์‹œ

 

ํ•ด๊ฒฐ

const fs = require('fs');
const { start } = require('repl');
const stdin = (process.platform === 'linux'
    ? fs.readFileSync('/dev/stdin').toString()
    : `6 -1 6
3 4 -1
-1 2 7
5 -1 3
0 0 0` 
).match(/[^\r\n]+/g);

const input = (() => {
let line = 0;
  return () => stdin[line++];
})();

let i = 1;
let answer=[];

while (true) {
  const s = input().split(' ').map(Number)

  if (s[0] === 0) break;

  const area = s.indexOf(-1)
  const arr = ['a','b','c']

  if (arr[area] == 'a') {
    const sq = (s[2]**2) - (s[1]**2)
    const line = (Math.sqrt(sq)).toFixed(3)
    
    if (line < s[2]  && line != 0){
      answer.push(`Triangle #${i}\n${arr[area]} = ${line}`)
    } else {
      answer.push(`Triangle #${i}\nImpossible.`)
    } 
  }

  if (arr[area] == 'b') {
    const sq = (s[2]**2) - (s[0]**2)
    const line = (Math.sqrt(sq)).toFixed(3)
    
    if (line < s[2] && line != 0){
      answer.push(`Triangle #${i}\n${arr[area]} = ${line}`)
    } else {
      answer.push(`Triangle #${i}\nImpossible.`)
    } 
  }

  if (arr[area] == 'c') {
    const sq = (s[0]**2) + (s[1]**2)
    const line = (Math.sqrt(sq)).toFixed(3)
    
    if (line > s[2] && line != 0){
      answer.push(`Triangle #${i}\n${arr[area]} = ${line}`)
    } else {
      answer.push(`Triangle #${i}\nImpossible.`)
    } 
  }

  i++;
}

console.log(answer.join('\n\n'))

๋ฌธ์ œ

ํŒฌ๊ทธ๋žจ์€ ์•ŒํŒŒ๋ฒณ์˜ ๋ชจ๋“  ๊ธ€์ž๋“ค์„ ์‚ฌ์šฉํ•ด์„œ ๋งŒ๋“  ๋ฌธ์žฅ์ด๋‹ค. "the quick brown fox jumps over a lazy dog"๊ณผ "jackdaws loves my big sphinx of quartz"์€ ํŒฌ๊ทธ๋žจ์ด๋‹ค. ๋ฌธ์žฅ์ด ์ฃผ์–ด์กŒ์„ ๋•Œ, ํŒฌ๊ทธ๋žจ์ธ์ง€ ์•„๋‹Œ์ง€๋ฅผ ์•Œ์•„๋‚ด๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค.

 

์ž…์ถœ๋ ฅ ์˜ˆ์‹œ

 

ํ•ด๊ฒฐ

const fs = require('fs');
const { start } = require('repl');
const stdin = (process.platform === 'linux'
    ? fs.readFileSync('/dev/stdin').toString()
    : `jackdawf loves my big quartz sphinx
abcdefghijklmnopqrstuvwxyz
hello world
*` 
).match(/[^\r\n]+/g);

const input = (() => {
let line = 0;
  return () => stdin[line++];
})();


let answer = [];

while (true) {
  const str = input().replace(/ /g,'').split('')
  if (str == '*') break;

  let temp = [];
  str.map((e) => {
    if (!temp.includes(e)){
      temp.push(e)    
    } 
 
  })
  
  const result = temp.length == 26? 'Y' : 'N'
  answer.push(result)
}

console.log(answer.join('\n'))

๋ฌธ์ œ

์ค€๋ฏผ์ด๋Š” ํƒ„์‚ฐ ์Œ๋ฃŒ๋ฅผ ์ข‹์•„ํ•œ๋‹ค. ํƒ„์‚ฐ ์Œ๋ฃŒ๋ฅผ ์‚ฌ๋А๋ผ ๋ˆ์„ ๋‹ค ์จ๋ฒ„๋ ธ๊ธฐ ๋•Œ๋ฌธ์—, ์ด์ œ ์ค€๋ฏผ์ด๋Š” ๊ฐ€์ง„ ๋ˆ์ด ์—†์–ด ํƒ„์‚ฐ ์Œ๋ฃŒ๋ฅผ ์‚ฌ๋จน์„ ์ˆ˜ ์—†๋‹ค.

์ค€๋ฏผ์ด๋Š” ํ•ญ์ƒ ๋ฒ•์„ ์ง€ํ‚ค๋ฉฐ ์‚ฌ๋Š” ์‚ฌ๋žŒ์ด๊ธฐ ๋•Œ๋ฌธ์—, ์•„๋ฌด๋ฆฌ ํƒ„์‚ฐ ์Œ๋ฃŒ๊ฐ€ ๋จน๊ณ  ์‹ถ์–ด๋„ ํ›”์น˜์ง€ ์•Š๋Š”๋‹ค. ๋”ฐ๋ผ์„œ, ๋ฒ•์ ์œผ๋กœ ๋ฌธ์ œ๊ฐ€ ์—†๋Š” ๋ฐฉ๋ฒ•์œผ๋กœ ํƒ„์‚ฐ ์Œ๋ฃŒ๋ฅผ ๊ตฌ๋งคํ•  ๊ฒƒ์ด๋‹ค.

๋งˆ์นจ ๋นˆ ๋ณ‘์„ ํŠน์ • ๊ฐœ์ˆ˜๋งŒํผ ๊ฐ€์ ธ๊ฐ€๋ฉด, ์ƒˆ ๋ณ‘์œผ๋กœ ๋ฐ”๊พธ์–ด์ฃผ๋Š” ์ด๋ฒคํŠธ๊ฐ€ ์ง„ํ–‰์ค‘์ด๋‹ค. ์ค€๋ฏผ์ด๋Š” ๊ธธ์—์„œ ๋นˆ ๋ณ‘์„ ์—ด์‹ฌํžˆ ์ฐพ์€ ๋’ค, ํƒ„์‚ฐ ์Œ๋ฃŒ๋ฅผ ๋จน์œผ๋ ค๊ณ  ํ•œ๋‹ค.

์ค€๋ฏผ์ด๊ฐ€ ํ˜„์žฌ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ๋นˆ ๋ณ‘์˜ ์ˆ˜์™€ ๊ธธ์—์„œ ๋ฐœ๊ฒฌํ•œ ๋นˆ ๋ณ‘์˜ ์ˆ˜, ์ƒˆ ๋ณ‘์œผ๋กœ ๋ฐ”๊พธ๋Š”๋ฐ ํ•„์š”ํ•œ ๋นˆ ๋ณ‘์˜ ์ˆ˜๊ฐ€ ์ฃผ์–ด์กŒ์„ ๋•Œ, ์ค€๋ฏผ์ด๊ฐ€ ํƒ„์‚ฐ ์Œ๋ฃŒ๋ฅผ ๋ช‡ ๊ฐœ ๋จน์„ ์ˆ˜ ์žˆ๋Š”์ง€ ๊ตฌํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค.

 

์ž…์ถœ๋ ฅ ์˜ˆ์‹œ

 

ํ•ด๊ฒฐ

const fs = require('fs');
const { start } = require('repl');
const stdin = (process.platform === 'linux'
    ? fs.readFileSync('/dev/stdin').toString()
    : `5 5 2` 
).match(/[^\r\n]+/g);

const input = (() => {
let line = 0;
  return () => stdin[line++];
})();

let s = input().split(' ').map(Number)

let hav = s[0]+s[1]
let chg = 0;
let i=0;
while (true) {
  if (hav < s[2]) break;

  const toChg = Math.floor(hav/s[2])
  const left = hav%s[2]
  chg+=toChg
  hav =toChg+left
  i++;
}

console.log(chg)

+ Recent posts