TopCoder

Caido
Waimai

User's AC Ratio

86.0% (166/193)

Submission's AC Ratio

47.3% (275/581)

Tags

Description

小明的數學老師出了一題函數計算的家庭作業,由於筆算的過程非常複雜,請你寫一個程式協助小明以及班上的其他同學進行驗算,以確定計算的結果是正確的。老師所出的題目是這樣的:給定一個整數,請求出函數 f 的值為何?

f(x)={f(x1)h(x)if x>h(x)f(g(x))g(x)if x<h(x)1otherwise
h(y)={1if y<22+h(y1)h(y2)otherwise
g(z)={z21if z22otherwise

Input Format

直接從標準輸入輸入一整數,300<x<300

Output Format

請將計算過後函數 f 的值直接輸出至標準輸出。

Sample Input 1

3

Sample Output 1

-1

Sample Input 2

-2

Sample Output 2

-4

Sample Input 3

-21

Sample Output 3

-1307

Hints

Problem Source

原TIOJ1060 / 95北市賽(prob 2)

Subtasks

No. Testdata Range Score
1 0 14
2 1 14
3 2 14
4 3 14
5 4 14
6 5 14
7 6 16

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 1000 65536 262144 1
1 1000 65536 262144 2
2 1000 65536 262144 3
3 1000 65536 262144 4
4 1000 65536 262144 5
5 1000 65536 262144 6
6 1000 65536 262144 7