关注
C++版 纳税题(通过率100%) #include
#include
using namespace std;
int main(int argc, char* argv[])
{
int T = 0;
while(cin >> T)
{
for(int i=0;i<T;i++)
{
int N = 0;
cin >> N;
vector a = {0, 3000, 12000, 25000, 35000, 55000, 80000};
vector b = {0.03, 0.1, 0.2, 0.25, 0.3, 0.35, 0.45};
float sum = 0;
int rest = N-5000;
for(int i=0;i<b.size()-1;i++)
{
if(rest>a[i])
{
sum += (rest>a[i+1]?(a[i+1]-a[i]):(rest-a[i])) * b[i];
}
}
if(rest>a[6])
{
sum += (rest-a[6]) * b[6];
}
sum += 0.5;
cout << int(sum) << endl;
}
}
return 0;
聊天会话列表题(通过率100%) #include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
typedef struct Node
{
int id;
string name;
}Node;
typedef struct compare
{
map<string, int> record;
compare(map<string, int> record)
{
this->record = record;
}
bool operator () (Node a, Node b)
{
/* 状态不同 */
if(this->record[a.name]!=this->record[b.name])
{
return this->record[a.name] > this->record[b.name];
}
/* 身份不同 */
if(a.id!=b.id)
{
return a.id > b.id;
}
return a.name < b.name;
}
}compare;
int main(int argc, char* argv[])
{
int N = 0;
while(cin >> N)
{
vector<Node> group;
for(int i=0;i<N;i++)
{
int id = 0;
string name;
cin >> id >> name;
group.push_back({id, name});
}
int M = 0;
cin >> M;
map<string, int> record;
for(int i=0;i<M;i++)
{
string name;
int state;
cin >> name >> state;
record[name] = state;
}
compare cmp(record);
stable_sort(group.begin(), group.end(), cmp);
for(auto it:group)
{
cout << it.name << endl;
}
}
return 0;
}
时间区间题(通过率0%, 时间来不及,差一点了) #include <iostream>
#include <vector>
#include <map>
using namespace std;
typedef struct Node
{
int start;
int end;
}Node;
int calc_time(map<int, vector<Node>>& schedule, int W, int& time, bool& flag)
{
int wait = 0;
if(schedule.count(W)!=0)
{
for(auto it:schedule[W])
{
if(time<it.start)
{
wait = it.start - time;
flag = true;
break;
}
if(time>=it.start && time<=it.end)
{
wait = 0;
flag = true;
break;
}
}
if(!flag)
{
wait = 24 * 3600 - time;
time = 0;
}
}
else
{
wait = 24 * 3600 - time;
time = 0;
}
return wait;
}
int main(int argc, char* argv[])
{
int T = 0;
while(cin >> T)
{
for(int i=0;i<T;i++)
{
int K = 0;
cin >> K;
map<int, vector<Node>> schedule;
for(int j=0;j<K;j++)
{
int W = 0, M = 0;
cin >> W >> M;
for(int k=0;k<M;k++)
{
int HH, MM, SS;
char ch;
int start = 0, end = 0;
cin >> HH >> ch >> MM >> ch >> SS;
start = HH * 3600 + MM * 60 + SS;
cin >> ch >> HH >> ch >> MM >> ch >> SS;
end = HH * 3600 + MM * 60 + SS;
schedule[W].push_back({start, end});
}
}
int C = 0;
cin >> C;
for(int j=0;j<C;j++)
{
int W = 0;
int HH, MM, SS;
char ch;
cin >> W >> HH >> ch >> MM >> ch >> SS;
int time = HH * 3600 + MM * 60 + SS;
bool flag = false;
int wait = calc_time(schedule, W, time, flag);
while(!flag)
{
W++;
wait += calc_time(schedule, W, time, flag);
}
cout << wait << endl;
}
}
}
return 0;
}
查看原帖
点赞 评论
相关推荐
点赞 评论 收藏
分享
07-16 20:10
门头沟学院 Java 点赞 评论 收藏
分享
牛客热帖
更多
正在热议
更多
# 第一份工作应该选高薪还是热爱? #
66825次浏览 593人参与
# 不考虑薪资和职业,你最想做什么工作呢? #
92092次浏览 679人参与
# 秋招签约后的心态变化 #
82543次浏览 814人参与
# 听劝,这个公司值得去吗 #
486171次浏览 1700人参与
# 你觉得早上几点上班合适? #
72389次浏览 303人参与
# 学历贬值真的很严重吗? #
24489次浏览 174人参与
# 机械人与华为的爱恨情仇 #
120170次浏览 957人参与
# 一人推荐一个值得去的通信/硬件公司 #
186496次浏览 1859人参与
# 打工人的工作餐日常 #
53258次浏览 415人参与
# 哪些公司真双非友好? #
15836次浏览 82人参与
# 26届的你们有几段实习? #
44130次浏览 488人参与
# 月薪多少能在一线城市生存 #
28178次浏览 305人参与
# 双非能在秋招上岸吗? #
221736次浏览 1172人参与
# 你以为的实习VS真实的实习 #
29850次浏览 274人参与
# 今年秋招哪家公司给的薪资最良心? #
252954次浏览 1418人参与
# 你后悔自己读研吗? #
20647次浏览 240人参与
# 当下环境,你会继续卷互联网,还是看其他行业机会 #
117938次浏览 812人参与
# 追觅科技求职进展汇总 #
18266次浏览 120人参与
# 实习想申请秋招offer,能不能argue薪资 #
149953次浏览 932人参与
# 如何KTV领导 #
62799次浏览 472人参与