그 밖의 방법들 7

파이썬으로 피보나치 수열을 구하는 여러가지 방법

1. 일반항으로 구하기 오일러가 발견한 수식입니다. 이를 코드로 옮길 시 아래와 같이 됩니다. r=5**(0.5) print(round(((1+r)/2)**int(input())/r)) cs 증명은 위키피디아를 참조 바랍니다. https://en.wikipedia.org/wiki/Fibonacci_number Fibonacci number - Wikipedia From Wikipedia, the free encyclopedia Jump to navigation Jump to search Integer in the infinite Fibonacci sequence A tiling with squares whose side lengths are successive Fibonacci numbers: 1, 1,..

백준 10814 나이순 정렬, 안정 정렬

https://www.acmicpc.net/problem/10814 10814번: 나이순 정렬 온라인 저지에 가입한 사람들의 나이와 이름이 가입한 순서대로 주어진다. 이때, 회원들을 나이가 증가하는 순으로, 나이가 같으면 먼저 가입한 사람이 앞에 오는 순서로 정렬하는 프로그램을 www.acmicpc.net 안정 정렬(Stable sort)에 관한 문제입니다 파이썬안의 sort를 나이순으로 정렬만 하면 되는 문제입니다 import sys n = int(sys.stdin.readline()) lis = [] for i in range(n): lis.append(list(sys.stdin.readline().strip().split())) lis.sort(key= lambda lis : int(lis[0]))..

[nodeJS] 백준 17433: 신비로운 수

https://www.acmicpc.net/problem/17433 17433번: 신비로운 수 첫째 줄에 테스트 케이스의 개수 T가 주어진다. 각 테스트 케이스는 두 줄로 이루어져 있고, 첫째 줄에 N, 둘째 줄에 N개의 정수가 주어진다. www.acmicpc.net const input = require('fs').readFileSync('/dev/stdin').toString().trim().split('\n'); for (let i = 0; i +v); const gcd = (x , y) => { while (y) { let t = x % y; x = y; y = t; } return x; } let tmp, res; for (let i = 1; i 0); for (let j = 1; j

SQL/MySQL의 기초 - WHERE, SubQuery

https://leetcode.com/problems/second-highest-salary/ Second Highest Salary - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 문제를 해석 하자면 두 번째로 높은 임금을 구하여라. 그러나 두 번째 높은 값이 없을 경우에는 null을 출력하라라는 뜻입니다. 그러나 문제를 풀 것은 아니고, 이 문제로 WHERE과 SubQuery를 배워봅시다. 일단 아래의 코드가 위에 링크 문제의 답입니다. SELECT MAX..

빠른 입출력 [node JS] 백준 15552번 - 빠른 A+B, 최대한 다양하게

https://www.acmicpc.net/problem/15552 15552번: 빠른 A+B 첫 줄에 테스트케이스의 개수 T가 주어진다. T는 최대 1,000,000이다. 다음 T줄에는 각각 두 정수 A와 B가 주어진다. A와 B는 1 이상, 1,000 이하이다. www.acmicpc.net 1. 코드 아쉽게도 이 문제는 node JS의 빠른 입출력 중 하나인 require('fs').readFileSync('/dev/stdin').toString().split('\n'); 로만 통과할 수 있습니다. ㅇㄴㅇ let input = require('fs').readFileSync('/dev/stdin').toString().split('\n'); let max = Number(input[0]); let a..

빠른 입출력 [C#] 백준 15552번 - 빠른 A+B, 최대한 다양하게

https://www.acmicpc.net/problem/15552 15552번: 빠른 A+B 첫 줄에 테스트케이스의 개수 T가 주어진다. T는 최대 1,000,000이다. 다음 T줄에는 각각 두 정수 A와 B가 주어진다. A와 B는 1 이상, 1,000 이하이다. www.acmicpc.net 1. 이해하기 쉬운 코드 using System; using System.Text; using System.IO; namespace backjoonmmmmmm { public class Program { public static void Main(string[] args) { StreamReader sr = new StreamReader(new BufferedStream(Console.OpenStandardInpu..

빠른 입출력 [C/C++] 백준 15552번 - 빠른 A+B, 최대한 다양하게

https://www.acmicpc.net/problem/15552 15552번: 빠른 A+B 첫 줄에 테스트케이스의 개수 T가 주어진다. T는 최대 1,000,000이다. 다음 T줄에는 각각 두 정수 A와 B가 주어진다. A와 B는 1 이상, 1,000 이하이다. www.acmicpc.net 핵심 아래의 코드를 main에 넣으시면 cin과 cout의 속도가 비약적으로 상승합니다. ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cs 혹은 아래와 같은 방식으로 적으시고 main에 fastio()를 선언해 줍니다. #define fastio() ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); cs 1..