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 |
Javaimport java.io.*; public class Main { static int [] a = new int [100010],p = new int [100010]; public static void main(String[] args) throws IOException { StreamTokenizer input = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); PrintWriter output = new PrintWriter(new OutputStreamWriter(System.out)); int c,n,i,sum,l,r = 0; while(input.nextToken() != StreamTokenizer.TT_EOF){ c = (int)input.nval; input.nextToken(); n = (int)input.nval; if(c == 0 && n == 0)break; for(i = 1;i <= n;++i){ input.nextToken(); a[i] = (int)input.nval; p[i] = 0; } sum = 0; for(l = i = 1;i <= n;++i){ sum = (sum + a[i]) % c; if(sum == 0){ r = i; break; } else if(p[sum] > 0){ l = p[sum] + 1; r = i; break; } else p[sum] = i; } for(i = l;i < r;++i) output.print(i + " "); output.println(r); } output.flush(); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator