F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Negative and Positive (NP)

Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 4518    Accepted Submission(s): 1219


Problem Description
When given an array $\left( {{a_0},{a_1},{a_2}, \cdots {a_{n - 1}}} \right)$ and an integer $K$, you are expected to judge whether there is a pair $(i,j) (0 \leq i \leq j < n)$ which makes that $NP-sum(i,j)$ equals to $K$ true. Here $NP-sum(i,j)={a_i}{\rm{ - }}{a_{i{\rm{ + 1}}}}{\rm{ + }}{a_{i{\rm{ + }}2}}{\rm{ + }} \cdots {\rm{ + ( - 1}}{{\rm{)}}^{j - i}}{a_j}$
 

Input
Multi test cases. In the first line of the input file there is an integer $T$ indicates the number of test cases.
In the next $2*T$ lines, it will list the data for each test case.
Each case occupies two lines, the first line contain two integers $n$ and $K$ which are mentioned above.
The second line contain $\left( {{a_0},{a_1},{a_2}, \cdots {a_{n - 1}}} \right)$separated by exact one space.
[Technical Specification]
All input items are integers.
$0 < T \leq 25,1 \leq n \leq 1000000,-1000000000 \leq ai \leq 1000000000,-1000000000 \leq K \leq 1000000000$
 

Output
For each case£¬the output should occupies exactly one line. The output format is Case #id: ans, here id is the data number starting from 1; ans is ¡°Yes.¡± or ¡°No.¡± (without quote) according to whether you can find $(i,j)$ which makes $PN-sum(i,j)$ equals to $K$.
See the sample for more details.
 

Sample Input
2 1 1 1 2 1 -1 0
 

Sample Output
Case #1: Yes. Case #2: No.
 

Hint
If input is huge, fast IO method is recommended.
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-24 06:11:38, Gzip enabled