zoj3678The Toy of Flandre Scarlet(水,高中老师提过。。)
2014-05-13 21:54
246 查看
The Toy of Flandre Scarlet
Time Limit: 2 Seconds Memory Limit: 65536 KB
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).
题目大意:题目意思是给你一个cube,他的长宽高,l,w,h,然后总共有l*w*h个格子,每个格子上面上有一个数字,然后可以每次可以操作,使得两个相邻的格子里的数字同时加上一个数字或者同时减去一个数字。问你操作次数不限定,能否使得cube数字全为0。
记得高中那会儿玩儿魔方的时候,下课了一个老师问过我这个问题,魔方的每个格子有数,相邻的可加加减减,归零的条件只需要八个顶角加上六个面心的和等于十二个棱角加上核的和即可。
其实可以简单的画一个二维的3*3的
1 0 1
0 1 0
1 0 1
其实我们不管怎么对这个图处理,四个角加上中心点的和减去四条边上的和的值始终等于5。
因为我们可以对每个点分类,每次都是这两类的同加同减,他们的差不变,自己体会。。
题目地址:The Toy of Flandre Scarlet
AC代码:
Time Limit: 2 Seconds Memory Limit: 65536 KB
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?
Input
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.
Output
One line for each case. If Flandre can success, you should print "Yes" (ignore quotes), otherwise you should print "No" (ignore quotes).
Sample Input
1 1 1 1 2 2 2 1 1 1 1 1 1 1 1
Sample Output
No Yes
题目大意:题目意思是给你一个cube,他的长宽高,l,w,h,然后总共有l*w*h个格子,每个格子上面上有一个数字,然后可以每次可以操作,使得两个相邻的格子里的数字同时加上一个数字或者同时减去一个数字。问你操作次数不限定,能否使得cube数字全为0。
记得高中那会儿玩儿魔方的时候,下课了一个老师问过我这个问题,魔方的每个格子有数,相邻的可加加减减,归零的条件只需要八个顶角加上六个面心的和等于十二个棱角加上核的和即可。
其实可以简单的画一个二维的3*3的
1 0 1
0 1 0
1 0 1
其实我们不管怎么对这个图处理,四个角加上中心点的和减去四条边上的和的值始终等于5。
因为我们可以对每个点分类,每次都是这两类的同加同减,他们的差不变,自己体会。。
题目地址:The Toy of Flandre Scarlet
AC代码:
#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*/
相关文章推荐
- zoj 2678 The Toy of Flandre Scarlet
- ZOJ 3678 The Toy of Flandre Scarlet
- 高中生活--第2篇--师生交锋,Fans的言论让老师彻底无语
- 写给女儿高中编程课老师的一封信
- 我的高中班主任——龚政军老师
- 高中的地理老师
- 张fool语录 (某高中老师,学生上课的时候记录的),蛮搞
- 我的高中数学老师&nbsp;--&nbsp;教…
- 偶遇高中化学老师
- 我的高中语文老师
- ****The Toy of Flandre Scarlet
- 由清华大学数学老师所写的一封浪漫情书!它包含了高中的所有数学知识!一个字“绝”!两个字“经典”!四个字“佩服之至”!
- 高中生活--第2篇--师生交锋,Fans的言论让老师彻底无语
- 高中生活--第2篇--师生交锋,Fans的言论让老师彻底无语
- 致青春 ——感恩我的高中老师
- 高中知识sin回顾:对不起老师!!!
- 请初高中及大学老师回答,为什么?(鸽巢原理:排列组合问题)
- 高中生活--第2篇--师生交锋,Fans的言论让老师彻底无语
- 高中老师和大学老师的区别
- 高中生活--第2篇--师生交锋,Fans的言论让老师彻底无语