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;
}