cswork / OA打开练习工作台

MicrosoftOA #20

Find Fair Indexes

估计简单可在线判题

考点(AI 标注)前缀和区间

A fair index K splits A and B each into two non-empty parts such that the sums of all four parts are equal. Count the fair indices, where K ranges over 1..N−1. Some of the original site's explanations had the wrong indices; this site corrected them example by example.

输入格式

This site's input: the first line contains N (1..100000), the second line contains A, and the third line contains B, each with N integers (−10⁹..10⁹).

输出格式

Output a single integer, the answer.

样例 1

输入:

4
4 -1 0 3
-2 5 0 3

输出:

2

样例 2

输入:

4
2 -2 -3 3
0 0 4 -4

输出:

1

样例 3

输入:

4
4 -1 0 3
-2 6 0 4

输出:

0

样例说明

Example 1: for K=2 and K=3 all four parts sum to 3, so the count is 2.

Example 2: only K=2 is valid, with all four parts summing to 0; the original site's K=1 is incorrect, and the count is still 1.

Example 3: the two arrays sum to 6 and 8, so the four parts cannot be equal; the answer is 0.