Codeforces Round #573
2024-09-05 19:52:23
http://codeforces.com/contest/1191
A
给一个数,可以加0,1或2然后取模,再映射到字母,字母有排名,求最大排名。
总共只有4种情况,讨论即可
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#define ll long long
#define fo(i,l,r) for(int i = l;i <= r;i++)
#define fd(i,l,r) for(int i = r;i >= l;i--)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
using namespace std;
const int maxn = ;
const ll inf = 987654321234500LL;
const ll mod = 1e9+;
ll n;
ll read() {
ll x=,f=;
char ch=getchar();
while(!(ch>=''&&ch<='')) {
if(ch=='-')f=-;
ch=getchar();
};
while(ch>=''&&ch<='') {
x=x*+(ch-'');
ch=getchar();
};
return x*f;
}
int tran[]={,,,};
int main() {
n=read();
int mx,dd;
n %= ;
if(n==){
dd=;
mx = ;
}
if(n==){
dd = ;
mx = ;
}
if(n==){
dd = ;
mx = ;
}
if(n==){
dd = ;
mx = ;
}
cout<<dd<<" "<<(char)('A'+mx);
return ;
}
B
一副牌,看看有没有三张一样的牌或者三张连号的牌
遍历
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#define ll long long
#define fo(i,l,r) for(int i = l;i <= r;i++)
#define fd(i,l,r) for(int i = r;i >= l;i--)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
using namespace std;
const int maxn = ;
const ll inf = 987654321234500LL;
const ll mod = 1e9+;
ll n;
ll read() {
ll x=,f=;
char ch=getchar();
while(!(ch>=''&&ch<='')) {
if(ch=='-')f=-;
ch=getchar();
};
while(ch>=''&&ch<='') {
x=x*+(ch-'');
ch=getchar();
};
return x*f;
}
char a[][];
int p[][];
int main() {
scanf("%s %s %s",a[],a[],a[]);
fo(i,,){
int hs = ;
if(a[i][]=='m')hs=;
if(a[i][]=='p')hs=;
if(a[i][]=='s')hs=;
p[hs][a[i][]-'']++;
}
int ans = ;
fo(i,,){
fo(j,,){
ans = min(ans,-p[i][j]);
}
fo(j,,){
ans = min(ans,-((p[i][j]>=)+(p[i][j+]>=)+(p[i][j+]>=)));
}
}
cout<<ans;
return ;
}
C
一个纸带,分成若干段,把一些位置标记,每轮把第一个有标记的段的所有标记位置拿走,后面的位置向前顺延,问多少次取完
这个标记段是不断后移的,算一下下次在哪个段就行了
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#define ll long long
#define fo(i,l,r) for(int i = l;i <= r;i++)
#define fd(i,l,r) for(int i = r;i >= l;i--)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
using namespace std;
const int maxn = ;
const ll inf = 987654321234500LL;
const ll mod = 1e9+;
ll read() {
ll x=,f=;
char ch=getchar();
while(!(ch>=''&&ch<='')) {
if(ch=='-')f=-;
ch=getchar();
};
while(ch>=''&&ch<='') {
x=x*+(ch-'');
ch=getchar();
};
return x*f;
}
ll n,m,k;
ll p[maxn];
ll lp,rp;
int main() {
n=read();
m=read();
k=read();
fo(i,,m){
p[i]=read();
}
lp = ;
rp = k;
ll hasp=,nowhp;
ll ans = ;
ll pos = ;
while(pos <= m){
nowhp=;
while(pos <= m && p[pos]-hasp<=rp){
nowhp++;
pos++;
}
if(nowhp)ans++;
hasp += nowhp;
if(rp < p[pos]-hasp){
ll tmp = (p[pos]-hasp-rp);
tmp = (tmp-)/k + ;
tmp *= k;
lp += tmp;
rp += tmp;
}
}
cout<<ans;
return ;
}
D
有n堆石子,两人轮流从一堆里取一块,什么时候取不了了,或者有两堆高度一样的(包括0),那这个人就输了。问谁赢。
假设先手面临的不是必败态,最后的必败态是0、1、2、3...n这种情况,看谁先到达。
先手必败有哪些?都是0的,和包含相同的,如果包含一个相同的对,其他再没有相同的对,并且这一对不是0,且没有恰好比它们高度小1的堆,那就不是必败,否则是必败。
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#define ll long long
#define fo(i,l,r) for(int i = l;i <= r;i++)
#define fd(i,l,r) for(int i = r;i >= l;i--)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
using namespace std;
const int maxn = ;
const ll inf = 987654321234500LL;
const ll mod = 1e9+;
ll read() {
ll x=,f=;
char ch=getchar();
while(!(ch>=''&&ch<='')) {
if(ch=='-')f=-;
ch=getchar();
};
while(ch>=''&&ch<='') {
x=x*+(ch-'');
ch=getchar();
};
return x*f;
}
int n;
ll a[maxn];
int main() {
n=read();
fo(i,,n){
a[i]=read();
}
sort(a+,a++n);
ll cnt = ;
fo(i,,n-){
if(a[i]==a[i+]){
cnt++;
if(a[i]==)cnt++;
if(i > && a[i]==a[i-]+)cnt++;
}
}
if(cnt > ){
cout<<"cslnb";
return ;
}
cnt = ;
fo(i,,n){
cnt += (ll)a[i]-(ll)(i-);
}
if(cnt&)cout<<"sjfnb";
else cout<<"cslnb";
return ;
}
最新文章
- NodeJs 开发微信公众号(五)真实环境部署
- 关于JavaScript中的delete操作
- HTML5 data-* 自定义属性
- [lua大坑]一个莫名其妙的lua执行时崩溃引出的堆栈大小问题
- fatal error: Call to undefined function mysqli_connect()
- XMLHttpRequestUtil
- codeforces 556B. Case of Fake Numbers 解题报告
- WordCount示例深度学习MapReduce过程(1)
- Xcode 编辑时的爆炸效果
- tomcat 启动时参数设置说明
- ASP.NET MVC的处理管线
- PSR-4——新鲜出炉的PHP规范
- Android学习之路——简易版微信为例(一)
- iOS极光推送
- 从Excel转Access的一个方法说开去(DataRow的state状态)
- 融云(找到“每个App都有沟通的需求”的细分市场)
- Redis和Memcached的区别【转】
- UWP:使用Behavior实现Button点击动态效果
- (转)Eclipse快捷键 10个最有用的快捷键
- POJ 1469(裸二分匹配)