Test instructions: There is a piece of 2^n big Nugget, you can only turn one piece into the same two times each time (of course size is the original 1/2), ask you now have capacity a,b,a+b = 2^n's backpack, how many times can make a A, a, and so on all of the gold nugget to put down.
The idea of solving problems: recursion.
Problem Solving Code:
1 //File name:f.cpp2 //Author:darkdream3 //Created time:2015 March 15 Sunday 12:19 58 seconds4 5#include <vector>6#include <list>7#include <map>8#include <Set>9#include <deque>Ten#include <stack> One#include <bitset> A#include <algorithm> -#include <functional> -#include <numeric> the#include <utility> -#include <sstream> -#include <iostream> -#include <iomanip> +#include <cstdio> -#include <cmath> +#include <cstdlib> A#include <cstring> at#include <ctime> - #defineLL Long Long - - using namespacestd; - LL A, b; -LL P (intN) in { -LL sum =1; to for(intI=1; I <= N;i + +) +Sum *=2 ; - returnsum; the } * intSolve (ll T, LL now) $ {Panax Notoginseng //printf ("%lld%lld\n", t,now); - if(T = =Now ) the return 0; + return 1+ Solve (t/2, ABS (now-t/2)); A } the intMain () { + intT; -scanf"%d",&t); $ while(t--) $ { - intN; -scanf"%d%lld%lld",&n,&a,&b); theprintf"%d\n", Solve (P (n), a)-1); - }Wuyi return 0; the}
View Code
GCPC2014 G Gold Rush