1
+ body[data-md-color-scheme="slate"] .gslide-desc { color: var(--md-default-fg-color);}
605 Problems, 854 Solutions, 11 Languages Solution in Python Solution in Python Solution in Python Solution in Python Solutions in 2 languages Solution in Python Solutions in 2 languages Solution in Python Solution in Python Solution in Python Solutions in 2 languages JavaScript Python
n = int ( input ())
-mapping = {
- "clank" : "a" ,
- "bong" : "b" ,
- "click" : "c" ,
- "tap" : "d" ,
- "poing" : "e" ,
- "clonk" : "f" ,
- "clack" : "g" ,
- "ping" : "h" ,
- "tip" : "i" ,
- "cloing" : "j" ,
- "tic" : "k" ,
- "cling" : "l" ,
- "bing" : "m" ,
- "pong" : "n" ,
- "clang" : "o" ,
- "pang" : "p" ,
- "clong" : "q" ,
- "tac" : "r" ,
- "boing" : "s" ,
- "boink" : "t" ,
- "cloink" : "u" ,
- "rattle" : "v" ,
- "clock" : "w" ,
- "toc" : "x" ,
- "clink" : "y" ,
- "tuc" : "z" ,
- "whack" : " " ,
-}
-cap = False
-shift = False
-res = ""
-for _ in range ( n ):
- s = input ()
- if s == "bump" :
- cap = not cap
- elif s == "dink" :
- shift = True
- elif s == "thumb" :
- shift = False
- elif s == "pop" :
- res = res [: - 1 ]
- else :
- c = mapping . get ( s )
- res = res + ( c . upper () if ( cap and not shift ) or ( shift and not cap ) else c )
-print ( res )
-
Solution in Python Solution in Python Solution in Python Solution in Python Python
n = int ( input ())
+mapping = {
+ "clank" : "a" ,
+ "bong" : "b" ,
+ "click" : "c" ,
+ "tap" : "d" ,
+ "poing" : "e" ,
+ "clonk" : "f" ,
+ "clack" : "g" ,
+ "ping" : "h" ,
+ "tip" : "i" ,
+ "cloing" : "j" ,
+ "tic" : "k" ,
+ "cling" : "l" ,
+ "bing" : "m" ,
+ "pong" : "n" ,
+ "clang" : "o" ,
+ "pang" : "p" ,
+ "clong" : "q" ,
+ "tac" : "r" ,
+ "boing" : "s" ,
+ "boink" : "t" ,
+ "cloink" : "u" ,
+ "rattle" : "v" ,
+ "clock" : "w" ,
+ "toc" : "x" ,
+ "clink" : "y" ,
+ "tuc" : "z" ,
+ "whack" : " " ,
+}
+cap = False
+shift = False
+res = ""
+for _ in range ( n ):
+ s = input ()
+ if s == "bump" :
+ cap = not cap
+ elif s == "dink" :
+ shift = True
+ elif s == "thumb" :
+ shift = False
+ elif s == "pop" :
+ res = res [: - 1 ]
+ else :
+ c = mapping . get ( s )
+ res = res + ( c . upper () if ( cap and not shift ) or ( shift and not cap ) else c )
+print ( res )
+
Solution in Python Solutions in 2 languages Solution in Python Solution in Python Solution in Python Solution in Python Solutions in 2 languages Solution in Python Solution in Python Solutions in 3 languages Solution in Python Solution in Python Solution in Python Solution in Python Solutions in 3 languages Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solutions in 4 languages Solution in Python Solution in Python Python
h , p = [ int ( d ) for d in input () . split ()]
-import "fmt"
-
-func main () {
- var wc , hc , ws , hs int
- fmt . Scan ( & wc )
- fmt . Scan ( & hc )
- fmt . Scan ( & ws )
- fmt . Scan ( & hs )
- if wc - 2 >= ws && hc - 2 >= hs {
-
- fmt . Println ( 1 )
-
- } else {
-
- fmt . Println ( 0 )
-
- }
-}
-
wc , hc , ws , hs = io.read ( "*n" , "*n" , "*n" , "*n" )
-if wc - 2 >= ws and hc - 2 >= hs then
- print ( 1 )
-else
- print ( 0 )
-end
-
wc , hc , ws , hs = [ int ( d ) for d in input () . split ()]
-if wc - 2 >= ws and hc - 2 >= hs :
- print ( 1 )
-else :
- print ( 0 )
-
Solutions in 2 languages Solutions in 4 languages C++ Go Lua Python
#include <iostream>
+
+using namespace std ;
+
+int main ()
+{
+ int wc , hc , ws , hs ;
+ cin >> wc >> hc >> ws >> hs ;
+ if ( wc - 2 >= ws && hc - 2 >= hs )
+ {
+ cout << 1 << endl ;
+ }
+ else
+ {
+ cout << 0 << endl ;
+ }
+ return 0 ;
+}
+
package main
+
+import "fmt"
+
+func main () {
+ var wc , hc , ws , hs int
+ fmt . Scan ( & wc )
+ fmt . Scan ( & hc )
+ fmt . Scan ( & ws )
+ fmt . Scan ( & hs )
+ if wc - 2 >= ws && hc - 2 >= hs {
+
+ fmt . Println ( 1 )
+
+ } else {
+
+ fmt . Println ( 0 )
+
+ }
+}
+
for _ = 1 , io.read ( "*n" ) do
- n = io.read ( "*n" )
- number = 1
- for i = 1 , n do
- number = number * i
- end
- print ( number % 10 )
-end
+6
wc , hc , ws , hs = io.read ( "*n" , "*n" , "*n" , "*n" )
+if wc - 2 >= ws and hc - 2 >= hs then
+ print ( 1 )
+else
+ print ( 0 )
+end
for _ in range ( int ( input ())):
- n = int ( input ())
- number = 1
- for i in range ( 1 , n + 1 ):
- number *= i
- print ( number % 10 )
-
Solutions in 3 languages Solutions in 2 languages Solutions in 3 languages Solutions in 3 languages Solution in Python Python
n , p = [ int ( d ) for d in input () . split ()]
-nouns = dict ( tuple ( input () . split ()) for _ in range ( n ))
-phrases = []
-for _ in range ( p ):
- row = input () . split ()
- row [ - 1 ] = nouns [ row [ - 1 ]]
- phrases . append ( " " . join ( row ))
-rules = (
- "number of c" ,
- "amount of m" ,
- "most c" ,
- "most m" ,
- "fewest c" ,
- "least m" ,
- "more c" ,
- "more m" ,
- "fewer c" ,
- "less m" ,
- "many c" ,
- "much m" ,
- "few c" ,
- "little m" ,
-)
-for row in phrases :
- if row in rules :
- print ( "Correct!" )
- else :
- print ( "Not on my watch!" )
-
Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solutions in 3 languages Solution in Python Python
n , p = [ int ( d ) for d in input () . split ()]
+nouns = dict ( tuple ( input () . split ()) for _ in range ( n ))
+phrases = []
+for _ in range ( p ):
+ row = input () . split ()
+ row [ - 1 ] = nouns [ row [ - 1 ]]
+ phrases . append ( " " . join ( row ))
+rules = (
+ "number of c" ,
+ "amount of m" ,
+ "most c" ,
+ "most m" ,
+ "fewest c" ,
+ "least m" ,
+ "more c" ,
+ "more m" ,
+ "fewer c" ,
+ "less m" ,
+ "many c" ,
+ "much m" ,
+ "few c" ,
+ "little m" ,
+)
+for row in phrases :
+ if row in rules :
+ print ( "Correct!" )
+ else :
+ print ( "Not on my watch!" )
+
Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in C++ Solution in Python Solution in Python Solutions in 3 languages Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in C++ Solutions in 3 languages Solution in Python Solution in Python Solution in Python Solution in Python Solutions in 2 languages Solutions in 2 languages Solution in Python Solution in Python Solution in Python Solutions in 2 languages Solutions in 2 languages Solutions in 2 languages Solution in Python Solution in Python Solution in Python Solution in Python Solutions in 2 languages Solution in Python Python
mapping = {
- "th" : "thou" ,
- "in" : "inch" ,
- "ft" : "foot" ,
- "yd" : "yard" ,
- "ch" : "chain" ,
- "fur" : "furlong" ,
- "mi" : "mile" ,
- "lea" : "league" ,
-}
-names = list ( mapping . values ())
-scale = [ 1 , 1000 , 12 , 3 , 22 , 10 , 8 , 3 ]
-
-v , a , _ , b = input () . split ()
-v = int ( v )
-na , nb = mapping . get ( a , a ), mapping . get ( b , b )
-ia , ib = names . index ( na ), names . index ( nb )
-
-rate = 1
-for s in scale [ min ( ia , ib ) + 1 : max ( ia , ib ) + 1 ]:
- rate *= s
-
-print ( v * rate if ia > ib else v / rate )
-
Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solutions in 2 languages Solution in Python Python
def score ( a , b ):
- roll = set ([ a , b ])
- if roll == { 1 , 2 }:
- return ( 3 , None )
- elif len ( roll ) == 1 :
- return ( 2 , a )
- else :
- a , b = min ( a , b ), max ( b , a )
- return ( 1 , 10 * b + a )
-
-
-while True :
- rolls = [ int ( d ) for d in input () . split ()]
- if not any ( rolls ):
- break
- score1 = score ( * rolls [: 2 ])
- score2 = score ( * rolls [ 2 :])
- if score1 == score2 :
- print ( "Tie." )
- elif score1 [ 0 ] == score2 [ 0 ]:
- print ( f "Player { 1 if score1 [ 1 ] > score2 [ 1 ] else 2 } wins." )
- else :
- print ( f "Player { 1 if score1 [ 0 ] > score2 [ 0 ] else 2 } wins." )
-
Solution in Python Solution in Python Solution in Python Python
mapping = {
+ "th" : "thou" ,
+ "in" : "inch" ,
+ "ft" : "foot" ,
+ "yd" : "yard" ,
+ "ch" : "chain" ,
+ "fur" : "furlong" ,
+ "mi" : "mile" ,
+ "lea" : "league" ,
+}
+names = list ( mapping . values ())
+scale = [ 1 , 1000 , 12 , 3 , 22 , 10 , 8 , 3 ]
+
+v , a , _ , b = input () . split ()
+v = int ( v )
+na , nb = mapping . get ( a , a ), mapping . get ( b , b )
+ia , ib = names . index ( na ), names . index ( nb )
+
+rate = 1
+for s in scale [ min ( ia , ib ) + 1 : max ( ia , ib ) + 1 ]:
+ rate *= s
+
+print ( v * rate if ia > ib else v / rate )
+
Solution in Python Solution in Python Solution in Python Solution in Python Solutions in 2 languages Solution in Python Python
def score ( a , b ):
+ roll = set ([ a , b ])
+ if roll == { 1 , 2 }:
+ return ( 3 , None )
+ elif len ( roll ) == 1 :
+ return ( 2 , a )
+ else :
+ a , b = min ( a , b ), max ( b , a )
+ return ( 1 , 10 * b + a )
+
+
+while True :
+ rolls = [ int ( d ) for d in input () . split ()]
+ if not any ( rolls ):
+ break
+ score1 = score ( * rolls [: 2 ])
+ score2 = score ( * rolls [ 2 :])
+ if score1 == score2 :
+ print ( "Tie." )
+ elif score1 [ 0 ] == score2 [ 0 ]:
+ print ( f "Player { 1 if score1 [ 1 ] > score2 [ 1 ] else 2 } wins." )
+ else :
+ print ( f "Player { 1 if score1 [ 0 ] > score2 [ 0 ] else 2 } wins." )
+
Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solutions in 2 languages Solution in Python Python
n , v = io.read ( "*n" , "*n" )
-b = {}
-for i = 1 , n do
- l , w , h = io.read ( "*n" , "*n" , "*n" )
- b [ i ] = ( l * w * h )
-end
-print ( math.max ( table.unpack ( b )) - v )
-
n , v = [ int ( d ) for d in input () . split ()]
-b = []
-for _ in range ( n ):
- l , w , h = [ int ( d ) for d in input () . split ()]
- b . append ( l * w * h )
-print ( max ( b ) - v )
-
Solution in Python Solution in Python Solution in Python Solutions in 2 languages Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Python
notes = [ "A" , "A#" , "B" , "C" , "C#" , "D" , "D#" , "E" , "F" , "F#" , "G" , "G#" ]
-offset = [ 2 , 2 , 1 , 2 , 2 , 2 ]
-majors = {}
-for i in range ( len ( notes )):
- name = notes [ i ]
- progression = [ name ]
- for i in offset :
- index = ( notes . index ( progression [ - 1 ]) + i ) % len ( notes )
- progression . append ( notes [ index ])
- majors [ name ] = progression
-
-_ = input ()
-scales = set ( input () . split ())
-print ( " " . join ([ n for n in majors if scales < set ( majors [ n ])]) or "none" )
-
Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Python
notes = [ "A" , "A#" , "B" , "C" , "C#" , "D" , "D#" , "E" , "F" , "F#" , "G" , "G#" ]
+offset = [ 2 , 2 , 1 , 2 , 2 , 2 ]
+majors = {}
+for i in range ( len ( notes )):
+ name = notes [ i ]
+ progression = [ name ]
+ for i in offset :
+ index = ( notes . index ( progression [ - 1 ]) + i ) % len ( notes )
+ progression . append ( notes [ index ])
+ majors [ name ] = progression
+
+_ = input ()
+scales = set ( input () . split ())
+print ( " " . join ([ n for n in majors if scales < set ( majors [ n ])]) or "none" )
+
Solution in Python Solution in Python Solution in Python Solutions in 3 languages Solution in Python Solution in Python Solution in Python Solutions in 3 languages Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solutions in 2 languages Solution in Python Solutions in 2 languages Solution in Python Solutions in 2 languages Solution in Python Solution in Python Solutions in 2 languages Solution in Python Solutions in 2 languages Solution in Python Solution in Python Solution in Python Solution in Python Solutions in 2 languages Solutions in 3 languages Java Lua Python
import java.util.Scanner ;
-
-class OffWorldRecords {
- public static void main ( String [] args ) {
- Scanner s = new Scanner ( System . in );
- int n = s . nextInt ();
- int c = s . nextInt ();
- int p = s . nextInt ();
- int ans = 0 ;
-
- for ( int i = 0 ; i < n ; i ++ ) {
- int h = s . nextInt ();
- if ( h > c + p ) {
- ans += 1 ;
- p = c ;
- c = h ;
- }
- }
- System . out . println ( ans );
- }
-}
-
n , c , p = io.read ( "*n" , "*n" , "*n" )
-ans = 0
-for _ = 1 , n do
- h = io.read ( "*n" )
- if h > c + p then
- ans = ans + 1
- c , p = h , c
- end
-end
-print ( ans )
-
n , c , p = [ int ( d ) for d in input () . split ()]
-ans = 0
-for _ in range ( n ):
- h = int ( input ())
- if h > c + p :
- ans += 1
- c , p = h , c
-print ( ans )
-
Solution in Python Solution in Python Python
import math
-
-mapping = {
- "000" : "0" ,
- "001" : "1" ,
- "010" : "2" ,
- "011" : "3" ,
- "100" : "4" ,
- "101" : "5" ,
- "110" : "6" ,
- "111" : "7" ,
-}
-b = input ()
-length = 3 * math . ceil ( len ( b ) / 3 )
-b = b . zfill ( length )
-
-print ( "" . join ([ mapping [ b [ i : i + 3 ]] for i in range ( 0 , length , 3 )]))
-
Solution in Python Solution in Python Solution in Python Solutions in 3 languages Java Lua Python
import java.util.Scanner ;
+
+class OffWorldRecords {
+ public static void main ( String [] args ) {
+ Scanner s = new Scanner ( System . in );
+ int n = s . nextInt ();
+ int c = s . nextInt ();
+ int p = s . nextInt ();
+ int ans = 0 ;
+
+ for ( int i = 0 ; i < n ; i ++ ) {
+ int h = s . nextInt ();
+ if ( h > c + p ) {
+ ans += 1 ;
+ p = c ;
+ c = h ;
+ }
+ }
+ System . out . println ( ans );
+ }
+}
+
n , c , p = io.read ( "*n" , "*n" , "*n" )
+ans = 0
+for _ = 1 , n do
+ h = io.read ( "*n" )
+ if h > c + p then
+ ans = ans + 1
+ c , p = h , c
+ end
+end
+print ( ans )
+
n , c , p = [ int ( d ) for d in input () . split ()]
+ans = 0
+for _ in range ( n ):
+ h = int ( input ())
+ if h > c + p :
+ ans += 1
+ c , p = h , c
+print ( ans )
+
Solution in Python Solution in Python Solution in Python Solution in Python Python
import math
+
+mapping = {
+ "000" : "0" ,
+ "001" : "1" ,
+ "010" : "2" ,
+ "011" : "3" ,
+ "100" : "4" ,
+ "101" : "5" ,
+ "110" : "6" ,
+ "111" : "7" ,
+}
+b = input ()
+length = 3 * math . ceil ( len ( b ) / 3 )
+b = b . zfill ( length )
+
+print ( "" . join ([ mapping [ b [ i : i + 3 ]] for i in range ( 0 , length , 3 )]))
+
Solution in Python Solution in Python Solution in Python Solution in Python Solutions in 2 languages Solution in Python Solutions in 3 languages Solution in Python Solutions in 2 languages Solution in Python Solution in Python Solution in Python Solutions in 3 languages Solution in Python Solutions in 3 languages Solution in Python Solution in Python Solution in Python Solution in Python Solutions in 3 languages Solution in Python Solution in Python Python
a , b , c = [ int ( d ) for d in input () . split ()]
-t = [ 0 ] * 100
-for _ in range ( 3 ):
- start , end = [ int ( d ) - 1 for d in input () . split ()]
- for i in range ( start , end ):
- t [ i ] += 1
+16
from datetime import datetime
+
+year = int ( input ())
+
+mother = datetime ( year , 5 , 1 ) . isoweekday ()
+father = datetime ( year , 6 , 1 ) . isoweekday ()
-total = 0
-mapping = {
- 3 : c ,
- 2 : b ,
- 1 : a ,
-}
-for s in t :
- total += mapping . get ( s , 0 ) * s
-print ( total )
-
Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solutions in 2 languages Solution in Python Solutions in 2 languages Solution in Python Solutions in 2 languages Solution in Python Solution in Python Solution in Python Solution in Python Solutions in 2 languages Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solutions in 2 languages Lua Python
n , h , v = io.read ( "*n" , "*n" , "*n" )
-print ( 4 * math.max ( h * v , ( n - h ) * ( n - v ), h * ( n - v ), v * ( n - h )))
-
n , h , v = [ int ( d ) for d in input () . split ()]
-print ( 4 * max ( h * v , ( n - h ) * ( n - v ), h * ( n - v ), v * ( n - h )))
-
Solution in Python Solution in Python Python
def f ( n , time , l ):
- total_time , penalty = 0 , 0
- for i , t in enumerate ( sorted ( l )):
- if total_time + t > time :
- return i , penalty
- total_time += t
- penalty = ( penalty + total_time ) % 1_000_000_007
- return n , penalty
-
-
-n , t = [ int ( d ) for d in input () . split ()]
-a , b , c , t0 = [ int ( d ) for d in input () . split ()]
-l = [ t0 ]
-for _ in range ( n - 1 ):
- l . append ((( a * l [ - 1 ] + b ) % c ) + 1 )
-
-
-n , penalty = f ( n , t , l )
-print ( n , penalty )
-
Solution in Python Solutions in 2 languages Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solutions in 2 languages Lua Python
n , h , v = io.read ( "*n" , "*n" , "*n" )
+print ( 4 * math.max ( h * v , ( n - h ) * ( n - v ), h * ( n - v ), v * ( n - h )))
+
n , h , v = [ int ( d ) for d in input () . split ()]
+print ( 4 * max ( h * v , ( n - h ) * ( n - v ), h * ( n - v ), v * ( n - h )))
+
Solution in Python Solution in Python Python
def f ( n , time , l ):
+ total_time , penalty = 0 , 0
+ for i , t in enumerate ( sorted ( l )):
+ if total_time + t > time :
+ return i , penalty
+ total_time += t
+ penalty = ( penalty + total_time ) % 1_000_000_007
+ return n , penalty
+
+
+n , t = [ int ( d ) for d in input () . split ()]
+a , b , c , t0 = [ int ( d ) for d in input () . split ()]
+l = [ t0 ]
+for _ in range ( n - 1 ):
+ l . append ((( a * l [ - 1 ] + b ) % c ) + 1 )
+
+
+n , penalty = f ( n , t , l )
+print ( n , penalty )
+
Solution in Python Solutions in 2 languages Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Python
def adrian ( n ):
- if n == 0 :
- return ""
- elif n == 1 :
- return "A"
- elif n == 2 :
- return "AB"
- elif n == 3 :
- return "ABC"
- else :
- duplicate = n // 3
- return adrian ( 3 ) * duplicate + adrian ( n % 3 )
-
-
-def bruno ( n ):
- if n == 0 :
- return ""
- elif n == 1 :
- return "B"
- elif n == 2 :
- return "BA"
- elif n == 3 :
- return "BAB"
- elif n == 4 :
- return "BABC"
- else :
- duplicate = n // 4
- return bruno ( 4 ) * duplicate + bruno ( n % 4 )
-
-
-def goran ( n ):
- if n == 0 :
- return ""
- elif n in [ 1 , 2 ]:
- return "C" * n
- elif n in [ 3 , 4 ]:
- return "CC" + "A" * ( n - 2 )
- elif n in [ 5 , 6 ]:
- return "CCAA" + "B" * ( n - 4 )
- else :
- duplicate = n // 6
- return goran ( 6 ) * duplicate + goran ( n % 6 )
-
-
-def get_score ( ans , guess ):
- return sum ([ a == g for a , g in zip ( ans , guess )])
-
-
-n = int ( input ())
-ans = input ()
-
-result = {}
-result [ "Adrian" ] = get_score ( ans , adrian ( n ))
-result [ "Bruno" ] = get_score ( ans , bruno ( n ))
-result [ "Goran" ] = get_score ( ans , goran ( n ))
-
-best = max ( result . values ())
-print ( best )
-
-for name , score in result . items ():
- if score == best :
- print ( name )
-
Solution in Python Solutions in 2 languages Solution in Python Solution in Python Solutions in 4 languages Solution in Python Solution in Python Python
def adrian ( n ):
+ if n == 0 :
+ return ""
+ elif n == 1 :
+ return "A"
+ elif n == 2 :
+ return "AB"
+ elif n == 3 :
+ return "ABC"
+ else :
+ duplicate = n // 3
+ return adrian ( 3 ) * duplicate + adrian ( n % 3 )
+
+
+def bruno ( n ):
+ if n == 0 :
+ return ""
+ elif n == 1 :
+ return "B"
+ elif n == 2 :
+ return "BA"
+ elif n == 3 :
+ return "BAB"
+ elif n == 4 :
+ return "BABC"
+ else :
+ duplicate = n // 4
+ return bruno ( 4 ) * duplicate + bruno ( n % 4 )
+
+
+def goran ( n ):
+ if n == 0 :
+ return ""
+ elif n in [ 1 , 2 ]:
+ return "C" * n
+ elif n in [ 3 , 4 ]:
+ return "CC" + "A" * ( n - 2 )
+ elif n in [ 5 , 6 ]:
+ return "CCAA" + "B" * ( n - 4 )
+ else :
+ duplicate = n // 6
+ return goran ( 6 ) * duplicate + goran ( n % 6 )
+
+
+def get_score ( ans , guess ):
+ return sum ([ a == g for a , g in zip ( ans , guess )])
+
+
+n = int ( input ())
+ans = input ()
+
+result = {}
+result [ "Adrian" ] = get_score ( ans , adrian ( n ))
+result [ "Bruno" ] = get_score ( ans , bruno ( n ))
+result [ "Goran" ] = get_score ( ans , goran ( n ))
+
+best = max ( result . values ())
+print ( best )
+
+for name , score in result . items ():
+ if score == best :
+ print ( name )
+
Solution in Python Solutions in 2 languages Solution in Python Solution in Python Solutions in 4 languages Solution in Python Solutions in 2 languages Solution in Python Solution in Python Solutions in 2 languages Solutions in 5 languages Solution in Python Solutions in 5 languages Solution in Python Solution in Python Solution in Python Solutions in 4 languages Solution in Python Solution in Python Solution in Python Solution in Python Solutions in 4 languages Solutions in 2 languages Solution in Python Solution in Python Solutions in 2 languages Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solutions in 4 languages Solution in Python Solution in Python Solution in Python Python
import java.util.Scanner ;
-
-class Rijeci {
- public static void main ( String [] args ) {
- Scanner s = new Scanner ( System . in );
- int k = s . nextInt ();
- int a = 1 ;
- int b = 0 ;
- for ( int i = 0 ; i < k ; i ++ ) {
- int t = b ;
- b = a + b ;
- a = t ;
-
- }
-
- System . out . println ( a + " " + b );
- }
-}
-
k = io.read ( "*n" )
-local a , b = 1 , 0
-for i = 1 , k do
- a , b = b , b + a
-end
-print ( a , b )
-
k = int ( input ())
-a , b = 1 , 0
-for _ in range ( k ):
- a , b = b , b + a
-
-print ( a , b )
-
Solutions in 3 languages Solutions in 4 languages Solution in Python Solution in Python Solution in Python Solutions in 3 languages Solution in Python Solutions in 2 languages Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solutions in 2 languages Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solutions in 2 languages Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solutions in 2 languages Solution in Python Solution in Python Solution in Python Solution in Python Solutions in 2 languages Solution in Python Solution in Python Solution in Python Solutions in 2 languages Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solutions in 2 languages Solution in Python Solution in Python Solution in Python Solution in Python Solutions in 3 languages Go Lua Python
package main
-
-import "fmt"
-
-func main () {
- var a , b , c int
- fmt . Scan ( & a )
- fmt . Scan ( & b )
- fmt . Scan ( & c )
- x := b - a
- y := c - b
- ans := x
- if ans < y {
- ans = y
- }
- ans -= 1
- fmt . Println ( ans )
-}
-
a , b , c = io.read ( "*n" , "*n" , "*n" )
-print ( math.max ( b - a , c - b ) - 1 )
-
a , b , c = [ int ( d ) for d in input () . split ()]
-print ( max ( b - a , c - b ) - 1 )
-
Solution in Python Solution in Python Solution in Python Solutions in 2 languages Solution in Python Solution in Python Solutions in 3 languages Solution in Python Solution in Python Solutions in 2 languages Java Python
package main
+
+import "fmt"
+
+func main () {
+ var a , b , c int
+ fmt . Scan ( & a )
+ fmt . Scan ( & b )
+ fmt . Scan ( & c )
+ x := b - a
+ y := c - b
+ ans := x
+ if ans < y {
+ ans = y
+ }
+ ans -= 1
+ fmt . Println ( ans )
+}
+
a , b , c = io.read ( "*n" , "*n" , "*n" )
+print ( math.max ( b - a , c - b ) - 1 )
+
a , b , c = [ int ( d ) for d in input () . split ()]
+print ( max ( b - a , c - b ) - 1 )
+
Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solutions in 2 languages Solutions in 2 languages Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solutions in 2 languages Solution in Python Solution in Python Solution in Python Solutions in 4 languages Solution in Python Solution in Python Solution in Python Python
from collections import Counter
-import "fmt"
-
-func main () {
- var a , b int
- fmt . Scan ( & a )
- fmt . Scan ( & b )
- if a < b {
- fmt . Printf ( "%d %d\n" , a , b )
- } else {
- fmt . Printf ( "%d %d\n" , b , a )
- }
-}
-
a , b = io.read ( "*n" , "*n" )
-if a < b then
- print ( a , b )
-else
- print ( b , a )
-end
-
line = input ()
-a , b = [ int ( d ) for d in line . split ()]
-if a < b :
- print ( a , b )
-else :
- print ( b , a )
-
Solutions in 3 languages Solution in Python Solutions in 4 languages C++ Go Lua Python
#include <iostream>
+
+using namespace std ;
+
+int main ()
+{
+ int a = 0 , b = 0 ;
+ cin >> a >> b ;
+ if ( a < b )
+ {
+ cout << a << " " << b ;
+ }
+ else
+ {
+ cout << b << " " << a ;
+ }
+}
+
import java.util.Scanner ;
+14
package main
-class Sottkvi {
- public static void main ( String [] args ) {
- Scanner s = new Scanner ( System . in );
- int n = s . nextInt ();
- int k = s . nextInt ();
- int today = s . nextInt ();
- int ans = 0 ;
- for ( int i = 0 ; i < n ; i ++ ) {
- int d = s . nextInt ();
- if ( d + 14 - today <= k ) {
- ans += 1 ;
- }
- }
- System . out . println ( ans );
-
- }
-}
+import "fmt"
+
+func main () {
+ var a , b int
+ fmt . Scan ( & a )
+ fmt . Scan ( & b )
+ if a < b {
+ fmt . Printf ( "%d %d\n" , a , b )
+ } else {
+ fmt . Printf ( "%d %d\n" , b , a )
+ }
+}
n , k , today = io.read ( "*n" , "*n" , "*n" )
-res = 0
-for _ = 1 , n do
- d = io.read ( "*n" )
- if d + 14 - today <= k then
- res = res + 1
- end
-end
-print ( res )
+6
a , b = io.read ( "*n" , "*n" )
+if a < b then
+ print ( a , b )
+else
+ print ( b , a )
+end
n , k , today = [ int ( d ) for d in input () . split ()]
-res = 0
-for _ in range ( n ):
- d = int ( input ())
- if d + 14 - today <= k :
- res += 1
-print ( res )
-
Solution in Python Solutions in 3 languages Java Lua Python
m = {
- "B" : 1 ,
- "F" : 1 ,
- "P" : 1 ,
- "V" : 1 ,
- "C" : 2 ,
- "G" : 2 ,
- "J" : 2 ,
- "K" : 2 ,
- "Q" : 2 ,
- "S" : 2 ,
- "X" : 2 ,
- "Z" : 2 ,
- "D" : 3 ,
- "T" : 3 ,
- "L" : 4 ,
- "M" : 5 ,
- "N" : 5 ,
- "R" : 6 ,
-}
-
-while True :
- try :
- s = input ()
- s = [ str ( m . get ( c , "" )) for c in s ]
- prev = s [ 0 ]
- ans = [ prev ]
- for c in s [ 1 :]:
- if c != prev :
- ans . append ( c )
- prev = c
- print ( "" . join ( ans ))
- except :
- break
-
Solution in Python Solution in Python Solutions in 3 languages Solution in Python Python
#include <iostream>
-
-using namespace std ;
-
-int main ()
-{
- int h , m ;
- cin >> h >> m ;
-
- int mm = m - 45 ;
- int borrow = 0 ;
- if ( mm < 0 )
- {
- mm += 60 ;
- borrow = 1 ;
- }
- int hh = h - borrow ;
- if ( hh < 0 )
- {
- hh += 24 ;
- }
- cout << hh << " " << mm << endl ;
- return 0 ;
-}
-
m = {
+ "B" : 1 ,
+ "F" : 1 ,
+ "P" : 1 ,
+ "V" : 1 ,
+ "C" : 2 ,
+ "G" : 2 ,
+ "J" : 2 ,
+ "K" : 2 ,
+ "Q" : 2 ,
+ "S" : 2 ,
+ "X" : 2 ,
+ "Z" : 2 ,
+ "D" : 3 ,
+ "T" : 3 ,
+ "L" : 4 ,
+ "M" : 5 ,
+ "N" : 5 ,
+ "R" : 6 ,
+}
+
+while True :
+ try :
+ s = input ()
+ s = [ str ( m . get ( c , "" )) for c in s ]
+ prev = s [ 0 ]
+ ans = [ prev ]
+ for c in s [ 1 :]:
+ if c != prev :
+ ans . append ( c )
+ prev = c
+ print ( "" . join ( ans ))
+ except :
+ break
+
Solution in Python Solution in Python Solution in Python Solutions in 3 languages Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solutions in 2 languages Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solutions in 2 languages Solution in Python Solution in Python Solutions in 2 languages Solution in Python Solution in Python Python
ds , dy , dm , ym = io.read ( "*n" , "*n" , "*n" , "*n" )
-
-for t = 1 , 5000 do
- if ( t + ds ) % dy == 0 and ( t + dm ) % ym == 0 then
- print ( t )
- break
- end
-end
-
sun_years_ago , sun_cycle = [ int ( v ) for v in input () . split ()]
-moon_years_ago , moon_cycle = [ int ( v ) for v in input () . split ()]
-
-for t in range ( 1 , 5001 ):
- if ( t + sun_years_ago ) % sun_cycle == 0 and ( t + moon_years_ago ) % moon_cycle == 0 :
- print ( t )
- break
-
Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Python
n = int ( input ())
-mapping = {
- "2" : "abc" ,
- "3" : "def" ,
- "4" : "ghi" ,
- "5" : "jkl" ,
- "6" : "mno" ,
- "7" : "pqrs" ,
- "8" : "tuv" ,
- "9" : "wxyz" ,
- "0" : " " ,
-}
-
-for i in range ( n ):
- ans = []
- prev = ""
- for c in input ():
- for d , r in mapping . items ():
- if c in r :
- if d == prev :
- ans . append ( " " )
- ans . append ( d * ( r . index ( c ) + 1 ))
- prev = d
- break
- print ( f "Case # { i + 1 } : { '' . join ( ans ) } " )
-
Solution in Python Solution in Python Solutions in 2 languages Lua Python
ds , dy , dm , ym = io.read ( "*n" , "*n" , "*n" , "*n" )
+
+for t = 1 , 5000 do
+ if ( t + ds ) % dy == 0 and ( t + dm ) % ym == 0 then
+ print ( t )
+ break
+ end
+end
+
sun_years_ago , sun_cycle = [ int ( v ) for v in input () . split ()]
+moon_years_ago , moon_cycle = [ int ( v ) for v in input () . split ()]
+
+for t in range ( 1 , 5001 ):
+ if ( t + sun_years_ago ) % sun_cycle == 0 and ( t + moon_years_ago ) % moon_cycle == 0 :
+ print ( t )
+ break
+
Solution in Python Solution in Python Solution in Python Solutions in 2 languages Solution in Python Python
n = int ( input ())
+mapping = {
+ "2" : "abc" ,
+ "3" : "def" ,
+ "4" : "ghi" ,
+ "5" : "jkl" ,
+ "6" : "mno" ,
+ "7" : "pqrs" ,
+ "8" : "tuv" ,
+ "9" : "wxyz" ,
+ "0" : " " ,
+}
+
+for i in range ( n ):
+ ans = []
+ prev = ""
+ for c in input ():
+ for d , r in mapping . items ():
+ if c in r :
+ if d == prev :
+ ans . append ( " " )
+ ans . append ( d * ( r . index ( c ) + 1 ))
+ prev = d
+ break
+ print ( f "Case # { i + 1 } : { '' . join ( ans ) } " )
+
Solution in Python Solution in Python Solution in Python Solutions in 2 languages Solution in Python Solutions in 2 languages Solution in Python Solution in Python Solution in Python Solution in Python Solutions in 2 languages Solution in Python Solution in Python Solution in Python Solutions in 2 languages Solution in Python Solution in Python Solutions in 3 languages Solutions in 4 languages Solution in Python Solution in Python Solutions in 2 languages Solution in Python Solutions in 3 languages Solution in Python Solutions in 4 languages Solution in Python Solutions in 8 languages Solution in Python Solution in Python Solutions in 8 languages Solutions in 3 languages Solution in Python Solution in Python Solutions in 3 languages Solution in Python Python
t = input ()
-
-
-def u ( pos , preference ):
- if pos == preference == "U" :
- return 0
- elif pos == preference == "D" :
- return 1
- elif pos == "U" and preference == "D" :
- return 2
- else :
- return 1
-
-
-def l ( pos , preference ):
- if pos == preference == "U" :
- return 1
- elif pos == preference == "D" :
- return 0
- elif pos == "U" and preference == "D" :
- return 1
- else :
- return 2
-
-
-def b ( pos , preference ):
- if pos == preference :
- return 0
- else :
- return 1
-
-
-pu = [ u ( pos , preference ) for pos , preference in zip ( t [ 0 ] + "U" * ( len ( t ) - 2 ), t [ 1 :])]
-pl = [ l ( pos , preference ) for pos , preference in zip ( t [ 0 ] + "D" * ( len ( t ) - 2 ), t [ 1 :])]
-pb = [ b ( pos , preference ) for pos , preference in zip ( t [ 0 ] + t [ 1 : - 1 ], t [ 1 :])]
-
-print ( sum ( pu ))
-print ( sum ( pl ))
-print ( sum ( pb ))
-
Solution in Python Solution in Python Solutions in 5 languages Solution in Python Solution in Python Solution in Python Solutions in 2 languages Lua Python
n = io.read ( "*n" )
-t = 0
-top = 0
-for _ = 1 , n do
- d = io.read ( "*n" )
- if top == 0 or d > top then
- t = t + 1
- end
- top = d
-end
-print ( t )
+
+def u ( pos , preference ):
+ if pos == preference == "U" :
+ return 0
+ elif pos == preference == "D" :
+ return 1
+ elif pos == "U" and preference == "D" :
+ return 2
+ else :
+ return 1
+
+
+def l ( pos , preference ):
+ if pos == preference == "U" :
+ return 1
+ elif pos == preference == "D" :
+ return 0
+ elif pos == "U" and preference == "D" :
+ return 1
+ else :
+ return 2
+
+
+def b ( pos , preference ):
+ if pos == preference :
+ return 0
+ else :
+ return 1
+
+
+pu = [ u ( pos , preference ) for pos , preference in zip ( t [ 0 ] + "U" * ( len ( t ) - 2 ), t [ 1 :])]
+pl = [ l ( pos , preference ) for pos , preference in zip ( t [ 0 ] + "D" * ( len ( t ) - 2 ), t [ 1 :])]
+pb = [ b ( pos , preference ) for pos , preference in zip ( t [ 0 ] + t [ 1 : - 1 ], t [ 1 :])]
+
+print ( sum ( pu ))
+print ( sum ( pl ))
+print ( sum ( pb ))
+
Solution in Python Solution in Python Solutions in 5 languages Solution in Python Python
k = [
- "qwertyuiop" ,
- "asdfghjkl" ,
- "zxcvbnm" ,
-]
-
-
-def d ( a , b ):
- for r1 in range ( 3 ):
- if a in k [ r1 ]:
- c1 = k [ r1 ] . index ( a )
- break
- for r2 in range ( 3 ):
- if b in k [ r2 ]:
- c2 = k [ r2 ] . index ( b )
- break
-
- return abs ( c1 - c2 ) + abs ( r1 - r2 )
-
-
-for _ in range ( int ( input ())):
- x , n = input () . split ()
- n , w = int ( n ), []
-
- for _ in range ( n ):
- y = input ()
- dist = sum ([ d ( a , b ) for a , b in zip ( list ( x ), list ( y ))])
- w . append ([ y , dist ])
-
- print ( " \n " . join ([ f " { k } { v } " for k , v in sorted ( w , key = lambda k : ( k [ 1 ], k [ 0 ]))]))
-
Solution in Python Solutions in 2 languages Solutions in 2 languages Solutions in 2 languages Solution in Python Python
k = [
+ "qwertyuiop" ,
+ "asdfghjkl" ,
+ "zxcvbnm" ,
+]
+
+
+def d ( a , b ):
+ for r1 in range ( 3 ):
+ if a in k [ r1 ]:
+ c1 = k [ r1 ] . index ( a )
+ break
+ for r2 in range ( 3 ):
+ if b in k [ r2 ]:
+ c2 = k [ r2 ] . index ( b )
+ break
+
+ return abs ( c1 - c2 ) + abs ( r1 - r2 )
+
+
+for _ in range ( int ( input ())):
+ x , n = input () . split ()
+ n , w = int ( n ), []
+
+ for _ in range ( n ):
+ y = input ()
+ dist = sum ([ d ( a , b ) for a , b in zip ( list ( x ), list ( y ))])
+ w . append ([ y , dist ])
+
+ print ( " \n " . join ([ f " { k } { v } " for k , v in sorted ( w , key = lambda k : ( k [ 1 ], k [ 0 ]))]))
+
Solution in Python Solutions in 2 languages Solution in Python Solution in Python Solutions in 2 languages Solutions in 2 languages Lua Python
d , a , b , h = io.read ( "*n" , "*n" , "*n" , "*n" )
-m = math.pi * d * d / 4
-t = ( a + b ) * h / 2
-if m == t then
- print ( 'Jafn storar!' )
-elseif m > t then
- print ( 'Mahjong!' )
-else
- print ( 'Trapizza!' )
-end
-
n = io.read ( "*n" )
+d = 0
+for i = 1 , n do
+ x , y = io.read ( "*n" , "*n" )
+ d = d + 2 * ( x - y )
+end
+print ( - d / ( 2 * n ))
+
n = int ( input ())
+d = 0
+for _ in range ( n ):
+ x , y = [ int ( i ) for i in input () . split ()]
+ d += 2 * ( x - y )
+print ( - d / ( 2 * n ))
+
Solution in Python Solution in Python Solution in Python Solution in Python Solutions in 2 languages Lua Python
from operator import add , mul , sub , truediv
-
-a , b , c = [ int ( d ) for d in input () . split ()]
-ops = {
- "+" : add ,
- "-" : sub ,
- "*" : mul ,
- "/" : truediv ,
-}
-
-for op , func in ops . items ():
- if a == func ( b , c ):
- print ( f " { a } = { b }{ op }{ c } " )
- break
- if func ( a , b ) == c :
- print ( f " { a }{ op }{ b } = { c } " )
-
Solutions in 5 languages Solution in Python Solution in Python Solution in Python Solutions in 5 languages C++ Go Java Lua Python
#include <iostream>
+
+using namespace std ;
+
+int main ()
+{
+ int h , b ;
+ cin >> h >> b ;
+ cout << float ( h ) * b / 2 << endl ;
+ return 0 ;
+}
+
package main
+
+import "fmt"
+
+func main () {
+ var a , b int
+ fmt . Scan ( & a )
+ fmt . Scan ( & b )
+ fmt . Println ( float32 ( a ) * float32 ( b ) / 2 )
+}
+
moves = input ()
-ball = [ 1 , 0 , 0 ]
-for move in moves :
- if move == "A" :
- ball [ 0 ], ball [ 1 ] = ball [ 1 ], ball [ 0 ]
- if move == "B" :
- ball [ 1 ], ball [ 2 ] = ball [ 2 ], ball [ 1 ]
- if move == "C" :
- ball [ 0 ], ball [ 2 ] = ball [ 2 ], ball [ 0 ]
-
-if ball [ 0 ]:
- print ( 1 )
-elif ball [ 1 ]:
- print ( 2 )
-else :
- print ( 3 )
-
Solution in Python Solution in Python Solutions in 2 languages Solutions in 7 languages Solution in Python Solution in Python Solution in Python Solutions in 2 languages Solutions in 7 languages Solutions in 5 languages Solution in Python Solution in Python Solution in Python Solutions in 5 languages Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Python
participants = int ( input ())
+19
import math
-vaccinated = 0
-control = 0
-infected_control_a = 0
-infected_vaccinated_a = 0
-infected_control_b = 0
-infected_vaccinated_b = 0
-infected_control_c = 0
-infected_vaccinated_c = 0
-
-for p in range ( participants ):
- record = input ()
- v , a , b , c = list ( record )
-
- if v == "N" :
- control += 1
- else :
- vaccinated += 1
-
- if a == "Y" :
- if v == "N" :
- infected_control_a += 1
- else :
- infected_vaccinated_a += 1
-
- if b == "Y" :
- if v == "N" :
- infected_control_b += 1
- else :
- infected_vaccinated_b += 1
-
- if c == "Y" :
- if v == "N" :
- infected_control_c += 1
- else :
- infected_vaccinated_c += 1
-
-
-def get_vaccine_efficacy ( infected_vaccinated , vaccinated , infected_control , control ):
- infection_rate_vaccinated = infected_vaccinated / vaccinated
- infection_rate_control = infected_control / control
- return 1 - infection_rate_vaccinated / infection_rate_control
-
-
-vaccine_efficacy = [
- get_vaccine_efficacy (
- infected_vaccinated_a ,
- vaccinated ,
- infected_control_a ,
- control ,
- ),
- get_vaccine_efficacy (
- infected_vaccinated_b ,
- vaccinated ,
- infected_control_b ,
- control ,
- ),
- get_vaccine_efficacy (
- infected_vaccinated_c ,
- vaccinated ,
- infected_control_c ,
- control ,
- ),
-]
-
-for value in vaccine_efficacy :
- if value <= 0 :
- print ( "Not Effective" )
- else :
- print ( f " { value * 100 : .6f } " )
-
Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in C++ C++
1
+vaccinated = 0
+control = 0
+infected_control_a = 0
+infected_vaccinated_a = 0
+infected_control_b = 0
+infected_vaccinated_b = 0
+infected_control_c = 0
+infected_vaccinated_c = 0
+
+for p in range ( participants ):
+ record = input ()
+ v , a , b , c = list ( record )
+
+ if v == "N" :
+ control += 1
+ else :
+ vaccinated += 1
+
+ if a == "Y" :
+ if v == "N" :
+ infected_control_a += 1
+ else :
+ infected_vaccinated_a += 1
+
+ if b == "Y" :
+ if v == "N" :
+ infected_control_b += 1
+ else :
+ infected_vaccinated_b += 1
+
+ if c == "Y" :
+ if v == "N" :
+ infected_control_c += 1
+ else :
+ infected_vaccinated_c += 1
+
+
+def get_vaccine_efficacy ( infected_vaccinated , vaccinated , infected_control , control ):
+ infection_rate_vaccinated = infected_vaccinated / vaccinated
+ infection_rate_control = infected_control / control
+ return 1 - infection_rate_vaccinated / infection_rate_control
+
+
+vaccine_efficacy = [
+ get_vaccine_efficacy (
+ infected_vaccinated_a ,
+ vaccinated ,
+ infected_control_a ,
+ control ,
+ ),
+ get_vaccine_efficacy (
+ infected_vaccinated_b ,
+ vaccinated ,
+ infected_control_b ,
+ control ,
+ ),
+ get_vaccine_efficacy (
+ infected_vaccinated_c ,
+ vaccinated ,
+ infected_control_c ,
+ control ,
+ ),
+]
+
+for value in vaccine_efficacy :
+ if value <= 0 :
+ print ( "Not Effective" )
+ else :
+ print ( f " { value * 100 : .6f } " )
+
Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solutions in 9 languages Solution in C++ Solution in Python Solution in Python Solution in Python Solutions in 9 languages Solution in Python Solution in Python Solutions in 3 languages Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solutions in 3 languages Solution in Python Solution in Python Solution in Python Python
mapping = {
- # row 1
- "1" : "`" ,
- "2" : "1" ,
- "3" : "2" ,
- "4" : "3" ,
- "5" : "4" ,
- "6" : "5" ,
- "7" : "6" ,
- "8" : "7" ,
- "9" : "8" ,
- "0" : "9" ,
- "-" : "0" ,
- "=" : "-" ,
- # row 2
- "W" : "Q" ,
- "E" : "W" ,
- "R" : "E" ,
- "T" : "R" ,
- "Y" : "T" ,
- "U" : "Y" ,
- "I" : "U" ,
- "O" : "I" ,
- "P" : "O" ,
- "[" : "P" ,
- "]" : "[" ,
- " \\ " : "]" ,
- # row 3
- "S" : "A" ,
- "D" : "S" ,
- "F" : "D" ,
- "G" : "F" ,
- "H" : "G" ,
- "J" : "H" ,
- "K" : "J" ,
- "L" : "K" ,
- ";" : "L" ,
- "'" : ";" ,
- # row 4
- "X" : "Z" ,
- "C" : "X" ,
- "V" : "C" ,
- "B" : "V" ,
- "N" : "B" ,
- "M" : "N" ,
- "," : "M" ,
- "." : "," ,
- "/" : "." ,
- " " : " " ,
-}
-
-while True :
- try :
- s = input ()
- except :
- break
- print ( "" . join ([ mapping [ c ] for c in s ]))
-
Solution in Python Solution in Python Solutions in 6 languages Solution in Python Solution in Python Python
package main
-
-import "fmt"
-
-func main () {
- var a , b int
- fmt . Scan ( & a )
- fmt . Scan ( & b )
- if a > b {
- fmt . Println ( 1 )
- } else {
- fmt . Println ( 0 )
- }
-}
-
mapping = {
+ # row 1
+ "1" : "`" ,
+ "2" : "1" ,
+ "3" : "2" ,
+ "4" : "3" ,
+ "5" : "4" ,
+ "6" : "5" ,
+ "7" : "6" ,
+ "8" : "7" ,
+ "9" : "8" ,
+ "0" : "9" ,
+ "-" : "0" ,
+ "=" : "-" ,
+ # row 2
+ "W" : "Q" ,
+ "E" : "W" ,
+ "R" : "E" ,
+ "T" : "R" ,
+ "Y" : "T" ,
+ "U" : "Y" ,
+ "I" : "U" ,
+ "O" : "I" ,
+ "P" : "O" ,
+ "[" : "P" ,
+ "]" : "[" ,
+ " \\ " : "]" ,
+ # row 3
+ "S" : "A" ,
+ "D" : "S" ,
+ "F" : "D" ,
+ "G" : "F" ,
+ "H" : "G" ,
+ "J" : "H" ,
+ "K" : "J" ,
+ "L" : "K" ,
+ ";" : "L" ,
+ "'" : ";" ,
+ # row 4
+ "X" : "Z" ,
+ "C" : "X" ,
+ "V" : "C" ,
+ "B" : "V" ,
+ "N" : "B" ,
+ "M" : "N" ,
+ "," : "M" ,
+ "." : "," ,
+ "/" : "." ,
+ " " : " " ,
+}
+
+while True :
+ try :
+ s = input ()
+ except :
+ break
+ print ( "" . join ([ mapping [ c ] for c in s ]))
+
Solution in Python Solutions in 6 languages Solutions in 2 languages Lua Python
n , k = io.read ( "*n" , "*n" )
-if math.log ( n , 2 ) <= k then
- print ( "Your wish is granted!" )
-else
- print ( "You will become a flying monkey!" )
-end
+12
#include <iostream>
+
+using namespace std ;
+
+int main ()
+{
+ int a , b ;
+ cin >> a >> b ;
+ int ans = ( a > b ) ? 1 : 0 ;
+ cout << ans << endl ;
+ return 0 ;
+}
+
package main
+
+import "fmt"
+
+func main () {
+ var a , b int
+ fmt . Scan ( & a )
+ fmt . Scan ( & b )
+ if a > b {
+ fmt . Println ( 1 )
+ } else {
+ fmt . Println ( 0 )
+ }
+}
+
import java.util.Scanner ;
+
+class WhichisGreater {
+ public static void main ( String [] args ) {
+ Scanner s = new Scanner ( System . in );
+ int a = s . nextInt ();
+ int b = s . nextInt ();
+ if ( a > b ){
+ System . out . println ( 1 );
+ } else {
+ System . out . println ( 0 );
+ }
+ }
+}
+
const readline = require ( "readline" );
+const rl = readline . createInterface ( process . stdin , process . stdout );
+
+rl . question ( "" , ( line ) => {
+ [ a , b ] = line
+ . trim ()
+ . split ( " " )
+ . map (( e ) => parseInt ( e ));
+ if ( a > b ) {
+ console . log ( 1 );
+ } else {
+ console . log ( 0 );
+ }
+});
import math
-
-n , k = [ int ( d ) for d in input () . split ()]
-ans = math . log ( n , 2 ) <= k
-if ans :
- print ( "Your wish is granted!" )
-else :
- print ( "You will become a flying monkey!" )
-
Solution in Python Python
mapping = {
- 0 : "zero" ,
- 1 : "one" ,
- 2 : "two" ,
- 3 : "three" ,
- 4 : "four" ,
- 5 : "five" ,
- 6 : "six" ,
- 7 : "seven" ,
- 8 : "eight" ,
- 9 : "nine" ,
- 10 : "ten" ,
- 11 : "eleven" ,
- 12 : "twelve" ,
-}
-
-
-def f ( d ):
- if d < 13 :
- return mapping [ d ]
-
- ones = d % 10
- if d < 20 :
- return { 3 : "thir" , 5 : "fif" , 8 : "eigh" } . get ( ones , mapping [ ones ]) + "teen"
-
- tens = d // 10
- return (
- { 2 : "twen" , 3 : "thir" , 4 : "for" , 5 : "fif" , 8 : "eigh" } . get ( tens , mapping [ tens ])
- + "ty"
- + ( "-" + mapping [ ones ] if ones else "" )
- )
-
-
-def t ( w ):
- if w . isdigit ():
- return f ( int ( w ))
- else :
- return w
-
-
-while True :
- try :
- words = input ()
- except :
- break
- print ( " " . join ([ t ( w ) for w in words . split ()]))
-
Solution in Python Solution in Python Solution in Python Solutions in 2 languages Solution in Python Python
l , d , x = input (), input (), input ()
-l , d , x = int ( l ), int ( d ), int ( x )
-
-for i in range ( l , d + 1 ):
- if sum ([ int ( d ) for d in str ( i )]) == x :
- print ( i )
- break
-
-for i in range ( d , l - 1 , - 1 ):
- if sum ([ int ( d ) for d in str ( i )]) == x :
- print ( i )
- break
-
Solutions in 2 languages Solution in Python Python
mapping = {
+ 0 : "zero" ,
+ 1 : "one" ,
+ 2 : "two" ,
+ 3 : "three" ,
+ 4 : "four" ,
+ 5 : "five" ,
+ 6 : "six" ,
+ 7 : "seven" ,
+ 8 : "eight" ,
+ 9 : "nine" ,
+ 10 : "ten" ,
+ 11 : "eleven" ,
+ 12 : "twelve" ,
+}
+
+
+def f ( d ):
+ if d < 13 :
+ return mapping [ d ]
+
+ ones = d % 10
+ if d < 20 :
+ return { 3 : "thir" , 5 : "fif" , 8 : "eigh" } . get ( ones , mapping [ ones ]) + "teen"
+
+ tens = d // 10
+ return (
+ { 2 : "twen" , 3 : "thir" , 4 : "for" , 5 : "fif" , 8 : "eigh" } . get ( tens , mapping [ tens ])
+ + "ty"
+ + ( "-" + mapping [ ones ] if ones else "" )
+ )
+
+
+def t ( w ):
+ if w . isdigit ():
+ return f ( int ( w ))
+ else :
+ return w
+
+
+while True :
+ try :
+ words = input ()
+ except :
+ break
+ print ( " " . join ([ t ( w ) for w in words . split ()]))
+
Solution in Python Solution in Python Solution in Python Solution in Python Solution in Python Solutions in 2 languages Solution in Python Solution in Python Solution in Python Back to top