题解 - Educational Codeforces Round 84 (Rated for Div. 2)

E d u c a t i o n a l   C o d e f o r c e s   R o u n d 84   ( A E ) \mathrm{ Educational \ Codeforces \ Round 84 \ (A-E)} 题解

  • 罚时真是个鬼畜的玩意。。

A   S u m   o f   O d d   I n t e g e r s \mathrm{A\ Sum \ of \ Odd\ Integers}

S o l \mathrm{Sol}

  • 一眼题,首先判断 m 2 n m^2\leq n (前 m m 个奇数相加为 m 2 m^2 ),再判奇偶性就好了。一开始 w a wa 了一发就是忘记判断 m 2 n m^2\leq n

C o d e \mathrm{Code}

#include <bits/stdc++.h>
#define int long long 
#define pb push_back
using namespace std;

inline int read()
{
	int sum=0,ff=1; char ch=getchar();
	while(!isdigit(ch))
	{
		if(ch=='-') ff=-1;
		ch=getchar();
	}
	while(isdigit(ch))
		sum=sum*10+(ch^48),ch=getchar();
	return sum*ff;
}

int Q,n,m;

signed main()
{
	Q=read();
	for (;Q--;)
	{
		n=read();
		m=read();
		if(m*m>n) printf("NO\n");
		else 
		{
			if(n&1)
				(m&1)?printf("YES\n"):printf("NO\n");
			else 
				(m&1)?printf("NO\n"):printf("YES\n");
		}
	}
	return 0;
}
		

B   P r i n c e s s e s   a n d   P r i n c e s \mathrm{B\ Princesses \ and \ Princes}

S o l \mathrm{Sol}

  • 差点死在这道题目上,题目是真的自闭(差点以为是二分图。。。
  • 然后就是简单的模拟,非常小清新:先找到每个公主匹配的王子,如果全部匹配,那么就是最优的。否则找出一个未匹配的公主和未匹配的王子,将这个王子加入公主的名单即可。

C o d e \mathrm{Code}

#include <bits/stdc++.h>
#define pb push_back
using namespace std;

inline int read()
{
	int sum=0,ff=1; char ch=getchar();
	while(!isdigit(ch))
	{
		if(ch=='-') ff=-1;
		ch=getchar();
	}
	while(isdigit(ch))
		sum=sum*10+(ch^48),ch=getchar();
	return sum*ff;
}

const int N=1e5+5;

int Q,vis[N],a[N];

int main()
{
	Q=read();
	for (;Q--;)
	{
		int n=read();
		int who=0;
		for ( int i=1;i<=n;i++ ) vis[i]=0;
		for ( int i=1;i<=n;i++ ) 
		{
			int x=read();
			for ( int j=1;j<=x;j++ ) a[j]=read();
			int zz=0;
			for ( int j=1;j<=x;j++ ) 
				if(!vis[a[j]]) 
				{
					vis[a[j]]=1;
					zz=1;
					break;
				}
			if(zz) continue;
			who=i;
		}
		if(who)
		{
			printf("IMPROVE\n");
			for ( int j=1;j<=n;j++ ) 
				if(vis[j]==0)
				{
					printf("%d %d\n",who,j);
					break;
				}
		}
		else printf("OPTIMAL\n");
	}
	return 0;
}
		

C   G a m e   w i t h   C h i p s \mathrm{C\ Game \ with \ Chips}

S o l \mathrm{Sol}

  • 这道题目还是很容易的,因为不用你写最优解。
  • 因为把整个图做一遍也只要 n × m 1 n\times m-1 即可,所以我们可以将所有物品移到某一个角落,然后遍历全图。

C o d e \mathrm{Code}

#include <bits/stdc++.h>
#define pb push_back
using namespace std;

inline int read()
{
	int sum=0,ff=1; char ch=getchar();
	while(!isdigit(ch))
	{
		if(ch=='-') ff=-1;
		ch=getchar();
	}
	while(isdigit(ch))
		sum=sum*10+(ch^48),ch=getchar();
	return sum*ff;
}
int n,m,k,a[220][220];

int main()
{
	n=read(),m=read(),k=read();
	for(int i=1;i<=k;++i ) read(),read();
	for( int i=1;i<=k;++i )
	{ 
		int x=read(),y=read();
		a[x][y]=1;
	}
	printf("%d\n",n+m+n*m-1);
	for( int i=1;i<=n;++i ) putchar('U');
	for( int i=1;i<=m;++i ) putchar('L');
	for( int i=1;i<=n;++i )
	{
		if(i&1) 
			for( int j=1;j<m;++j )
				putchar('R');
		else
			for( int j=1;j<m;++j )
				putchar('L');
		if(i<n) putchar('D');
	}
	return 0;
}

D   I n f i n i t e   P a t h \mathrm{D\ Infinite \ Path}

S o l \mathrm{Sol}

  • 首先我没做出这道题目,然后就是不美妙的事情。。。
  • 先挖个坑,以后再补。引用: l g lg 题解

E   C o u n t   T h e   B l o c k s \mathrm{E\ Count \ The\ Blocks}

S o l \mathrm{Sol}

  • 一道愚蠢的数数题。
  • 假设知道有一个长度为 l l 的串,分 3 3 种情况即可
    • l = n l=n ,那么输出 10 10 (众所周知
    • l 1 = 1 , l n = n l_1=1,l_n=n ,那么对于这个连续的串的贡献为 10 10 因为可以取 ( 0 10 ) (0-10) 。那么对于与这段区间连接的那个位置只能填 9 9 个数,那么总贡献为 10 × 9 × 2 × 1 0 l i 1 10\times 9 \times 2\times 10^{l-i-1} 其中的 2 2 因为既要算头也要算尾, 1 0 l i 1 10^{l-i-1} 因为剩下 l i 1 l-i-1 个数可以随便填。
    • l 1 [ 2 , n i 2 ] l_1∈{[2,n-i-2]} ,即既不碰到开头也不碰结尾。与上面同理我们可以得到的贡献为 10 × 9 × 9 × ( n i 1 ) × 1 0 n i 2 10\times 9\times 9 \times (n-i-1) \times 10^{n-i-2}

C o d e \mathrm{Code}

#include <bits/stdc++.h>
#define pb push_back
#define int long long 
using namespace std;

inline int read()
{
	int sum=0,ff=1; char ch=getchar();
	while(!isdigit(ch))
	{
		if(ch=='-') ff=-1;
		ch=getchar();
	}
	while(isdigit(ch))
		sum=sum*10+(ch^48),ch=getchar();
	return sum*ff;
}

const int N=5e5+5;
const int mod=998244353;

int n,jc[N],ans;

signed main()
{
	n=read(); if(n==1) return printf("10\n"),0;
	jc[0]=1; for ( int i=1;i<=n;i++ ) jc[i]=jc[i-1]*10%mod;
	for ( int i=1;i<n-1;i++ ) printf("%lld ",(jc[n-i-1]%mod*10*9*2%mod+jc[n-i-2]%mod*10*81%mod*(n-i-1)%mod+mod)%mod);
	printf("180 10\n");
	return 0;
}

猜你喜欢

转载自blog.csdn.net/wangyiyang2/article/details/105070311