提交时间:2023-11-05 12:47:39
运行 ID: 109014
#include<bits/stdc++.h> using namespace std; int main(){ int n; int a[50005]; int b[50005]; scanf("%d",&n); while(n!=0){ //if(n == 0){ // break; //} for(int i = 1;i <= n;i++){ scanf("%d",&a[i]); b[i] = a[i]; } sort(a+1,a+n+1); sort(b+1,b+n+1); for(int i = n;i >= 2;i--){ a[i-1] = a[i] * a[i-1] + 1; } for(int i = 1;i <= n-1;i++){ b[i+1] = b[i] * b[i+1] + 1; } printf("%d",b[n]-a[1]); scanf("%d",&n); } return 0; }