只写了AB,甚至还WA了一次A题,暴露了蒟蒻的本质=。=

感觉考的时候有好多正确或和正解有关的思路,但是就想不出具体的解法或者想的不够深(长)(怕不是过于鶸)

话说CF的E题怎么都这么清奇=。=

A.Little C Loves 3 I

随便拆一下就好了,大概全场就我一个心太急写挂了一次TAT

 #include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main ()
{
long long n; scanf("%lld",&n);
if(n%==) printf("%lld 1 2",n-);
else printf("%lld 1 1",n-);
return ;
}

B.Cover Points

初中数学知识(?)或者随手推一推,水水(我**就会这俩水题)

 #include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main ()
{
long long n,m,p,ans=;
scanf("%lld",&n);
for(int i=;i<=n;i++)
scanf("%lld%lld",&m,&p),ans=max(m+p,ans);
printf("%lld",ans);
return ;
}

C.Enlarge GCD

题目并不难......

然而被这题确实没做出来,调的时候也调了半天,我好菜啊=。=

首先我们求一个全序列的gcd,然后从每个数中除掉它,剩下的数肯定是互质的,也就是说现在我们要从这些剩下的数中删掉最少的数使得他们不互质。我们将每个数分解质因数,统计出现次数最多的质因数(出现在一个数里算是一次),保留下它肯定就是最优的,于是用总数减去出现次数更新答案即可

 #include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=,M=;
int mpr[M],pri[M],cnt[M],num[N];
int n,g,maxx,ans=2e9;
int gcd(int a,int b)
{
return b?gcd(b,a%b):a;
}
inline int maxi(int a,int b)
{
return a>b?a:b;
}
inline int mini(int a,int b)
{
return a<b?a:b;
}
int main ()
{
scanf("%d",&n);
for(register int i=;i<=n;i++)
{
scanf("%d",&num[i]);
g=gcd(g,num[i]),maxx=maxi(maxx,num[i]);
}
mpr[]=;
for(register int i=,sz=;i<=maxx+;i++)
{
if(!mpr[i]) pri[++sz]=mpr[i]=i;
for(register int j=;j<=sz&&i*pri[j]<=maxx+;j++)
{
mpr[i*pri[j]]=i;
if(!(i%pri[j])) break;
}
}
for(register int i=;i<=n;i++)
{
int t=num[i]/g;
for(register int j=;pri[j]*pri[j]<=t;j++)
if(!(t%pri[j]))
{
ans=mini(ans,n-(++cnt[pri[j]]));
while(!(t%pri[j])) t/=pri[j];
}
if(t>) ans=mini(ans,n-(++cnt[t]));
}
if(ans>=n) ans=-;
printf("%d",ans);
return ;
}

D.Little C Loves 3 II

这题毒瘤啊,各种分类海星

比赛的时候怎么就没玩玩小数据呢,明明能A的TAT

首先的首先,要考虑$n*m$的奇偶性,不解释

然后我们可以发现,有些$n*m$是可以填满且无法被其他的$n*m$表示出来的,它们分别是

$1*6$,$2*4$,$2*5$

所以说我们可以考虑用这些块填满棋盘,最后小块单独处理

那么没什么可说的,我们开始讨论吧=。=

1.$n,m$都为偶数

这种情况只有$(2,2)$填不满,别的都可以填满

2.$n,m$都为奇数

有一种特殊情况是有一边的长度为$1$,这种情况要以$1*6$这种填满的填法特殊考虑(代码中的$line$数组就是干这个用的),易证其余情况都是正好剩一个

3.$n,m$一偶一奇

同理于上,根据那三种填满情况特殊考虑,发现我们不能用$4,5,6$凑出来的数只有$1,2,3,7$,$1,2$的情况我们讨论过了,$3,7$特殊讨论一下,然后剩下的肯定都能填满

然后终于做完辣=。=

 #include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
long long line[]={,,,,,};
long long n,m;
int main ()
{
scanf("%lld%lld",&n,&m);
if(n>m) swap(n,m);
if(n==) printf("%lld",m-line[m%]);
else if(!(n&)&&!(m&)) (n==&&m==)?printf(""):printf("%lld",n*m);
else if((n&)&&(m&)) printf("%lld",n*m-);
else
{
if(n&) swap(n,m);
if(n==&&m==) printf("");
else if(n==&&m==) printf("");
else printf("%lld",n*m);
}
return ;
}

E.Region Separation

至今没看懂题意,咕咕咕

