In fact, the Beijing station DP are not expected to be difficult.
But.. ..
Dp[x,y] Indicates the number of scenarios with the first X number of XOR values ==y
When transferring, you can first assign the upper level fully to this layer and assume that a[i] does not participate in XOR
Then A[i] is different from the upper value or needs to traverse all the scenarios 2 times
I was worried about Tle, but N was only 40.
I didn't use the scroll array to open the 40 directly at first.
Then an open scrolling array I don't know why I've been re ...
A long time to find that I will dp[x,y] the first open to 3 can be opened into 2 No, I'm depressed.
Obviously only can take 0 or 1 ah because the result of num&1 is not only 0 or 1?
No words ...
Not to understand. If I understand, I'll make up the reason below.
1#include <iostream>2#include <cstring>3 using namespacestd;4 5typedefLong LongLL;6 intN;7 Const intSize =1000000;8LL dp[2][size+Ten];9 inta[ $];Ten One voidSolve () A { - for(inti =1; I<=n; i++ ) - { the for(intj =0; J<=size; J + + ) - { -dp[i&1][J] = dp[! ( i&1)][j]; - } + for(intj =0; J<=size; J + + ) - { +dp[i&1] [J^a[i]] + = dp[! ( i&1)][j]; A } at } - } - - intMain () - { -Cin.sync_with_stdio (false); in intT, M; - LL ans; toCIN >>T; + for(intK =1; k<=t; k++ ) - { theCIN >> N >>m; *Memset (DP,0,sizeof(DP)); $ for(inti =1; I<=n; i++ )Panax Notoginseng { -CIN >>A[i]; the } +dp[0][0] =1; AAns =0; the solve (); + for(inti = m; I<=size; i++ ) - { $Ans + = dp[n&1][i]; $ } -cout <<"Case #"<< k <<": "<< ans <<Endl; - } the return 0; -}View Code
1#include <iostream>2#include <cstring>3 using namespacestd;4 5typedefLong LongLL;6 intN;7 Const intSize =1000000;8LL dp[3][size+Ten];9 inta[ $];Ten One voidSolve () A { - for(inti =1; I<=n; i++ ) - { the for(intj =0; J<=size; J + + ) - { -dp[i&1][J] = dp[! ( i&1)][j]; - } + for(intj =0; J<=size; J + + ) - { +dp[i&1] [J^a[i]] + = dp[! ( i&1)][j]; A } at } - } - - intMain () - { -Cin.sync_with_stdio (false); in intT, M; - LL ans; toCIN >>T; + for(intK =1; k<=t; k++ ) - { theCIN >> N >>m; *Memset (DP,0,sizeof(DP)); $ for(inti =1; I<=n; i++ )Panax Notoginseng { -CIN >>A[i]; the } +dp[0][0] =1; AAns =0; the solve (); + for(inti = m; I<=size; i++ ) - { $Ans + = dp[n&1][i]; $ } -cout <<"Case #"<< k <<": "<< ans <<Endl; - } the return 0; -}View Code
Today
Nightmare
It's raining.
Waiting for a man's coffee
Waiting for a phone call from a person
hdu--5119--number of decision scenarios DP