Bzoj1621/p2907 [usaco 08open] roads around the farm round the farm

Source: Internet
Author: User

P2907 [usaco 08open] roads around the farm round the farm

Basic DFS: recursively follow the meaning of the question.

1 # include <iostream> 2 # include <cstdio> 3 # include <cstring> 4 # define re register 5 using namespace STD; 6 int N, K, ans; 7 void DFS (int x) {8 If (x <= k | (X-k) & 1) {// No half of the cows (dense fog) 9 + + ans; return; 10} DFS (X-k)/2); DFS (X-k)/2 + k ); // divided into 2 groups 11} 12 INT main () {13 scanf ("% d", & N, & K); DFS (N ); 14 printf ("% d", ANS); 15 return 0; 16}
View code

 

Bzoj1621/p2907 [usaco 08open] roads around the farm round the farm

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.