关注
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;
}
查看原帖
点赞 评论
相关推荐
点赞 评论 收藏
分享
牛客热帖
更多
正在热议
更多
# 找工作能把i人逼成什么样 #
3922次浏览 41人参与
# 腾讯音乐求职进展汇总 #
142904次浏览 1032人参与
# 百融云创求职进展汇总 #
21876次浏览 144人参与
# 0经验如何找实习? #
13598次浏览 275人参与
# 最难的技术面是哪家公司? #
59953次浏览 934人参与
# 你今年做了几份实习? #
3936次浏览 64人参与
# 你找工作经历过哪些骗局? #
5021次浏览 92人参与
# 实习心态崩了 #
93689次浏览 487人参与
# 字节出了豆包coding模型 #
4452次浏览 46人参与
# 你开始找寒假实习了吗? #
7451次浏览 127人参与
# 实习越久越好,还是多多益善? #
10605次浏览 93人参与
# 25年找工作是什么难度? #
7406次浏览 84人参与
# 一上班就想____,这正常吗? #
2505次浏览 57人参与
# 刚工作,应该先搞钱or搞成长? #
4300次浏览 66人参与
# 离职你会和父母说吗? #
5832次浏览 79人参与
# 如果公司降薪,你会跳槽吗? #
109136次浏览 687人参与
# 实习必须要去大厂吗? #
167860次浏览 1658人参与
# 你是怎么和mt相处的? #
82332次浏览 435人参与
# 你的实习什么时候入职 #
323475次浏览 2192人参与
# 你会为了工作牺牲生活吗? #
64965次浏览 445人参与
# 产品每日一题 #
73371次浏览 662人参与
查看1道真题和解析
360集团公司福利 435人发布