發表文章

目前顯示的是 12月, 2016的文章

codeforces 271A --- beautiful year

BEAUTIFUL YEAR It seems like the year of 2013 came only yesterday. Do you know a curious fact? The year of 2013 is the first year after the old 1987 with only distinct digits. Now you are suggested to solve the following problem: given a year number, find the minimum year number which is strictly larger than the given one and has only distinct digits. Input The single line contains integer  y   (1000 ≤  y  ≤ 9000)  — the year number. Output Print a single integer — the minimum year number that is strictly larger than  y  and all it's digits are distinct. It is guaranteed that the answer exists. Examples input 1987 output 2013 input 2013 output 2014 #include <iostream> using   namespace  std ; int  iFind  (   int  iIn  ) { int  iFlag ;   int  iBucket [ 10 ] ; for   (   int  i = 0   ;  i < 10   ;  i ++   )     iBucket [ i ]   =   0 ; iFlag  =   0 ; while   (  iIn  )      {      if   (  iBucket [

Codeforces --- string task

Petya started to attend programming lessons. On the first lesson his task was to write a simple program. The program was supposed to do the following: in the given string, consisting if uppercase and lowercase Latin letters, it: deletes all the vowels, inserts a character " . " before each consonant, replaces all uppercase consonants with corresponding lowercase ones. Vowels are letters "A", "O", "Y", "E", "U", "I", and the rest are consonants. The program's input is exactly one string, it should return the output as a single string, resulting after the program's processing the initial string. Help Petya cope with this easy task. Input The first line represents input string of Petya's program. This string only consists of uppercase and lowercase Latin letters and its length is from  1  to  100 , inclusive. Output Print the resulting string. It is guaranteed that this string is

JAVA easy class -- circle

圖片
public   class  Circle2  {      public   static   void  main ( String [ ]  args )   {         Circle2 circle1  =   new  Circle2 ( ) ;          System . out . println ( "radius "   +  circle1. radius   +   " Area "   +  circle1. getArea ( ) ) ;         Circle2 circle2  =   new  Circle2 ( 30.0 ) ;          System . out . println ( "radius "   +  circle2. radius   +   " Area "   +  circle2. getArea ( ) ) ;         circle2. radius   =   40.0 ;          System . out . println ( "radius "   +  circle2. radius   +   " Area "   +  circle2. getArea ( ) ) ;      }      double  radius ;     Circle2 ( )          {         radius  =   1.0 ;          }     Circle2 ( double  dIn )          {         radius  =  dIn ;          }      double  getArea ( )          {          return  radius  *  radius  * Math . PI ;          } } object and class class is a template,

8.13 Smallest element

圖片
import   java.util.Scanner ; public   class  SmallestArrayElement  {        public   static   void  main ( String [ ]  args )   {          int  iRow,iCol ;          int  i,j ;          double  dSmall ;          int  iTempR,iTempC ;         Scanner input  =   new  Scanner ( System . in ) ;         iRow  =  input. nextInt ( ) ;         iCol  = input. nextInt ( ) ;          double   [ ] [ ] SmallestA  =   new   double [ iRow ] [ iCol ] ;         dSmall  =   10000 ;         iTempR  =  iTempC  =   0 ;          for   (  i = 0   ;  i < iRow  ;  i ++   )              for   (  j = 0   ;  j < iCol  ;  j ++   )              {             SmallestA [ i ] [ j ]   =  input. nextDouble ( ) ;                     if   (  SmallestA [ i ] [ j ]   <  dSmall  )                  {                 dSmall  =  SmallestA [ i ] [ j ] ;                 iTempR  =  i ;                 iTempC  =  j ;                  }              }