九度Online Judge

OJ新增积分机制,如有任何问题或者建议,请发帖到九度论坛OJ意见反馈版,祝大家一切顺利!
亲,九度OJ官方微博开通了,欢迎你来粉!微博地址:weibo.com/jobdu

 题目1429-九度Online Judge,用代码记录你的成长之路!

题目1429:Sequence Transformation

时间限制:1 秒

内存限制:32 兆

特殊判题:

提交:216

解决:88

题目描述:

        You’re given a sequence {a1, a2, a3, … , an}, and you can do one kind of operation to it: pick three consecutive numbers (ai-1, ai, ai+1), transform them to (ai-1+ai, - ai, ai+1 + ai). For example, (1, 2, 3) will be changed to (3, -2, 5) after one operation.

        Now for an initial sequence, your task is to determine whether it can be transformed into a destination sequence after series of operations.

输入:

        The first line contains a T, represents the number of test cases (1<=T<=50).

        Each test case contains three lines:

        First line, an integer N (3<=N<=25), represent the length of two sequences.

        Second line contains N integers, representing the initial sequence.

        Third line contains N integers, representing the initial sequence.

        The absolute value of each element in the sequence is less than 1000000.

输出:

        For each case, if the initial sequence can be changed into destination sequence after series of operations, output “yes”. Otherwise output “no”.

样例输入:
2
3
1 2 3
1 3 2
6
1 6 9 4 2 0
7 -6 19 2 -6 6
样例输出:
no
yes
提示:

        Sample 2: (1,6,9,4,2,0)->(1,6,13,-4,6,0)->(1,6,13,2,-6,6)->(7,-6,19,2,-6,6)

来源:
第四届ACM_DIY群程序设计竞赛