[思路题] Codeforces 354C #206 (Div. 1) C. Vasya and Beautiful Arrays
来源:互联网 发布:58端口使用技巧 编辑:程序博客网 时间:2024/04/29 02:22
枚举gcd为
#include<cstdio>#include<cstdlib>#include<algorithm>using namespace std;inline char nc(){ static char buf[100000],*p1=buf,*p2=buf; return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;}inline void read(int &x){ char c=nc(),b=1; for (;!(c>='0' && c<='9');c=nc()) if (c=='-') b=-1; for (;c>='0' && c<='9';x=x*10+c-'0',c=nc()); x*=b;}const int N=1000005;int n,K;int a[N],c[N];int main(){ int m=0; freopen("t.in","r",stdin); freopen("t.out","w",stdout); read(n); read(K); for (int i=1;i<=n;i++) read(a[i]),m=max(m,a[i]),c[a[i]]++; for (int i=1;i<=m;i++) c[i]+=c[i-1]; for (int i=m;i>1;i--){ int sum=0; for (int j=i;j<=m;j+=i) sum+=c[min(m,min(j+i-1,j+K))]-c[j-1]; if (sum==n) return printf("%d\n",i),0; } printf("1\n"); return 0;}
0 0
- [思路题] Codeforces 354C #206 (Div. 1) C. Vasya and Beautiful Arrays
- Codeforces #206(Div.1) C. Vasya and Beautiful Arrays
- codeforces 354C C. Vasya and Beautiful Arrays( 数论+枚举)
- Codeforces 354C Vasya and Beautiful Arrays[dp+暴力]
- Codeforces 354C. Vasya and Beautiful Arrays【DP,暴力】
- C. Vasya and Beautiful Arrays----思维题
- Codeforces Round #206 (Div. 2) E. Vasya and Beautiful Arrays
- Codeforces Round #206 (Div. 2) E-Vasya and Beautiful Arrays
- Codeforces 354C. Vasya and Beautiful (★)
- codeforces #354 div.2 C &&676C Vasya and String
- Codeforces Round #354 (Div. 2)676C. Vasya and String
- Codeforces Round #354 (Div. 2) C .Vasya and String
- Codeforces Round #354 (Div. 2)-C. Vasya and String
- Codeforces Round #354 (Div. 2) C Vasya and String
- Codeforces Round #354 (Div. 2)C. Vasya and String
- Codeforces Round #206 (Div. 2) C - Vasya and Robot
- Codeforces Round #206 (Div. 2) C. Vasya and Robot
- Codeforces Round #206 (Div. 2) C-Vasya and Robot
- ios动画笔记(2)CATransform3D和CASpringAnimation 、CATransition和CAEmitterLayer、UIDynamicAnimator
- matlab corrcoef 函数&n…
- springMVC和tiles的整合
- matlab factoran 因子分析函数
- 剑指Offer面试题24二叉搜索树的后序遍历序列(递归),面试题25二叉树中和为某一值的路径(栈)
- [思路题] Codeforces 354C #206 (Div. 1) C. Vasya and Beautiful Arrays
- matlab regress函数 最…
- matlab classify 线性判别分析函数
- HttpClient4.4 登录知乎(详细过程)
- matlab exprnd函数 生成…
- matlab isa函数 判断输…
- matlab linprog函数 线…
- matlab fmincon 非线性…
- 【程序44】 题目:一个偶数总能表示为两个素数之和。