Cod sursa(job #227880)
| Utilizator | Data | 5 decembrie 2008 18:19:51 | |
|---|---|---|---|
| Problema | Jocul Flip | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.46 kb |
#include<fstream.h>
float max,a[17][17];
int n,m;
void back(int k, int l ,int s)
{ if(k==n-1&&l==m) { if(s>max) max=s;} else {
if(l==m&&k<n-1) back(k+1,0,s);
else { back(k,l+1,s+((a[k][l])*(-1)));
back(k,l+1,s+a[k][l]); } } }
int main()
{ ifstream f("flip.in");
ofstream g("flip.out");
f>>n>>m; int i,j;
for(i=0;i<n;i++)
for(j=0;j<n;j++) { f>>a[i][j]; max+=a[i][j]; }
back(0,0,0);
g<<max;
return 0; }