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

Perfect square number

Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 968    Accepted Submission(s): 388


Problem Description
You have an array of $n$ elements $a_1,$ $a_2,$ $...$ , $a_n$.

You have an operation that can modify the value of a certain position to any of the values in $[1,300]$. (You can only perform it once)

Find the maximum number of intervals that satisfy the interval sum is a Perfect square number.
 

Input
Each test contains multiple test cases. The first line contains the number of test cases $T$ ($T \le 5$).
The description of the test cases follows.

The first line contains one integer $n$($1\le \ n \le 300$).

The second line contains $n$ integers $a_1, \ a_2, \ ..., \ a_n$($1\le a_i \le 300$).
 

Output
For each test case, output the maximum number.
 

Sample Input
2 3 1 1 1 4 1 2 3 4
 

Sample Output
4 5
 

Hint
For the first query, change $a_2=3$.
For the second query, change $a_2=1$.
 

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-22 16:59:58, Gzip enabled