2019網易互娛8 9筆試

2021-08-22 14:51:37 字數 2174 閱讀 4114

逐級扣稅,

關鍵:四捨五入 int(x+0.5)

問題:c++在本地編譯通過,在牛客不通過

import sys

def shui(x):

if(x<5000):

return 0

if(x>=5000 and x<8000):

return (x-5000)*0.03

if(x>=8000 and x<17000):

return (x-8000)*0.1+90

if(x>=17000 and x<30000):

return (x-17000)*0.2+990

if(x>=30000 and x<40000):

return (x-30000)*0.25+3590

if(x>=40000 and x<60000) :

return (x-40000)*0.3+6090

if(x>=60000 and x<85000):

return (x-60000)*0.35+12090

else:

return (x-85000)*0.35+20840

t = int(input())

for i in range(t):

x=int(input())

print(int(shui(x)+0.5))

群主2-管理1-成員0

級別相同按字典序排序

#!/usr/bin/python

# -*- coding: utf-8 -*-

dict1={}

n=int(input())

for i in range(n):

line= input().split()

dict1[line[1]]=int(line[0])#id name

m=int(input())

dict2={}

for i in range(m):

line= input().split()

dict2[line[0]]=int(line[1])#name status

for name in dict2:

dict1[name]+=dict2[name]*10 #上線的*10,id變大

res=sorted(dict1.items(),key=lambda item:(-item[1],item[0]))

for name,val in res:

print(name)

#!/usr/bin/python

# -*- coding: utf-8 -*-

def change(w,time):

h,m,s = list(map(int, time.split(":")))#小時 分鐘 秒

return w * 24 * 3600 + h * 3600 + m * 60 + s # 轉換成秒數

def check(time, opentimes):

res = float("inf")

for start, end in opentimes:

if start <= time <= end:

return 0

if start > time:

res = min(res, start - time)

return res

t=int(input())

for i in range(t):

opentimes=;

k=int(input()) # k天開放

for j in range(k):

line =input().split()

w,m=int(line[0]),int(line[1])#w星期 m次數

for k in range(m):

start, end = line[i+2].split("-")

c = int(input()) # c個查詢

for _ in range(c):

line = input().split()

w, clock = int(line[0]), line[1]

time = change(w, clock)

print(chenck(time, opentimes))

2020網易互娛筆試C題

題目 巴拉巴拉,沒有原題,懶得敲了 題意比較坑的地方在於,輸入的v對應的是第i個v 如果第一行的原序列是231 第二行的v序列是159 則對應上去就是591 一開始死在這個地方了 接下來討論解法 n分奇偶討論 n為偶數時,顯然直接交換1和2,3和4,n 1和n 這邊的數字指的是位置,不是序列對應的值...

2017網易互娛筆試題 括號匹配

題目描述 對於一行 字串 裡面可能出現大括號 中括號 和小括號 請程式設計判斷改行 的括號巢狀是否正確。printf hello netease 等都是括號使用的正確方法,print hello netease 則是錯誤的範例。輸入描述 輸入包含一行,為一行包含括號的字串 字串長度不超過1000 輸...

9 4 網易互娛客戶端筆試

做了一半圖書館閉館,我?第一題public class main for int i 0 i else else if hand.equals left caozuo.equals return else if hand.equals right caozuo.equals return else ...