Link: http://acm.hdu.edu.cn/showproblem.php? PID = 1, 4814
The Golden Ratio split point is that a 10-digit number is now required to be converted into a phi-hexadecimal number, and '11' is not allowed.
Idea: because the question contains two sub-statements, the question becomes a simple simulation question. Since the number of pHi in the system is only 200 at most, and the data is only 100 bits at most, the simulation can start from AA [50] = tot.
Code:
# Include <iostream> # include <cstdio> # include <cstring> # include <cmath> # include <map> # include <cstdlib> # include <queue> # include <stack> # include <vector> # include <ctype. h >#include <algorithm> # include <string> # include <cstdlib> # define PI ACOs (-1.0) # define maxn 10005 # define INF 0x7fffffusing namespace STD; int main () {int AA [105]; int tot; while (~ Scanf ("% d", & ToT) {memset (AA, 0, sizeof (AA); AA [50] = tot; while (1) {bool flag = 0; For (INT I = 0; I <= 100; I ++) {If (AA [I]> 1) {flag = 1; AA [I + 1] + = (AA [I]/2); AA [I-2] + = (AA [I]/2 ); AA [I] % = 2 ;}}for (INT I = 0; I <= 100; I ++) {If (AA [I]> 0 & aa [I + 1]> 0) {flag = 1; int T = min (AA [I], AA [I + 1]); AA [I + 2] + = T; AA [I + 1]-= T; AA [I]-= T ;}} if (flag = 0) break;} int head, tail; For (INT I = 100; I --) {If (AA [I] = 1) {head = I; break ;}}for (INT I = 0; I ++) {If (AA [I] = 1) {tail = I; break ;}for (INT I = head; I> = tail; I --) {if (I = 49) printf (". "); printf (" % d ", AA [I]);} printf (" \ n ");} return 0 ;}
HDU 4814 golden radio base small Simulation