Codefroces-NCST-ACM 11-30 Training
原题跳转
A
#include<bits/stdc++.h>
#define int long long
using namespace std;
bool check(int x)
{
int k = 0;
while(x)
{
k += x % 10;
x /= 10;
}
return k == 10;
}
void solve()
{
int ans = 19;
int k = 1;
cin >> k;
int cnt = 1;
for(int i = ans; ; i++)
{
if(check(i))
{
if(cnt == k)
{
cout << i << "\n";
return;
}
cnt++;
}
}
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
while(t--)
solve();
return 0;
}
B
#include<bits/stdc++.h>
#define int long long
using namespace std;
void solve()
{
int n;
cin >> n;
vector<int> a(n + 2);
vector<int> b(n + 2);
for(int i = 1; i <= n; i++)
{
cin >> a[i];
b[max(0ll, i - a[i] + 1)] += 1;
b[i + 1] -= 1;
}
for(int i = 1; i <= n; i++)
{
b[i] += b[i - 1];
}
for(int i = 1; i <= n; i++)
{
if(b[i]) cout << "1 ";
else cout << "0 ";
}
cout << "\n";
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
while(t--)
solve();
return 0;
}
C.
#include<bits/stdc++.h>
#define int long long
using namespace std;
void solve()
{
int n, m, k;
cin >> n >> m >> k;
vector<string> s(n);
for(auto &x : s) cin >> x;
int cnt = 0;
if(k == 1)
{
for(int i = 0; i < n; i++)
{
for(int j = 0; j < m; j++)
{
if(s[i][j] == '.') cnt++;
}
}
cout << cnt << "\n";
return;
}
if(m != 1)
{
for(int i = 0; i < n; i++)
{
for(int j = 0; j < m; j++)
{
int siz = 0;
while(j < m && s[i][j] == '.')
{
j++;
siz++;
if(siz >= k)
{
cnt++;
}
}
}
}
}
if(n != 1)
{
for(int i = 0; i < m; i++)
{
for(int j = 0; j < n; j++)
{
int siz = 0;
while(j < n && s[j][i] == '.')
{
j++;
siz++;
if(siz >= k)
{
cnt++;
}
}
}
}
}
cout << cnt << "\n";
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
while(t--)
solve();
return 0;
}
/*
1 1 1
.
2
*/
/*
2 1 1
.
.
2
*/
D.
E.
F.
G.
// Problem: G. Monitor
// Contest: Codeforces - NCST-ACM 11-30 Training
// URL: https://codeforces.com/group/AlBkNycyFm/contest/489875/problem/G
// Memory Limit: 64 MB
// Time Limit: 500 ms
// Date:2023-12-01 01:08:23
// Author:hblgzsx
// 借鉴思路:自己
//
// Powered by CP Editor (https://cpeditor.org)
#include<bits/stdc++.h>
#define int long long
using namespace std;
void solve()
{
int a, b, x, y;
cin >> a >> b >> x >> y;
int xygcd = __gcd(x, y);
x = x / xygcd;
y = y / xygcd;
int l = 0, r = a + 1;
while(l + 1 < r)
{
int mid = (l + r) / 2;
if((mid * y / x) <= b) l = mid;
else r = mid;
}
if((l * y) != (l / x * y * x))
{
cout << l / x * y * x / y << " " << l / x * y << "\n";
}
else cout << l << " " << l / x * y << "\n";
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
while(t--)
solve();
return 0;
}