当前位置:网站首页>2303. Calculate the total tax payable
2303. Calculate the total tax payable
2022-07-02 15:40:00 【Laver (nori)】
class Solution {
public:
double calculateTax(vector<vector<int>>& brackets, int income) {
double ans = 0;
for(int i = brackets.size() - 1; i > 0; --i){
auto &vec = brackets[i];
auto &vec1 = brackets[i - 1];
// When income Skip directly when not in this interval
if(vec[0] > income && vec1[0] > income){
continue;
}
// The difference in the middle
int diff = income - vec1[0];
// The tax that should be paid for this part of the difference , Here is the actual value 100 times
ans += (diff * vec[1]);
// The remaining uncomputed income
income = vec1[0];
}
// Calculate the minimum range , Tax payable , Here is the actual value 100 times
ans += (income * brackets[0][1]);
// Calculate the actual tax
ans /= 100;
return ans;
}
};
边栏推荐
- Bing.com網站
- 终于搞懂了JS中的事件循环,同步/异步,微任务/宏任务,运行机制(附笔试题)
- Case introduction and problem analysis of microservice
- 提前批院校名称
- MD5 encryption
- (Video + graphic) machine learning introduction series - Chapter 5 machine learning practice
- LeetCode刷题——去除重复字母#316#Medium
- List set & UML diagram
- 6092. 替换数组中的元素
- Party History Documentary theme public welfare digital cultural and creative products officially launched
猜你喜欢
. Net again! Happy 20th birthday
LeetCode刷题——统计各位数字都不同的数字个数#357#Medium
How to avoid 7 common problems in mobile and network availability testing
MySQL -- Index Optimization -- order by
Facing the challenge of "lack of core", how can Feiling provide a stable and strong guarantee for customers' production capacity?
【LeetCode】1905-统计子岛屿
Download blender on Alibaba cloud image station
03.golang初步使用
自定义异常
【网络安全】网络资产收集
随机推荐
LeetCode刷题——去除重复字母#316#Medium
高考录取分数线爬取
【LeetCode】283-移动零
Leetcode skimming -- sum of two integers 371 medium
夏季高考文化成绩一分一段表
Pytoch saves tensor to Mat file
彻底弄懂浏览器强缓存和协商缓存
6092. 替换数组中的元素
MySQL -- Index Optimization -- order by
搭载TI AM62x处理器,飞凌FET6254-C核心板首发上市!
飞凌嵌入式RZ/G2L处理器核心板及开发板上手评测
folium,确诊和密接轨迹上图
2022 年辽宁省大学生数学建模A、B、C题(相关论文及模型程序代码网盘下载)
Custom exception
(Video + graphic) machine learning introduction series - Chapter 5 machine learning practice
LeetCode_ Sliding window_ Medium_ 395. Longest substring with at least k repeated characters
语义分割学习笔记(一)
[leetcode] 200 number of islands
LeetCode刷题——两整数之和#371#Medium
[solution] educational codeforces round 82