Educational Codeforces Round 83 (Rated for Div. 2)A--C
地址:http://codeforces.com/contest/1312
题意:给出一个边数为n的等边多边形,问是否可以变成m的等边多边形。条件是同一个中心,共用原顶点。
解析:直接n%m==0即可,这样就是平分了。签到题没得说了。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
using namespace std;
typedef long long ll;
const int maxn=1e4;
int pr[maxn];
int find(int x)
{
if(x!=pr[x])
return pr[x]=find(pr[x]);
return x;
}
void join(int x1,int x2)
{
int f1=find(x1),f2=find(x2);
if(f1!=f2)
{
pr[f1]=f2;
}
return ;
}
int main()
{
int t;
cin>>t;
while(t--)
{
int n,m;
cin>>n>>m;
if(n%m==)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
}
题意:把给定数组任意排列,保证i<j时,j-a[j]!=i-a[i]。输出任意一组答案。
解析:sort一下从大到小排列即可。看数据的话,暴力也是可以的。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<map>
using namespace std;
typedef long long ll;
int a[];
int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
for(int i=;i<=n;i++)
cin>>a[i];
while()
{
int ok=;
for(int i=;i<=n;i++)
{
for(int j=i+;j<=n;j++)
{
if((j-a[j])==(i-a[i]))
{
ok=;break;
}
}
if(ok)
break;
}
if(!ok)
break;
for(int i=;i<=n;i++)
{
for(int j=i+;j<=n;j++)
{
if((j-a[j])==(i-a[i]))
{
swap(a[i],a[j]);
}
}
}
}
for(int i=;i<n;i++)
cout<<a[i]<<" ";
cout<<a[n]<<endl;
} }
题意:给你一个个数为n的数组a[],判断是否可以由相同大小的全0数组v[]变换而来。
变换规则:
1.在第i次操作时,你可以给数组v任意位置的值加上k^i
2.在第i次什么也不做。
解析:这其实就是一个进制的题。对于任意一个a【i】假设k进制对其有n位:a[i]= x0* k^0 +x1* k^1 +x2* k^2 +……+x(n-1)* k^n-1
而这个题对于k^i的i,是不断递增的,即每个i只能出现一次。所以我们只要知道每个k^i的系数,大于1,就是NO了。
举个例子:二进制,k=2
5 6
5的二进制表示为101,2为110,101
110 可以看出,2^2那里出现了两次,肯定不服题意了。
这里用vis[]来记录各个k^i的出现次数,记住vis是与实际转化的k进制数方向是相反的。vis[]+=a[i]%k,这个a[i]%k,就是系数,即次数。最后注意一下vis[]开的大些
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<map>
using namespace std;
typedef long long ll;
const int maxn=;
const int maxn2=;
ll a[maxn];
int vis[maxn2];
int t;
int main()
{
scanf("%d",&t);
while(t--)
{
int n,k;
scanf("%d%d",&n,&k);
for(int i=;i<n;i++)
scanf("%lld",&a[i]);
memset(vis,,sizeof(vis));
int ok=;
for(int i=;i<n;i++)
{
int tot=;
while(a[i])
{
tot++;
vis[tot]+=a[i]%k;
a[i]=a[i]/k;
if(vis[tot]>)
{
ok=;break;
}
}
if(ok)
break;
}
if(!ok)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
}
Educational Codeforces Round 83 (Rated for Div. 2)A--C的更多相关文章
- Educational Codeforces Round 83 (Rated for Div. 2)
A. Two Regular Polygons 题意:给你一个 正n边形,问你能否以这个 n 的其中一些顶点组成一个 m边形, 思路 :如果 n % m == 0 ,就可 收获:边均分 B. Bogo ...
- Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship
Problem Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship Time Limit: 2000 mSec P ...
- Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems(动态规划+矩阵快速幂)
Problem Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems Time Limit: 3000 mSec P ...
- Educational Codeforces Round 43 (Rated for Div. 2)
Educational Codeforces Round 43 (Rated for Div. 2) https://codeforces.com/contest/976 A #include< ...
- Educational Codeforces Round 35 (Rated for Div. 2)
Educational Codeforces Round 35 (Rated for Div. 2) https://codeforces.com/contest/911 A 模拟 #include& ...
- Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings
Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings 题目连接: http://cod ...
- Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes
Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes 题目连接: http://code ...
- Educational Codeforces Round 63 (Rated for Div. 2) 题解
Educational Codeforces Round 63 (Rated for Div. 2)题解 题目链接 A. Reverse a Substring 给出一个字符串,现在可以对这个字符串进 ...
- Educational Codeforces Round 39 (Rated for Div. 2) G
Educational Codeforces Round 39 (Rated for Div. 2) G 题意: 给一个序列\(a_i(1 <= a_i <= 10^{9}),2 < ...
随机推荐
- Mysql-win免安装卸载服务后重新安装不能启动的问题
一.先看配置文件有没有问题,以下是一个简单的配置 [mysql] default-character-set=utf8 [mysqld] character-set-server=utf8 port ...
- OA-APP增加空间
第一步:虚拟机增加一块200G的硬盘,使用fdisk -l 命令可以看到增加的硬盘(centos6可能需要重启系统) 第二步:然后对 /dev/sdc进行分区 第三步:创建一个分区 第四步:重新查看磁 ...
- 12款优秀的 JavaScript 日历和时间选择控件
这些插件能够帮助 Web 开发人员更快速的实现各种精美的日历和时间选择效果. 1. The Coolest Calendar 界面非常漂亮的一款日期选择插件,有详细的使用文档,最新版本 1.5. 点 ...
- Spring MVC及与structs MVC对比
一.Spring MVC MVC: Model + View + Controller(数据模型+视图+控制器) 三层架构: Presentation tier + Application tier ...
- 使用Hangfire MVC 做排程
Greg Yang Developer Taipei, Taiwan 108 POSTS 35 TAGS 所使用的是 Hangfire 強大排程器有 UI介面可以使用. 首先安裝PM> Inst ...
- Sublime Text 2+Zen Coding
自己长期使用editplus做代码编辑,使用过DW,还是习惯前者的使用环境.好友推荐,试试新的编码工具——Sublime Text 2.在代码制作过程中,最主要的是1)快速复制的模式化工作 2)零碎 ...
- PO设计模式-实现移动端自动化测试
开发环境:python 3.6.5 + selenium 2.48.0 + pytest框架 + Android 5.1 工具:pycharm + Appium + Genymotion 测试机型:S ...
- <JZOJ4726>种花
挺有意思的贪心 神奇的贪心 #include<cstdio> #include<iostream> #include<cstring> #include<al ...
- java 项目乱码解决(web.xml全局配置编码格式)
<!-- 乱码解决 --> <filter> <filter-name>encodingFilter</filter-name> //过滤器名称 < ...
- Python拾遗(2)
包括Python中的常用数据类型. int 在64位平台上,int类型是64位整数: 从堆上按需申请名为PyIntBlcok的缓存区域存储整数对象 使用固定数组缓存[-5, 257]之间的小数字,只需 ...