Description
The cows have a line of 20 water bowls from which they drink. The bowls can be either right-side-up (properly oriented to serve refreshing cool water) or upside-down (a position which holds no water). They want all 20 water bowls to be right-side-up and thus use their wide snouts to flip bowls.Input
Line 1: A single line with 20 space-separated integersOutput
Line 1: The minimum number of bowl flips necessary to flip all the bowls right-side-up (i.e., to 0). For the inputs given, it will always be possible to find some combination of flips that will manipulate the bowls to 20 0's.Sample Input
0 0 1 1 1 0 0 1 1 0 1 1 0 0 0 0 0 0 0 0
Sample Output
3
Hint
Explanation of the sample:Source
USACO 2006 January Bronze
高斯消元的簡單題:
#include#include #include #include using namespace std; int a[24][24],x[24]; int equ,var;//方程數和變元數 void Debug() { for(int i=0;i a[max_r][col]) max_r=j; } if(max_r!=i) { for(int k=0;k<=var;k++) { swap(a[i][k],a[max_r][k]); } } if(a[i][col]==0) { i--; continue; } for(int j=i+1;j 0?1:0; sum=0; for(int i=equ-2;i>=0;i--) { int temp=a[i][var]; for(int j=i+1;j