PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#QHD0000009. Homer Simpson ăn bánh (Homer Simpson)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Homer Simpson ăn bánh (Homer Simpson)

Homer Simpson

Source: UVa

Version: Phuoc Hung OJ Extended

Problem Statement

Homer has tt minutes to eat burgers. There are two burger types: each burger of the first type takes mm minutes to eat, and each burger of the second type takes nn minutes. Only whole burgers may be eaten.

Choose how many burgers of each type to eat so that the unused time is minimized. Among choices with the same minimum unused time, maximize the total number of burgers eaten.

If no time is left unused, print only the number of burgers. Otherwise print the number of burgers followed by the unused time.

Input

One line contains three integers mm, nn, and tt: the eating times for the two burger types and the total time available.

Output

If the minimum unused time is 00, print the maximum number of burgers. Otherwise print two integers, the maximum number of burgers and the minimum unused time, separated by one space.

Subtasks

  • Subtask 1 (20 points): 1≤m≤401\le m\le 40; 1≤n≤401\le n\le 40; 1≤t≤401\le t\le 40.
  • Subtask 2 (30 points): 1≤m≤10001\le m\le 1000; 1≤n≤10001\le n\le 1000; 1≤t≤10001\le t\le 1000.
  • Subtask 3 (50 points): 1≤m≤99991\le m\le 9999; 1≤n≤99991\le n\le 9999; 1≤t≤99991\le t\le 9999.

Examples

Input

3 5 54

Output

18

Explanation

Eating 1818 burgers of the 33-minute type takes 18⋅3=5418\cdot3=54 minutes. There is no leftover time, so the output is only 18.