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 |
为什么WA呀?,没道理,2356都过了import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class pku3370_ { /** * @param args */ static int v[],g[]; static final int maxint=100002; static BufferedReader cin; public static void main(String[] args) throws IOException { //Scanner sc=new Scanner(System.in); cin=new BufferedReader(new InputStreamReader(System.in)); v=new int[maxint]; g=new int[maxint]; int temp,k,q=0; while(true) { //int c=sc.nextInt(); String s1=cin.readLine(); String[] sa=s1.split(" "); //int n=sc.nextInt(); int c=Integer.parseInt(sa[0]); int n=Integer.parseInt(sa[1]); if(n==0&&c==0)break; k=0; //g[0]=0; for(int i=0;i<=n;i++) v[i]=0; // for(int i=0;i<=n;i++) g[0]=0; String s3=cin.readLine(); sa=s3.split(" "); for(int i=1;i<=n;i++) { temp=Integer.parseInt(sa[i-1]); g[i]=(g[i-1]+temp)%c; if(v[g[i]]==0)v[g[i]]=i; else { k=i; q=g[i]; } } if(k==0)System.out.println("no sweets"); else { for(int i=v[q]+1;i<k;i++) System.out.print(i+" "); System.out.println(k); } } } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator