文章目录 520-1 浪漫表白 520-2 AI 销售 520-3 520红包 520-4 520数列 520-5 小情侣 520-6 How Pay (16分) 520-7 家务骰子 (19分) 520-8 青提
520-1 浪漫表白
def solve ( ) : print ( "Every day with you is a gift, but today is extra special." )
520-2 AI 销售
def solve ( ) : a, b = map ( int , input ( ) . split( ) ) s = min ( a, b) print ( s) if 0 < s <= 20 : print ( "XianHua" ) elif 20 < s <= 40 : print ( "XiangXun" ) elif 40 < s <= 60 : print ( "BaoWenBei" ) elif 60 < s <= 200 : print ( "HunShaZhao" )
520-3 520红包
def solve ( ) : a = list ( map ( int , input ( ) . split( ) ) ) print ( a. index( 520 ) + 1 )
520-4 520数列
def solve ( ) : n = int ( input ( ) ) if n == 1 : print ( 5 ) return if ( n == 2 ) : print ( 52 ) return if ( n == 3 ) : print ( 520 ) return v = [ 0 ] * ( n + 1 ) v[ 1 ] , v[ 2 ] , v[ 3 ] = 5 , 2 , 0 for i in range ( 4 , n + 1 ) : v[ i] = ( v[ i - 1 ] + v[ i - 2 ] + v[ i - 3 ] ) % 10 for i in range ( 1 , n + 1 ) : print ( v[ i] , end= '' )
520-5 小情侣
import sys
sys. setrecursionlimit( 1000000 )
input = lambda : sys. stdin. readline( ) . strip( ) def solve ( ) : input = sys. stdin. read( ) . split( ) ptr = 0 n = int ( input [ ptr] ) ptr += 1 r, c = map ( int , input [ ptr: ptr+ 2 ] ) ptr += 2 pos = { } for i in range ( r) : row = input [ ptr: ptr+ c] ptr += cfor j in range ( c) : student = int ( row[ j] ) if student != 0 : pos[ student] = ( i, j) k = int ( input [ ptr] ) ptr += 1 for _ in range ( k) : a = int ( input [ ptr] ) b = int ( input [ ptr+ 1 ] ) ptr += 2 ra, ca = pos[ a] rb, cb = pos[ b] if ( ra == rb and abs ( ca - cb) == 1 ) or ( ca == cb and abs ( ra - rb) == 1 ) : print ( "yes" ) else : print ( "no" )
520-6 How Pay (16分)
import sys
sys. setrecursionlimit( 1000000 )
input = lambda : sys. stdin. readline( ) . strip( )
from collections import deque, Counter, defaultdictdef check ( a, b) - > bool : na, nb = len ( a) , len ( b) if na != nb: return False a = a. lower( ) b = b. lower( ) cnt = 0 v1, v2 = [ ] , [ ] for i in range ( na) : if a[ i] != b[ i] : v1. append( a[ i] ) v2. append( b[ i] ) else : cnt += 1 cnta = Counter( v1) for c in v2: if cnta[ c] : cnt += 1 return cnt >= 4 def solve ( ) : n = int ( input ( ) ) for _ in range ( n) : a, b = map ( str , input ( ) . split( ) ) print ( "how pay" if check( a, b) else "bull pay" )
solve( )
520-7 家务骰子 (19分)
import sys
sys. setrecursionlimit( 1000000 )
input = lambda : sys. stdin. readline( ) . strip( )
from collections import deque, Counter, defaultdictdef solve ( ) : n = int ( input ( ) ) cnt_p = defaultdict( int ) cnt_t = defaultdict( int ) for _ in range ( n) : x, p = map ( int , input ( ) . split( ) ) if x == 1 or x == 2 or x == 3 or x == 5 : cnt_p[ p] += 1 cnt_t[ x] += 1 maxp = max ( cnt_p. values( ) ) pers = [ p for p, cnt in cnt_p. items( ) if cnt == maxp] if len ( pers) == 2 : print ( f"LOVE { maxp} " ) else : print ( f" { pers[ 0 ] } { maxp} " ) if cnt_t: maxt_cnt = max ( cnt_t. values( ) ) tasks = sorted ( [ t for t, cnt in cnt_t. items( ) if cnt == maxt_cnt] ) print ( f" { maxt_cnt} { ' ' . join( map ( str , tasks) ) } " )
520-8 青提
import sys
sys. setrecursionlimit( 1000000 )
input = lambda : sys. stdin. readline( ) . strip( ) from collections import deque, Counter, defaultdictdef solve ( ) : n = int ( input ( ) ) dic = defaultdict( str ) for _ in range ( n) : a, b = map ( str , input ( ) . split( ) ) dic[ a] = bdic[ b] = am = int ( input ( ) ) for _ in range ( m) : a, b = map ( str , input ( ) . split( ) ) if dic[ a] == b or dic[ b] == a: print ( "(~_~)" ) else : print ( "o(@O@)o" ) solve( )