Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.text.DecimalFormat;
- import java.util.Scanner;
- public class Inception_Watch {
- /**
- * @param args
- */
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- try {
- Scanner r = new Scanner(new File("A.in"));
- int Tnext[] = new int[9];
- int max = 0;
- DecimalFormat df = new DecimalFormat("000000000");
- int Ans[]= new int[9];
- while(true)
- {int level,time;String n;
- level = r.nextInt();
- if(level==-1)break;
- time=r.nextInt();n=r.next();
- if(n.equals("s")){Tnext[level]=time;}else
- if(n.equals("m")){Tnext[level]=time*60;}else
- if(n.equals("h")){Tnext[level]=time*60*60;}else
- if(n.equals("d")){Tnext[level]=time*60*60*24;}else
- if(n.equals("y")){Tnext[level]=time*60*60*24*365;}
- max=level;
- }
- for(int i=max;i>=0;i--){
- if(i==max){Ans[i]=Tnext[i];}
- else{
- Ans[i]=Tnext[i]+(Ans[i+1]/12);
- }
- }
- for(int i = 0;i<=max;i++)
- {System.out.println(i+""+df.format(Ans[i]));}
- } catch (FileNotFoundException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
- /*
- Input
- 0 15 s
- 1 75 m
- 2 8 h
- 3 3 d
- 4 30 d
- 5 275 d
- 6 3 y
- -1
- output
- 0000000992
- 1000011726
- 2000086712
- 3000694950
- 4005229000
- 5031644000
- 6094608000
- */
Add Comment
Please, Sign In to add comment