标签:blog class code c color int
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40 |
#include <stdio.h> int main( int
argc, char
*argv[]) { int
c = -1, n = -1; while
( true ) { scanf ( "%d%d" ,&c,&n); int
arr[n],sum[n],b[n]; if
(c + n == 0) { return
0; } for
( int i = 0; i < n; i++) { scanf ( "%d" ,&arr[i]); b[i] = -1; } sum[0] = arr[0] % c; b[sum[0]] = 0; int
temp = -1, temp1 = 0; for
( int i = 1; i < n; i++) { sum[i] = sum[i - 1] + arr[i]; sum[i] %= c; if
(sum[i] == 0) { temp = -1; temp1 = i; break ; } if
(b[sum[i]] == -1) { b[sum[i]] = i; } else
{ temp = b[sum[i]]; temp1 = i; break ; } } for
( int i = temp+1 ; i <= temp1; i++) { printf ( "%d%s" ,i+1, " " ); } printf ( "\n" ); } return
0; } |
标签:blog class code c color int
原文地址:http://www.cnblogs.com/ZhangJinkun/p/3728806.html