当前位置:网站首页>2303. 计算应缴税款总额
2303. 计算应缴税款总额
2022-07-02 12:10:00 【紫菜(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];
// 当income不在这个区间时直接跳过
if(vec[0] > income && vec1[0] > income){
continue;
}
// 中间的差值
int diff = income - vec1[0];
// 这部分差值所应该交的税,这里是实际值的100倍
ans += (diff * vec[1]);
// 当前剩余未计算的income
income = vec1[0];
}
// 计算最小的范围,应交的税,这里是实际值的100倍
ans += (income * brackets[0][1]);
// 计算实际税
ans /= 100;
return ans;
}
};边栏推荐
- folium,确诊和密接轨迹上图
- Party History Documentary theme public welfare digital cultural and creative products officially launched
- 02_线性表_顺序表
- 16_Redis_Redis持久化
- 【LeetCode】876-链表的中间结点
- 【LeetCode】1905-统计子岛屿
- How to choose a third-party software testing organization for automated acceptance testing of mobile applications
- Leetcode skimming -- sum of two integers 371 medium
- 百变大7座,五菱佳辰产品力出众,人性化大空间,关键价格真香
- [development environment] install the Chinese language pack for the 2013 version of visual studio community (install test agents 2013 | install visual studio 2013 simplified Chinese)
猜你喜欢
随机推荐
18_Redis_Redis主从复制&&集群搭建
Steps for Navicat to create a new database
高考录取分数线爬虫
07_ Hash
List set & UML diagram
Leetcode skimming - remove duplicate letters 316 medium
vChain: Enabling Verifiable Boolean Range Queries over Blockchain Databases(sigmod‘2019)
Summary of the first three passes of sqli Labs
【LeetCode】283-移动零
21_Redis_浅析Redis缓存穿透和雪崩
微信支付宝账户体系和支付接口业务流程
6.12 critical moment of Unified Process Platform
党史纪实主题公益数字文创产品正式上线
FPGA - 7系列 FPGA内部结构之Clocking -03- 时钟管理模块(CMT)
Build your own semantic segmentation platform deeplabv3+
【LeetCode】977-有序数组的平方
Data analysis thinking analysis methods and business knowledge - business indicators
04.进入云原生后的企业级应用构建的一些思考
【LeetCode】1020-飞地的数量
(Video + graphic) machine learning introduction series - Chapter 5 machine learning practice









