题目大意 :
解题思路:
参考代码:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e5 + 5;
int T, n;
int a[N];
void slove() {
cin >> n;
int ok = 0;
for (int i = 1; i <= n; i++) {
cin >> a[i];
if (a[i] <= i) ok = 1;
}
if (ok) cout << "YES" << endl;
else cout << "NO" << endl;
}
int main() {
cin >> T;
while (T--) slove();
return 0;
}
题目大意:
解题思路:
参考代码:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e5 + 5;
ll T, n;
vector<int>ans;
int cnt;
void slove() {
cin >> n;
if (n % 2 == 0) cout << -1 << endl;
else {
cnt = -1;
ans.clear();
while (n) {
cnt++;
if (n % 2 == 1)ans.push_back(2);
else ans.push_back(1);
n /= 2;
}
cout << cnt << endl;
for (int i=ans.size()-1;i>=1;i--) cout << ans[i] << ' ';
cout << endl;
}
}
int main() {
cin >> T;
while (T--) slove();
return 0;
}
题目大意:
解题思路:
参考代码:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e5 + 5;
ll T, n, c, d;
ll cnt, x;
unordered_map<int, bool>mp;
vector<int>key;
void slove() {
cin >> n >> c >> d;
cnt = 0;
mp.clear();
key.clear();
key.push_back(0);
for (int i = 1; i <= n; i++) {
cin >> x;
if (mp[x]) cnt += c;
else mp[x] = 1, key.push_back(x);
}
ll ans = 2e18;
ll len = mp.size();
sort(key.begin(), key.end());
for (int i = 1; i <= len; i++) {
ans = min(ans, (key[i] - i) * d + (len - i) * c);
}
ans = min(ans, d + len * c);
cout << ans + cnt << endl;
}
int main() {
cin >> T;
while (T--) slove();
return 0;
}
D
题目大意:
解题思路:
参考代码:
E
F