AtCoder Beginner Contest 205
A
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
int main() {
const double m = 100.0;
int A,B;
cin >> A >> B;
double b = B / m;
cout << A * b << endl;
return 0;
}
B
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <unordered_set>
using namespace std;
int main() {
int N;
cin >> N;
unordered_set<int> set;
for (int i = 0; i < N; i++)
{
int t;
cin >> t;
set.emplace(t);
}
bool miss = false;
for(int i = 1; i <= N; i++) {
if (set.find(i) == set.end())
{
miss = true;
break;
}
}
if (miss)
{
cout << "No" << endl;
}
else {
cout << "Yes" << endl;
}
return 0;
}
C
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <unordered_set>
using namespace std;
int main() {
int64_t A,B,C;
cin >> A >> B >> C;
if (!(C & 1)) // if C is even
{
if (abs(A) < abs(B))
{
cout << "<" << endl;
}
else if (abs(A) > abs(B))
{
cout << ">" << endl;
}
else
{
cout << "=" << endl;
}
}
else // if C is odd
{
if (A < B)
{
cout << "<" << endl;
}
else if (A > B)
{
cout << ">" << endl;
}
else
{
cout << "=" << endl;
}
}
return 0;
}
D
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
int N, Q;
cin >> N >> Q;
vector<int64_t> v;
for(int i = 0; i < N; i++) {
int64_t t;
cin >> t;
v.push_back(t);
}
// count how many available number from [1,+] without in v and before v[i];
//
vector<int64_t> vv;
for(int i = 1; i<= N; i++) {
vv.push_back(v[i - 1] - i);
}
while (Q --)
{
int64_t q;
cin >> q;
int j = lower_bound(vv.begin(), vv.end(), q) - vv.begin();
if (j == N) // if q is outside of vv
{
cout << v[N - 1] + q - vv[N - 1] << endl;
}
else
{
cout << v[j] - vv[j] + q - 1 << endl;
}
}
return 0;
}