UVA-10120 gift?! Violence + Regularity

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.