Poj Solution 3619

http://poj.org/problem?id=3619



import java.util.*;
import java.io.*;
/*
 * n ����;
 * s[i] ÿ���ӿ���ɵĹ���
 * t[i] һ����l��������ֵ�ʱ��
 * r[i] һ��l�������Ҫ��Ϣ��ʱ�� 
*/
public class Main{
    
    public static void main(String rgs[]) throws Exception
    {
        BufferedReader stdin = 
            new BufferedReader(
                new InputStreamReader(System.in));
           String line = stdin.readLine();
           StringTokenizer st = new StringTokenizer(line);
           int k,s,t,r,i,j,n,m,l,p;   
        n = Integer.parseInt(st.nextToken());
        k = Integer.parseInt(st.nextToken()); 
        for(i=0;i< k;i++){
            m=l=p=0;
            line = stdin.readLine();
               st = new StringTokenizer(line);
               s = Integer.parseInt(st.nextToken());
               t = Integer.parseInt(st.nextToken());
               r = Integer.parseInt(st.nextToken());
               while(l< n){
                   while(l< n && p< t){
                       l+=s;
                       m++;
                       p++;
                   }
                   if(l< n){
                       m+=r;
                       p=0;
                   }
               }
            System.out.println(m);    
        }    
    }
}

											
This entry was posted in poj. Bookmark the permalink.