关注
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人逼成什么样 #
2867次浏览 34人参与
# 腾讯音乐求职进展汇总 #
142851次浏览 1031人参与
# 百融云创求职进展汇总 #
10136次浏览 138人参与
# 0经验如何找实习? #
12153次浏览 245人参与
# 最难的技术面是哪家公司? #
59912次浏览 933人参与
# 你今年做了几份实习? #
3405次浏览 60人参与
# 实习心态崩了 #
93592次浏览 487人参与
# 你找工作经历过哪些骗局? #
4464次浏览 78人参与
# 你开始找寒假实习了吗? #
6507次浏览 112人参与
# 字节出了豆包coding模型 #
4387次浏览 45人参与
# 实习越久越好,还是多多益善? #
9605次浏览 81人参与
# 25年找工作是什么难度? #
6752次浏览 72人参与
# 一上班就想____,这正常吗? #
2279次浏览 53人参与
# 刚工作,应该先搞钱or搞成长? #
4032次浏览 62人参与
# 离职你会和父母说吗? #
5477次浏览 71人参与
# 实习必须要去大厂吗? #
167479次浏览 1654人参与
# 你是怎么和mt相处的? #
82212次浏览 434人参与
# 你的实习什么时候入职 #
323342次浏览 2191人参与
# 产品每日一题 #
73295次浏览 659人参与
# 顺丰求职进展汇总 #
71754次浏览 340人参与
# 转正答辩报告怎么写 #
47722次浏览 791人参与