提交时间:2023-11-05 10:25:14
运行 ID: 108999
#include<bits/stdc++.h> using namespace std; long long n,a[55],b[55]; int work() { sort(a+1,a+1+n); for(int i=1;i<=n;i++){ a[i+1]=a[i+1]*a[i]+1; sort(a+1,a+n+1); } sort(b+1,b+n+1); for(int i=n;i>=1;i--){ b[i-1]=b[i-1]*b[i]+1; } cout<<a[n]-b[1]<<endl; } int main() { cin>>n; while(n!=0){ for(int i=1;i<=n;i++){ cin>>a[i]; b[i]=a[i]; } work(); cin>>n; } return 0; }