The main topic: There are n blocks of stone, gifts on the block M stone, the distance of adjacent stones is 1, the first step of the small frog to jump to the first stone, the next jump to conform to the rule, assuming this is the nth jump, then the small frog jumping distance is (2 * n-1), and each jump must jump to the stone
Problem-solving ideas: If the number of stones more than 49, the small frog can jump to any stone, the other situation only a violent Dfs can be solved
#include <cstdio>#include <cstring>int POS, Len;bool DFS (intCurint Time) {if(cur = =POS)returnTrueintL = Time*2-1;if(cur + l <= len && dfs (cur + l, Time+1))returnTrueif(Cur-l >0&& Dfs (Cur-l, Time+1))returnTruereturnfalse;}intMain () {intNm; while(SCANF ("%d%d", &len, &POS) ==2&& Len +POS) {if(Len >= -) {printf("Let me try!\n");Continue; }if(Dfs (1,2))printf("Let me try!\n");Else printf("Don ' t make fun of me!\n"); }return 0;}
UVA-10120 gift?! Violence + Regularity