比赛链接
A - Welcome to AtCoder Land
AC_Code
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main()
{
string s,t;
cin >> s >> t;
if(s == "AtCoder" && t == "Land")
cout << "Yes\n";
else
cout << "No\n";
return 0;
}
B - Ticket Counter
AC_Code
#include <bits/stdc++.h>
using namespace std;
#define int long long
int t[110];
signed main()
{
int n,a;
cin >> n >> a;
for(int i = 1; i <= n; i++)
cin >> t[i];
int last = 0;
for(int i = 1; i <= n; i++)
{
last = max(last,t[i]) + a;
cout << last << "\n";
}
return 0;
}
C - Popcorn
AC_Code
#include <bits/stdc++.h>
using namespace std;
#define int long long
string s[20];
int val[20];
signed main()
{
int n,m;
cin >> n >> m;
for(int i = 1; i <= n; i++)
{
cin >> s[i];
val[i] = 0;
for(int j = 0; j < s[i].length(); j++)
val[i] = val[i] * 2 + (s[i][j] == 'o' ? 1 : 0);
}
int ans = n;
for(int s = 0; s < (1 << n); s++)
{
int now = 0,cnt = 0;
for(int i = 1; i <= n; i++)
{
if(s & (1 << (i - 1)))
now |= val[i],cnt++;
}
if(now == (1 << m) - 1)
ans = min(ans,cnt);
}
cout << ans << "\n";
return 0;
}
D - Souvenirs
AC_Code
#include <bits/stdc++.h>
using namespace std;
#define int long long
int a[200010],b[200010];
signed main()
{
int n,m;
cin >> n >> m;
for(int i = 1; i <= n; i++)
cin >> a[i];
for(int j = 1; j <= m; j++)
cin >> b[j];
sort(a + 1,a + n + 1);
sort(b + 1,b + m + 1);
int pos1 = 1,ans = 0;
bool flag = true;
for(int i = 1; i <= m; i++)
{
int l = pos1,r = n,tmp = -1;
while(l <= r)
{
int mid = (l + r) >> 1;
if(a[mid] < b[i])
l = mid + 1;
else
r = mid - 1,tmp = mid;
}
if(tmp == -1 || a[tmp] < b[i])
{
flag = false;
break;
}
ans += a[tmp];
pos1 = tmp + 1;
}
if(flag)
cout << ans << "\n";
else
cout << "-1\n";
return 0;
}
E - Alphabet Tiles
AC_Code
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 998244353
int c[30],dp[30][1010],C[2010][2010];
void init()
{
for(int i = 0; i <= 2000; i++)
{
for(int j = 0; j <= i; j++)
{
if(i == j || j == 0)
C[i][j] = 1;
else
C[i][j] = C[i - 1][j] + C[i - 1][j - 1];
C[i][j] %= mod;
}
}
}
signed main()
{
int k;
cin >> k;
init();
for(int i = 1; i <= 26; i++)
cin >> c[i];
dp[0][0] = 1;
for(int i = 1; i <= 26; i++)
{
for(int j = 0; j <= k; j++)
{
dp[i][j] += dp[i - 1][j];
dp[i][j] %= mod;
for(int l = 1; l <= c[i]; l++)
{
if(l > j)
break;
dp[i][j] += dp[i - 1][j - l] * C[j][l];
dp[i][j] %= mod;
}
}
}
int ans = 0;
for(int i = 1; i <= k; i++)
ans += dp[26][i],ans %= mod;
cout << ans << "\n";
return 0;
}
标签:tmp,AtCoder,ABC,int,namespace,long,include,358,define
From: https://www.cnblogs.com/cookiebread/p/18260812/ABC358Summary