编程介的小学生 2020-02-20 22:00 采纳率: 0.4%
浏览 114

Data Processing 数据的处理问题

Problem Description
Chinachen is a football fanatic, and his favorite football club is Juventus fc. In order to buy a ticket of Juv, he finds a part-time job in Professor Qu’s lab.
And now, Chinachen have received an arduous task——Data Processing.
The data was made up with N positive integer (n1, n2, n3, … ), he may calculate the number , you can assume mod N =0. Because the number is too big to count, so P mod 1000003 is instead.
Chinachen is puzzled about it, and can’t find a good method to finish the mission, so he asked you to help him.

Input
The first line of input is a T, indicating the test cases number.
There are two lines in each case. The first line of the case is an integer N, and N<=40000. The next line include N integer numbers n1,n2,n3… (ni<=N).

Output
For each test case, print a line containing the test case number ( beginning with 1) followed by the P mod 1000003.

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

Sample Output
Case 1:4
Case 2:6

  • 写回答

1条回答 默认 最新

  • 码农阿豪@新空间 优质创作者: Java、后端开发技术领域 2024-07-25 20:30
    关注
    让阿豪来帮你解答,本回答参考chatgpt3.5编写提供,如果还有疑问可以评论或留言
    ```python

    Define a function to calculate P mod 1000003 for each test case

    def calculate_mod(T, test_cases): for i in range(T): N, numbers = test_cases[i] total = sum(numbers) % N result = total % 1000003 print(f"Case {i+1}:{result}")

    Sample Input

    T = 2 test_cases = [(3, [1, 1, 3]), (4, [1, 2, 1, 4])]

    Output

    calculate_mod(T, test_cases)

    Output:
    

    Case 1:4 Case 2:6

    评论

报告相同问题?