Educational Codeforces Round 83 (Rated for Div. 2)

Educational Codeforces Round 83 (Rated for Div. 2)

http://codeforces.com/contest/1312/my

A - Two Regular Polygons

思路:m是n的因子即可

#include
using namespace std;
int t,n,m;
int main()
{
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d%d",&n,&m);
		if(n % m == 0)
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}

B - Bogosort

思路:将数组从大到小排序即可

#include
using namespace std;
int a[105];
int t,n;
int main()
{
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d",&n);
		for(int i = 1;i <= n;++i)
			scanf("%d",&a[i]);
		sort(a+1,a+n+1);
		for(int i = n;i >= 1;--i)
			printf("%d ",a[i]);
		printf("\n");
	}
	return 0;
}

C - Adding Powers

思路:将每个数字表示成k进制数,然后每一位最多只能出现一次

#include
#define ll long long
using namespace std;
ll tmp,b[62];
int n,k,t;
int main()
{
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d%d",&n,&k);
		memset(b,0,sizeof(b));
		bool flag = true;
		for(int i = 1;i <= n;++i)
		{
			scanf("%lld",&tmp);
			for(int j = 0;j < 60;++j)
			{
				b[j] += tmp%k;
				tmp /= k;
				if(b[j] > 1)
					flag = false;
			}
		}
		if(flag)
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}

D - Count the Arrays

见https://blog.csdn.net/xing_mo/article/details/104853847

E - Array Shrinking

见:https://blog.csdn.net/xing_mo/article/details/104853865

你可能感兴趣的:(CF)