시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
2 초 (언어별 추가 시간 없음) 128 MB 238 40 25 25.773%

문제

조세퍼스 문제는 아래와 같이 풀 수 있다.

r := 0;
for i from 1 to n do
    r := (r + k) mod i;
return r;

하지만 상근이는 코드를 잘못 읽고 아래와 같이 작성했다.

r := 0;
for i from 1 to n do
    r := r + (k mod i);
return r;

n과 k가 주어졌을 때, 상근이의 잘못 작성한 소스를 실행시킨 결과를 출력하는 프로그램을 작성하시오.

입력

첫 줄에 n과 k가 주어진다. (1 ≤ n, k ≤ 109)
 

출력

첫째 줄에 주어진 n과 k로 상근이의 잘못 작성한 소스의 결과를 출력한다.

예제 입력 1

5 3

예제 출력 1

7
W3sicHJvYmxlbV9pZCI6IjEyMTUiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWM3OThcdWJhYmIgXHVjNzkxXHVjMTMxXHVkNTVjIFx1Yzg3MFx1YzEzOFx1ZDM3Y1x1YzJhNCBcdWNmNTRcdWI0ZGMiLCJkZXNjcmlwdGlvbiI6IjxwPlx1Yzg3MFx1YzEzOFx1ZDM3Y1x1YzJhNCBcdWJiMzhcdWM4MWNcdWIyOTQgXHVjNTQ0XHViNzk4XHVjNjQwIFx1YWMxOVx1Yzc3NCBcdWQ0ODAgXHVjMjE4IFx1Yzc4OFx1YjJlNC48XC9wPlxyXG5cclxuPHByZSBjbGFzcz1cImJydXNoOmMrKzsgdG9vbGJhcjpmYWxzZTtcIj5cclxuciA6PSAwO1xyXG5mb3IgaSBmcm9tIDEgdG8gbiBkb1xyXG4gICAgciA6PSAociArIGspIG1vZCBpO1xyXG5yZXR1cm4gcjs8XC9wcmU+XHJcblxyXG48cD5cdWQ1NThcdWM5YzBcdWI5Y2MgXHVjMGMxXHVhZGZjXHVjNzc0XHViMjk0IFx1Y2Y1NFx1YjRkY1x1Yjk3YyBcdWM3OThcdWJhYmIgXHVjNzdkXHVhY2UwIFx1YzU0NFx1Yjc5OFx1YzY0MCB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