# 第十四届蓝桥杯 社区打卡 Day2

TralSun 2023-03-05 09:03:17

# T1

``````#include <iostream>
using namespace std;
bool check(int x) {
while (x) {
int t = x % 10;
if (t % 2 == 0) return false;
x /= 10;
}
return true;
}
int main()
{
int t = 1;
while (true) {
if (check(2019 * t)) {
cout << 2019 * t;
break;
}
++t;
}
return 0;
}``````

# T2

``````#include <bits/stdc++.h>
using namespace std;
int fun(int x) {
unordered_map<int, int> cnt;
for (int i = 2; i <= sqrt(x); ++i) {
while (x % i == 0) {
cnt[i]++;
x /= i;
}
}
if (x > 1) cnt[x]++;
int ans = 1;
for (auto u : cnt) {
ans = ans * (u.second + 1);
}
return ans;
}
int main()
{
int t = 1;
while (fun(t) != 100) {
++t;
}
cout << t;
return 0;
}``````

# T3

``````#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 100;
int a[N], n;
int main()
{
cin >> n;
for (int i = 1; i <= n; ++i) cin >> a[i], a[i] += a[i - 1];
long long ans = 0;
for (int i = 1; i <= n - 1; ++i) {
ans += (long long)(a[i] - a[i - 1]) * (a[n] - a[i]);
}
cout << ans;
return 0;
}``````

# T4

``````#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct node {
int val, sum;
bool operator< (const node &a) {
return sum < a.sum || sum == a.sum && val < a.val;
}
};
vector<node> v;
int fun(int x) {
int ans = 0;
while (x) {
ans += x % 10;
x /= 10;
}
return ans;
}
int main()
{
int n, m; cin >> n >> m;
for (int i = 1; i <= n; ++i) {
v.push_back({i, fun(i)});
}
sort(v.begin(), v.end());
cout << v[m - 1].val;
return 0;
}``````

...全文
4 回复 打赏 收藏 举报

3.1w+

2023-03-05 09:03

刷题！