fork download
  1. import sys
  2.  
  3. data = sys.stdin.read().strip().split()
  4. if not data:
  5. sys.exit(0)
  6.  
  7. N = int(data[0])
  8.  
  9. # Kiểm tra N
  10. if N < 1 or N > 10:
  11. print("INVALID INPUT")
  12. sys.exit(0)
  13.  
  14. idx = 1
  15.  
  16. def calc_tax(tntt: int) -> int:
  17. """Tính thuế TNCN từ TNTT (đơn vị VND)."""
  18. if tntt <= 0:
  19. return 0
  20.  
  21. # Bảng bậc thuế: (ngưỡng trên, thuế suất %, giảm trừ nhanh)
  22. brackets = [
  23. (5_000_000, 5, 0),
  24. (10_000_000, 10, 250_000),
  25. (18_000_000, 15, 750_000),
  26. (32_000_000, 20, 1_650_000),
  27. (52_000_000, 25, 3_250_000),
  28. (80_000_000, 30, 5_850_000),
  29. (float('inf'), 35, 9_850_000),
  30. ]
  31.  
  32. for upper, rate, ded in brackets:
  33. if tntt <= upper:
  34. return tntt * rate // 100 - ded
  35.  
  36. # Không tới được đây, nhưng để chắc chắn:
  37. return 0
  38.  
  39. for _ in range(N):
  40. if idx + 1 >= len(data):
  41. print("INVALID INPUT")
  42. break
  43.  
  44. m = int(data[idx])
  45. n = int(data[idx + 1])
  46. idx += 2
  47.  
  48. # Kiểm tra từng bộ test
  49. if m < 1000 or n < 1000:
  50. print("INVALID INPUT")
  51. continue
  52.  
  53. # Tính bảo hiểm
  54. bhxh = n * 8 // 100 # 8%
  55. bhyt = n * 15 // 1000 # 1.5%
  56. bhtn = n * 1 // 100 # 1%
  57. bh = bhxh + bhyt + bhtn
  58.  
  59. # Thu nhập chịu thuế
  60. giam_tru_ban_than = 11_000_000
  61. tntt = m - giam_tru_ban_than - bh
  62.  
  63. # Thuế TNCN
  64. thue = calc_tax(tntt)
  65.  
  66. print(f"{bh} {thue}")
  67.  
Success #stdin #stdout 0.13s 14096KB
stdin
Standard input is empty
stdout
Standard output is empty