Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
只要一个数组就行了!附代码!#include<stdio.h> #define N 100015 int flag[N]; int main() { int i, sum, j, a; int count, n, t; while (fscanf(stdin, "%d %d", &count, &n) != EOF) { for (i=1; i<=count; i++) flag[i] = 0; sum = 0; for (i=1; i<=n; i++) { fscanf(stdin, "%d", &a); sum += a; t = sum %count; sum = sum %count; if (!t) { for (j=1; j<=i; j++) printf("%d ", j); break; } else { if (flag[t] > 0) { for (j=flag[t]+1; j<=i; j++) printf("%d ", j); break; } } flag[t] = i; } for (j=i+1; j<=n; j++) fscanf(stdin, "%d", &sum); printf("\n"); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator