标签:水题
As you know, Flandre Scarlet loves her elder sister Remilia Scarlet, and of course, Remilia loves Flandre, too. But because of Flandre‘s unstable personality and incredible destructive power, Remilia has asked Flandre not to leave Scarlet Devil Mansion for nearly 500 years. The life of Flandre is so boring that it‘s no surprising that she did some unimaginable things. To solve this problem, Remilia decides to give a interesting big cubic toy to Flandre and tell her how to play so that Flandre can have fun.
The interesting toy‘s length is L meters, while its width is W meters and height is H meters. And, the toy can be split into L * W * H standard cube. The length, width and height of the standard cubes are all 1 meter.
Remilia prints a number on each standard cube. What‘s more, Flandre can add or subtract a same integer on two adjacent standard cube for arbitary times. Two cubes are adjacent if they share the same surface.
The goal of this game is making all the number become 0. Can you help Flandre to solve the problem to get some candies from her sister Remilia?
There are multiple test cases.
Each test case consists of two parts.
The first part contains a single line with three integers: L, W, H (1 ≤ L, W, H ≤ 4).
The second part consists of L sections. Each section consists of W lines, each line consists of H integers. In lth section, the hth integer of the wth line denotes the number in the given cube. All numbers are in range [0, 100].
There is a blank line between every two cases.
One line for each case. If Flandre can success, you should print "Yes" (ignore quotes), otherwise you should print "No" (ignore quotes).
1 1 1 1 2 2 2 1 1 1 1 1 1 1 1
No Yes
#include<iostream> #include<cstdio> #include<cmath> using namespace std; int main() { int cnt1,cnt2; int i,j,k,l,w,h; while(cin>>l>>w>>h) { cnt1=cnt2=0; int x; for(i=0;i<l;i++) for(j=0;j<w;j++) for(k=0;k<h;k++) { cin>>x; if((i+j+k)&1) cnt1+=x; else cnt2+=x; } if(cnt1==cnt2) puts("Yes"); else puts("No"); } return 0; } /* 1 1 1 1 2 2 2 1 1 1 1 1 1 1 1 */
zoj3678The Toy of Flandre Scarlet(水,高中老师提过。。),布布扣,bubuko.com
zoj3678The Toy of Flandre Scarlet(水,高中老师提过。。)
标签:水题
原文地址:http://blog.csdn.net/coraline_m/article/details/25742187