2018.9.21 Codeforces Round #511(Div.2)的更多相关文章

  1. Codeforces Round #511 (Div. 2)

    Codeforces Round #511 (Div. 2) #include <bits/stdc++.h> using namespace std; int n; int main() ...

  2. Codeforces Round #511 (Div. 2):C. Enlarge GCD(数学)

    C. Enlarge GCD 题目链接:https://codeforces.com/contest/1047/problem/C 题意: 给出n个数,然后你可以移除一些数.现在要求你移除最少的数,让 ...

  3. Codeforces Round #511 (Div. 2)-C - Enlarge GCD (素数筛)

    传送门:http://codeforces.com/contest/1047/problem/C 题意: 给定n个数,问最少要去掉几个数,使得剩下的数gcd 大于原来n个数的gcd值. 思路: 自己一 ...

  4. Codeforces Round #511 (Div. 1) C. Region Separation(dp + 数论)

    题意 一棵 \(n\) 个点的树,每个点有权值 \(a_i\) .你想砍树. 你可以砍任意次,每次你选择一些边断开,需要满足砍完后每个连通块的权值和是相等的.求有多少种砍树方案. \(n \le 10 ...

  5. Codeforces Round #511 Div.1 A Div.2 C

    嗯切一题走人很开心. gzy-50分比我还惨. 题意:有n个数,去掉尽量少的数使得剩下数的gcd变大. 首先把这n个数都除以gcd,就变成了去掉尽量少的数使得gcd不等于1. 可以枚举一个质数,然后统 ...

  6. C. Enlarge GCD Codeforces Round #511 (Div. 2)【数学】

    题目: Mr. F has nn positive integers, a1,a2,…,an. He thinks the greatest common divisor of these integ ...

  7. B. Cover Points Codeforces Round #511 (Div. 2)【数学】

    题目: There are nn points on the plane, (x1,y1),(x2,y2),…,(xn,yn)(x1,y1),(x2,y2),…,(xn,yn). You need t ...

  8. A. Little C Loves 3 I Codeforces Round #511 (Div. 2) 【数学】

    题目: Little C loves number «3» very much. He loves all things about it. Now he has a positive integer ...

  9. Codeforces Round #511 (Div. 2) C. Enlarge GCD

    题目链接 题目就是找每个数的最小素因子,然后递归除,本来没啥问题,结果今天又学习了个新坑点. 我交了题后,疯狂CE,我以为爆内存,结果是,我对全局数组赋值, 如果直接赋值,会直接在exe内产生内存,否 ...

随机推荐

  1. Python-RabbitMQ(持久化)

    生产者: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 import pika   connection = pika.BlockingConnection(pi ...

  2. Gitlab CI-1.Gitlab部署

    参考文档: GitLab Documentation:https://docs.gitlab.com/ce/ Installation and Configuration using omnibus ...

  3. 06-matplotlib-饼状图

    import numpy as np import matplotlib.pyplot as plt ''' 饼状图显示一个数据系列中各项总和的比例: 饼状图中的数据点显示为整个饼状图的百分比: 如: ...

  4. Django中的Project和App的区别

    Django是一个非常流行的用python编写的Web框架,在使用Django之前,我们需要了解一些基本的概念,这样可以在使用Django的时候对其有一个更加深入的把握.本文主要介绍Django中两个 ...

  5. 基于Linux-3.9.4内核增加简单的时间片轮转功能

    简单的时间片轮转多道程序内核代码 原创作品转载请注明出处https://github.com/mengning/linuxkernel/ 作者:sa18225465 一.安装 Linux-3.9.4 ...

  6. java工程文件路径的问题

    String classpath = this.getClass().getResource("/").getPath().replaceFirst("/WEB-INF/ ...

  7. mybatis批量插入oracle

    <insert id="batchInsert" parameterType="java.util.List"> INSERT INTO TEST( ...

  8. 将eclipse上的web项目部署到Tomcat服务器上经验总结

    1.  将Tomcat插件添加到eclipse上 Window --> Preferences --> Server --> Runtime Environment --> A ...

  9. MathExam6317

    自己取一个大气又可爱的标题 小学二年级的还没来得及写,大部分时间还是花在巩固和查阅新旧知识上了,通过看学习视频,查资料,看博客园的博客...下次完善好了交上. 一.预估与实际 PSP2.1 Perso ...

  10. 20172325 2016-2017-2 《Java程序设计》第四周学习总结

    20172325 2016-2017-2 <Java程序设计>第四周学习总结 教材学习内容总结 1.对类.对象.声明变量的定义和属性有了进一步的了解 2.学会如何编写一个类并运用到需要的程 ...