题解 - 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)} Educational Codeforces Round84 (AE) 题解

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

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

S o l \mathrm{Sol} Sol
  • 一眼题,首先判断 m 2 ≤ n m^2\leq n m2n(前 m m m个奇数相加为 m 2 m^2 m2),再判奇偶性就好了。一开始 w a wa wa了一发就是忘记判断 m 2 ≤ n m^2\leq n m2n
C o d e \mathrm{Code} 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} B Princesses and Princes

S o l \mathrm{Sol} Sol
  • 差点死在这道题目上,题目是真的自闭(差点以为是二分图。。。
  • 然后就是简单的模拟,非常小清新:先找到每个公主匹配的王子,如果全部匹配,那么就是最优的。否则找出一个未匹配的公主和未匹配的王子,将这个王子加入公主的名单即可。
C o d e \mathrm{Code} 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} C Game with Chips

S o l \mathrm{Sol} Sol
  • 这道题目还是很容易的,因为不用你写最优解。
  • 因为把整个图做一遍也只要 n × m − 1 n\times m-1 n×m1即可,所以我们可以将所有物品移到某一个角落,然后遍历全图。
C o d e \mathrm{Code} 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} D Infinite Path

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

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

S o l \mathrm{Sol} Sol
  • 一道愚蠢的数数题。
  • 假设知道有一个长度为 l l l 的串,分 3 3 3种情况即可
    • l = n l=n l=n,那么输出 10 10 10(众所周知
    • l 1 = 1 , l n = n l_1=1,l_n=n l1=1,ln=n,那么对于这个连续的串的贡献为 10 10 10因为可以取 ( 0 − 10 ) (0-10) (010)。那么对于与这段区间连接的那个位置只能填 9 9 9个数,那么总贡献为 10 × 9 × 2 × 1 0 l − i − 1 10\times 9 \times 2\times 10^{l-i-1} 10×9×2×10li1其中的 2 2 2因为既要算头也要算尾, 1 0 l − i − 1 10^{l-i-1} 10li1因为剩下 l − i − 1 l-i-1 li1个数可以随便填。
    • l 1 ∈ [ 2 , n − i − 2 ] l_1∈{[2,n-i-2]} l1[2,ni2],即既不碰到开头也不碰结尾。与上面同理我们可以得到的贡献为 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} 10×9×9×(ni1)×10ni2
C o d e \mathrm{Code} 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;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值