当前位置:网站首页>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;
}
};
边栏推荐
猜你喜欢
【LeetCode】1905-统计子岛屿
. Net again! Happy 20th birthday
让您的HMI更具优势,FET-G2LD-C核心板是个好选择
Case introduction and problem analysis of microservice
基于RZ/G2L | OK-G2LD-C开发板存储读写速度与网络实测
Semantic segmentation learning notes (1)
彻底弄懂浏览器强缓存和协商缓存
MySQL calculate n-day retention rate
I made an istio workshop. This is the first introduction
Solve the problem of frequent interruption of mobaxterm remote connection
随机推荐
College entrance examination admission score line crawler
. Solution to the problem of Chinese garbled code when net core reads files
怎样从微信返回的json字符串中截取某个key的值?
Leetcode skimming -- count the number of numbers with different numbers 357 medium
Pytorch 保存tensor到.mat文件
LeetCode刷题——奇偶链表#328#Medium
Case introduction and problem analysis of microservice
2022 年辽宁省大学生数学建模A、B、C题(相关论文及模型程序代码网盘下载)
6095. 强密码检验器 II
6.12 企业内部upp平台(Unified Process Platform)的关键一刻
Custom exception
SQL stored procedure
【LeetCode】877-石子游戏
02. After containerization, you must face golang
【LeetCode】19-删除链表的倒数第N个结点
面对“缺芯”挑战,飞凌如何为客户产能提供稳定强大的保障?
[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)
yolo格式数据集处理(xml转txt)
Force deduction solution summarizes the lucky numbers in 1380 matrix
党史纪实主题公益数字文创产品正式上线