Guest User

Untitled

a guest
Sep 24th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.40 KB | None | 0 0
  1. import java.io.File;
  2.  
  3. import java.io.FileNotFoundException;
  4. import java.text.DecimalFormat;
  5. import java.util.Scanner;
  6.  
  7.  
  8. public class Inception_Watch {
  9.  
  10.     /**
  11.      * @param args
  12.      */
  13.     public static void main(String[] args) {
  14.         // TODO Auto-generated method stub
  15.  
  16.        
  17.         try {
  18.             Scanner r = new Scanner(new File("A.in"));
  19.             int Tnext[] = new int[9];
  20.             int max = 0;
  21.             DecimalFormat df = new DecimalFormat("000000000");
  22.             int Ans[]= new int[9];
  23.             while(true)
  24.                 {int level,time;String n;
  25.                
  26.                 level = r.nextInt();
  27.                 if(level==-1)break;
  28.                 time=r.nextInt();n=r.next();
  29.                 if(n.equals("s")){Tnext[level]=time;}else
  30.                     if(n.equals("m")){Tnext[level]=time*60;}else
  31.                         if(n.equals("h")){Tnext[level]=time*60*60;}else
  32.                             if(n.equals("d")){Tnext[level]=time*60*60*24;}else
  33.                                 if(n.equals("y")){Tnext[level]=time*60*60*24*365;}
  34.                
  35.                
  36.                
  37.                    
  38.                 max=level;
  39.            
  40.                
  41.                 }
  42.             for(int i=max;i>=0;i--){
  43.                 if(i==max){Ans[i]=Tnext[i];}
  44.                 else{
  45.                     Ans[i]=Tnext[i]+(Ans[i+1]/12);     
  46.                 }
  47.                
  48.             }
  49.             for(int i = 0;i<=max;i++)
  50.             {System.out.println(i+""+df.format(Ans[i]));}
  51.            
  52.            
  53.            
  54.         } catch (FileNotFoundException e) {
  55.             // TODO Auto-generated catch block
  56.             e.printStackTrace();
  57.         }
  58.     }
  59.  
  60. }
  61. /*
  62. Input
  63. 0 15 s
  64. 1 75 m
  65. 2 8 h
  66. 3 3 d
  67. 4 30 d
  68. 5 275 d
  69. 6 3 y
  70. -1
  71. output
  72. 0000000992
  73. 1000011726
  74. 2000086712
  75. 3000694950
  76. 4005229000
  77. 5031644000
  78. 6094608000
  79. */
Add Comment
Please, Sign In to add comment