Algorithm, Data structure/Solved Algorithmic Problem 120

USACO 1.4 - Arithmetic Progressions

An arithmetic progression is a sequence of the form a, a+b, a+2b, ..., a+nb where n=0,1,2,3,... . For this problem, a is a non-negative integer and b is a positive integer.Write a program that finds all arithmetic progressions of length n in the set S of bisquares. The set of bisquares is defined as the set of all integers of the form p2 + q2 (where p and q are non-negative integers).TIME LIMIT:..

Project Euler #18 - Maximum path sum I

By starting at the top of the triangle below and moving to adjacent numbers on the row below, the maximum total from top to bottom is 23.3 7 4 2 4 6 8 5 9 3That is, 3 + 7 + 4 + 9 = 23.Find the maximum total from top to bottom of the triangle below:75 95 64 17 47 82 18 35 87 10 20 04 82 47 65 19 01 23 75 03 34 88 02 77 73 07 63 67 99 65 04 28 06 16 70 92 41 41 26 56 83 40 80 70 33 41 48 72 33 47 ..

Project Euler #16 - Power digit sum

215 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.What is the sum of the digits of the number 21000? 출처: https://projecteuler.net/ 큰 수의 곱셈은 karatsuba algorithm 을 통해 구했고 2 power 1000 은 divide and conquer algorithm 을 통해 시간 복잡도를 줄였습니다. multiply 메써드는 karatsuba algorithm 포스팅에서 확인하실 수 있습니다. my solvingc++123456789101112131415161718192021222324252627282930#include #include #include #includ..

Codility #1 - BinaryGap

문제: https://codility.com/programmers/task/binary_gap/ Codility 의 첫 번째 문제를 풀어봤습니다. 32비트의 integer가 주어졌을 때 해당 integer 를 binary 로 표현할 때 연속적으로 보이는 0의 개수를 binary gap 이라 할 때 가장 긴 binary gap 를 반환하는 문제입니다.쉬운 문제라 생각하며 별 생각없이 아래와 같이 풀었더니 답은 맞았지만 33% 의 점수를 얻었습니다. my solvingc++123456789101112131415161718192021#include using namespace std; int solution1(int num){ int count = 0; int ret = 0; while (num > 0) { ..