# Educational Codeforces Round 80 (Rated for Div. 2)

## B. Yet Another Meme Problem

#### 题解

$b$ 的位数位为 $l$ ,那么那个式子就可以写成$ab+a+b=a*10^l+b$，稍微化简一下就很显然了，注意要特判$b$ 全是9的情况

#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<queue>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long LL;
typedef pair<int,int> PII;
#define X first
#define Y second
{
int x=0,f=1;char c=getchar();
while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
while(isdigit(c)){x=x*10+c-'0';c=getchar();}
return x*f;
}
int T,a,cnt;
char b[20];
int main()
{
while(T--)
{
int len=strlen(b);
cnt=len-1;
bool ok=0;
for(int i=0;i<len;i++)if(b[i]!='9')ok=1;
if(!ok)cnt++;
cout<<(LL)cnt*(LL)a<<endl;
}
return 0;
}
/*

*/



## C. Two Arrays

#### 题解

I suck.OK I suck.

$f[i][j]$表示当前为第i位，第i位为j的方案书。$f[i][j]=\sum f[i-1][j] (j\leq i)$

#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<queue>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long LL;
typedef pair<int,int> PII;
#define X first
#define Y second
{
int x=0,f=1;char c=getchar();
while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
while(isdigit(c)){x=x*10+c-'0';c=getchar();}
return x*f;
}
const int MOD=1000000007;
int n,m,dp[30][1010],ans;
int main()
{
for(int i=1;i<=n;i++)dp[1][i]=1;
for(int i=2;i<=m;i++)
for(int j=1;j<=n;j++)
for(int k=1;k<=j;k++)dp[i][j]=(dp[i][j]+dp[i-1][k])%MOD;
for(int i=1;i<=n;i++)ans=(ans+dp[m][i])%MOD;
printf("%d\n",ans);
return 0;
}
/*

*/



## D. Minimax Problem

#### 题解

（血的教训，答案一定要xjb赋一个初值，我一直wa找了半天错发现是这个）

#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<queue>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long LL;
typedef pair<int,int> PII;
#define X first
#define Y second
{
int x=0,f=1;char c=getchar();
while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
while(isdigit(c)){x=x*10+c-'0';c=getchar();}
return x*f;
}
int n,m,a[300010][10],L,R,ans,ans1=1,ans2=1,bin[300010],has[300],pos[300];
bool judge(int index)
{
mem(bin,0);mem(has,0);mem(pos,0);
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
if(a[i][j]>=index)bin[i]=bin[i]<<1|1;
else bin[i]<<=1;
for(int i=1;i<=n;i++)has[bin[i]]=1,pos[bin[i]]=i;
for(int i=0;i<(1<<m);i++)
if(has[i])
for(int j=i;j<(1<<m);j++)
if(has[j] && (i|j)==(1<<m)-1)
{
if(ans<index)
{
ans=index;
ans1=pos[i];
ans2=pos[j];
}
return 1;
}
return 0;
}
int calc(int A,int B)
{
int res=2147483647;
for(int i=1;i<=m;i++)res=min(res,max(a[A][i],a[B][i]));
return res;
}
int main()
{
while(R-L>1)
{
int mid=L+R>>1;
if(judge(mid))L=mid;
else R=mid;
}
judge(L);judge(R);
printf("%d %d\n",ans1,ans2);
return 0;
}


## E. Messenger Simulator

#### 题解

#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<queue>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long LL;
typedef pair<int,int> PII;
#define X first
#define Y second
{
int x=0,f=1;char c=getchar();
while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
while(isdigit(c)){x=x*10+c-'0';c=getchar();}
return x*f;
}
const int maxn=300010;
int n,m,a,pos[maxn],L[maxn],R[maxn];
struct FenwichTree
{
int tag[maxn<<1];
int lowbit(int x){return x&(-x);}
void update(int x,int v){for(;x<=n+m;x+=lowbit(x))tag[x]+=v;}
int query(int x){int res=0;for(;x;x-=lowbit(x))res+=tag[x];return res;}
}T;

int main()
{
for(int i=1;i<=n;i++)pos[i]=i+m,L[i]=R[i]=i,T.update(i+m,1);
for(int i=1;i<=m;i++)
{
L[a]=1;
R[a]=max(R[a],T.query(pos[a]));
T.update(pos[a],-1);T.update(m-i+1,1);
pos[a]=m-i+1;
}
for(int i=1;i<=n;i++)R[i]=max(R[i],T.query(pos[i]));
for(int i=1;i<=n;i++)printf("%d %d\n",L[i],R[i]);
return 0;
}


### 废话

posted @ 2020-01-15 20:48  小飞淙的云端  阅读(110)  评论(0编辑  收藏