fork download
  1. /**********************************************************************************/
  2. /* Problem: a293 "A 百年國慶" from 2011 NPSC 國中組初賽 */
  3. /* Language: CPP (613 Bytes) */
  4. /* Result: AC(0.1s, 388KB) judge by this@ZeroJudge */
  5. /* Author: lfs92002 at 2011-12-06 12:35:30 */
  6. /**********************************************************************************/
  7.  
  8.  
  9. #include<iostream>
  10. using namespace std;
  11. int main()
  12. {
  13. int b[5][5],a[5][5];
  14. int T,_x,x,y,sum;
  15.  
  16. cin>>T;
  17. for(y=0;y<5;y++)
  18. for(x=0;x<5;x++)
  19. cin>>a[y][x];
  20.  
  21. for(_x=0;_x<T-1;_x++)
  22. {
  23. for(y=0;y<5;y++)
  24. for(x=0;x<5;x++)
  25. cin>>b[y][x];//c.4
  26. sum=0;
  27. for(y=0;y<5;y++)
  28. for(x=0;x<5;x++)
  29. {
  30. if(a[y][x]==8&&b[y][x]==8)
  31. sum+=5;
  32. else if(a[y][x]==1&&b[y][x]==1)
  33. sum+=1;
  34. else if(a[y][x]==8&&b[y][x]==1)
  35. sum+=2;
  36. else
  37. sum+=7;
  38.  
  39.  
  40. }
  41. cout<<sum<<endl;
  42. for(y=0;y<5;y++)
  43. for(x=0;x<5;x++)
  44. a[y][x]=b[y][x];
  45. }
  46.  
  47.  
  48. return 0;
  49. }
  50.  
Success #stdin #stdout 0s 3300KB
stdin
6

8 1 1 1 8
8 8 1 1 8
8 1 8 1 8
8 1 1 8 8
8 1 1 1 8

8 8 8 8 1
8 1 1 1 8
8 8 8 8 1
8 1 1 1 1
8 1 1 1 1

1 8 8 8 1
8 1 1 1 1
1 8 8 8 1
1 1 1 1 8
8 8 8 8 1

1 8 8 8 1
8 1 1 1 1
8 1 1 1 1
8 1 1 1 1
1 8 8 8 1

1 1 8 1 1
1 1 8 1 1
1 1 8 1 1
1 1 1 1 1
1 1 8 1 1

1 1 8 1 1
1 1 8 1 1
1 1 8 1 1
1 1 1 1 1
1 1 8 1 1
stdout
89
85
70
52
41