https://www.algospot.com/judge/problem/read/JOSEPHUS# algospot.com :: JOSEPHUS 조세푸스 문제 문제 정보 문제 1세기에 살던 역사학자 조세푸스는 로마와의 전쟁에서 패해 N - 1명의 동료 병사들과 함께 출구가 없는 동굴에 포위당했다고 합니다. 동료 병사들은 로마에 항복하 www.algospot.com list를 이용해서 원형 연결 리스트를 구현한다. #include #include using namespace std; void josephus(int n, int k) { list survivors; for (int i = 1; i 2) { kill = survivors.erase(kill); if (kill == survivors.end()) ..
https://algospot.com/judge/problem/read/TRIPATHCNT algospot.com :: TRIPATHCNT 삼각형 위의 최대 경로 수 세기 문제 정보 문제 9 5 7 1 3 2 3 5 5 6 위 형태와 같이 삼각형 모양으로 배치된 자연수들이 있습니다. 맨 위의 숫자에서 시작해, 한 번에 한 칸씩 아래로 내려가 맨 아래 algospot.com count(x,y) = (x,y)에서 시작해 맨 아래줄까지 내려가는 최대 경로의 수 #include #include #include using namespace std; int n,triangle[100][100]; int cache[100][100],countCache[100][100]; int path(int x,int y) { i..
https://algospot.com/judge/problem/read/TILING2 algospot.com :: TILING2 타일링 문제 정보 문제 2xn 크기의 사각형을 2x1 크기의 사각형으로 빈틈없이 채우는 경우의 수를 구하는 프로그램을 작성하세요. 예를 들어 n=5라고 하면 다음 그림과 같이 여덟 가지의 방법이 있 algospot.com tiling(n) = 2*n 크기의 사각형을 타일로 덮는 방법을 반환한다 tiling(n) = tiling(n-1) + tiling(n-2) #include #include const int MOD=1000000007; int cache[101]; int tiling(int n) { if(n