Educational Codeforces Round 100

\(noip\)之后颓废了一段时间了,现在月考考完了,还是决定干正事。

这场比赛是我赛后打的,没有\(Virtual\quad Contest\),直接脑补画面,比较恶心。

总之题还是题,做了就是做了,没做就是没做。

\(A. Dungeon\)

话说\(T1\)没看出结论整个人心态都是崩的。

结论是:合为\(9\)的倍数,且最小数能支撑到最后一刻。

代码如下,仅供参考:

#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
const int maxn=2e5+10;
const int mod=1e9+7;
inline int read(){
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+c-'0';c=getchar();}
	return x*f;
}
int T,a,b,c,sum,mn;
int main(){
	T=read();
	while(T--){
		a=read(),b=read(),c=read();
		sum=a+b+c,mn=min(min(a,b),c);
		if(sum%9||sum<9||mn*9<sum)puts("NO");
		else puts("YES");
	}
	return 0;
}

\(B. Find The Array\)

感觉好久不搞\(oi\)人都颓了,脑子都笨了。

巧妙地利用\(2\)的幂次可以将\(|a_i-b_i|\)控制在\(\frac12a_i\)以内。

代码如下,仅供参考:

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define inf 1e9
const int maxn=2e5+10;
const int mod=1e9+7;
int T,n,a[maxn],pre[maxn];
inline int read(){
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+c-'0';c=getchar();}
	return x*f;
}
signed main(){
	T=read();pre[0]=1;
	for(int i=1;i<=40;i++)
		pre[i]=pre[i-1]<<1;
	while(T--){
		n=read();
		for(int i=1;i<=n;i++)
			a[i]=read();
		for(int i=1;i<=n;i++)
			printf("%lld ",pre[lower_bound(pre+1,pre+41,a[i])-pre-1]);
		puts("");
	}
	return 0;
}
posted @ 2020-12-18 20:42  syzf2222  阅读(89)  评论(0编辑  收藏  举报