A - Pair of Numbers 数论
const int maxn = 310000; int num[maxn]; int ans[maxn]; int main() { //freopen("in.txt","r",stdin); int n; while(cin>>n) { repf(i,1,n) scanf("%d",&num[i]); int Max = 0; int cnt = 0; for(int i = 1;i<=n;) { int L = i; int R = i; while(L>=1 && num[L]%num[i] == 0) L--; while(R<=n && num[R]%num[i] == 0) R++; i = R; R--;L++; if(R - L > Max) { Max = R - L; cnt = 0; ans[cnt] = L; cnt++; } if(R - L == Max) { ans[cnt] = L; cnt++; } } int sz = unique(ans,ans+cnt) - ans; printf("%d %d\n",sz,Max); printf("%d",ans[0]); rep(i,1,sz) printf(" %d",ans[i]); cout<<endl; } return 0; }
posted on 2013-11-25 15:08 keep trying 阅读(274) 评论(0) 编辑 收藏 举报