목록Computer/Coding Test (70)
Machineboy空
n = int(input()) count = 1 start_index = 1 end_index = 1 sum = 1 while end_index !=n: if sum == n: count +=1 end_index +=1 sum += end_index elif sum >n: sum -= start_index start_index +=1 else: end_index +=1 sum += end_index print(count) 오답 이유) 이런 똑똑한 알고리즘이 있다니
문제설명 머쓱이는 태어난 지 6개월 된 조카를 돌보고 있습니다. 조카는 아직 "aya", "ye", "woo", "ma" 네 가지 발음을 최대 한 번씩 사용해 조합한(이어 붙인) 발음밖에 하지 못합니다. 문자열 배열 babbling이 매개변수로 주어질 때, 머쓱이의 조카가 발음할 수 있는 단어의 개수를 return하도록 solution 함수를 완성해주세요. 제한사항 1
using System; using System.Collections.Generic; namespace CodingTestForBaekJoon { class Program { static void Main(string[] args) { //1: 시험 본 과목 개수 N //2. 현재 성적 (N개의 성적 중 최댓값 M) int N = int.Parse(Console.ReadLine()); string[] scores = Console.ReadLine().Split(); float[] scoreNum = new float[N]; for(int i = 0; i < scores.Length; i++) { scoreNum[i] = float.Parse(scores[i]); } //최댓값 구하기 float M = 0..
private void UpdateSearch() { // Scene에 배치된 타워들을 모두 찾아서 GameObject[] towers = GameObject.FindGameObjectsWithTag("Tower"); // 최단거리, 선택배열번호 float distance = float.MaxValue; int chooseIndex = -1;//index로 들어갈 수 없는 -1을 넣는다. for (int i = 0; i < towers.Length; i++) { // 타워와 나와의 거리를 재고 float temp = Vector3.Distance(towers[i].transform.position, transform.position); // 그 거리가 최단거리보다 작다면 if (temp < distanc..
//시간 초과 코드 using System; namespace CodingTestForBaekJoon { class Program { static void Main(string[] args) { string T = Console.ReadLine(); int numT = Int32.Parse(T); for (int i = 0; i < numT; i++) { string[] pair = Console.ReadLine().Split(); int A = Int32.Parse(pair[0]); int B = Int32.Parse(pair[1]); int Sum = A + B; Console.WriteLine(Sum); } } } } 원인) string을 사용해 출력하게 되면 처리 속도가 느리다. int, floa..
using System; namespace CodingTestForBaekJoon { class Program { static void Main(string[] args) { //\역슬래쉬 쓰려면 \\ Console.WriteLine("|\\_/|"); Console.WriteLine("|q p| /}"); //"따옴표 쓰려면 \" Console.WriteLine("( 0 )\"\"\"\\"); Console.WriteLine("|\"^\"` |"); Console.WriteLine("||_/=\\\\__|"); } } } using System; namespace CodingTestForBaekJoon { class Program { static void Main(string[] args) { Cons..