标签:AtCoder typedef const Beginner int cin long 085 include
目录A - Already 2018
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
typedef long long LL;
string s;
int main(){
cin>>s;
s[3] = '8';
cout << s << endl;
return 0;
}
B - Kagami Mochi
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
typedef long long LL;
int n;
set<int> st;
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
int x;
cin >> x;
st.insert(x);
}
cout << st.size() << endl;
return 0;
}
C - Otoshidama
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
typedef long long LL;
int n, y;
int main() {
cin >> n >> y;
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= n; j++) {
int k = n - i - j;
if (k < 0) continue;
if(i*10000+j*5000+k*1000==y){
cout << i << ' ' << j << ' ' << k << endl;
return 0;
}
}
}
cout << -1 << ' ' << -1 << ' ' << -1 << endl;
return 0;
}
D - Katana Thrower
给出n个武器的一般攻击力,以及将其扔出的攻击力,一般攻击可以重复使用无限次,但是扔出只能使用一次
问将小怪兽杀死最多需要多少次攻击
利用优先队列,首先将所有的武器按照扔出和一般攻击两种形态放到队列里,然后每次取队头,如果当前的武器是扔出形态,那么就让小怪兽的血量减去扔出形态的攻击力,否则如果是一般形态,那么就直接算可以攻击几次即可,这样相当于从后往前模拟,保证了扔出形态只可能用一次
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
typedef long long LL;
struct node {
int a, b;
int use;
int flag;
} a[N];
int n, h;
struct cmp {
bool operator()(node a, node b) { return a.use < b.use; }
};
priority_queue<node, vector<node>, cmp> q;
int main() {
cin >> n >> h;
for (int i = 0; i < n; i++) {
cin >> a[i].a >> a[i].b;
q.push({a[i].a, a[i].b, a[i].a, 0});
q.push({a[i].a, a[i].b, a[i].b, 1});
}
int res = 0;
while(!q.empty()){
if (h <= 0) break;
node now = q.top();
q.pop();
//cout << now.use << endl;
if(now.flag==1){
h -= now.use;
now.use = now.a;
now.flag = 0;
q.push(now);
res++;
}
else{
res += int(ceil(1.0 * h / now.use));
break;
}
}
cout << res << endl;
return 0;
}
标签:AtCoder,typedef,const,Beginner,int,cin,long,085,include 来源: https://www.cnblogs.com/dyhaohaoxuexi/p/14391788.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。