萌新求调
  • 板块学术版
  • 楼主Unordered_OIer
  • 当前回复2
  • 已保存回复2
  • 发布时间2021/1/29 16:48
  • 上次更新2023/11/5 04:12:17
查看原帖
萌新求调
291706
Unordered_OIer楼主2021/1/29 16:48

昨晚只花 5 分钟打 A 划水走了,今天准备补一下。

结果自闭。所以第二天打前一天的比赛 rp 会掉。

RT, CF 说

wrong answer expected YES, found NO [10021st token]

然鹅看不到 YES 的那组数据

求调 qwq,这人已经 fst 了好久了。

思路就是判断 dd 加起来能够到的末尾数字,和达到这个末尾数字的最小值,然后去判断每个数行不行,总复杂度是 O(Tq)\mathcal O(Tq)

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline ll read(){
	ll x=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-f;ch=getchar();}
	while(isdigit(ch)){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	return x*f;
}
inline void write(ll x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);
	putchar(x%10+'0');
}
inline void writeln(ll x){write(x),putchar('\n');}
const ll Q=10005;
ll T,q,d,a[Q],mn[15][15];
bool c[15][15];
inline void pre(){
	for(ll i=1;i<=9;i++)
		for(ll j=1;j<=10;j++)
			c[i][(i*j)%10]=1,mn[i][(i*j)%10]=i*j;
}
inline bool check(ll d,ll now){
	return (c[d][now%10]&&now>=mn[d][now%10])||now%d==0;
}
int main(){
	pre();
	T=read();
	while(T--){
		q=d=0;
		memset(a,0,sizeof a);
		q=read(),d=read();
		for(ll i=1;i<=q;i++)a[i]=read();
		for(ll i=1;i<=q;i++)
			if(check(d,a[i]))puts("YES");
			else puts("NO");
	}
	return 0;
}
2021/1/29 16:48
加载中...