提交时间:2023-11-06 13:41:23

运行 ID: 109141

#include<bits/stdc++.h> using namespace std; int n; int a[50001]; int main() { int l=1; do { cin>>n; if(n==0) break; for(int i=1;i<=n;i++) cin>>a[i]; int nn=n; while(n-l!=0) { sort(a+l,a+1+n); a[++n]=a[l]*a[l+1]+1; l+=2; } int b=a[n]; l=1;n=nn; while(n-l!=0) { sort(a+1+l,a+1+n); a[++n]=a[n-1]*a[n-2]+1; l+=2; } int c=a[n]; cout<<c-b<<endl; }while(n!=0); return 0; }