Topic background
Title Description
Input Format
Output Format
Sample input and output
data range
Resolve
We set two parameters are cheating \ ((a_1, b_1) \ ) and \ ((A_2, B_2) \) , then the set
\ [S1 = \ frac {a_1 } {b_1}, S2 = \ frac { a_2} {b_2} \]
If we select both cheating, it was obtained Maxtire time
\ [S = \ frac {a_1
+ a_2} {b_1 + b_2} \] may assume \ (S1 <S2 \ ) , then
\ [S1-S2 = \ frac
{a_2b_1-a_1b_2} {b_1b_2}> 0 \ Rightarrow a_2b_1-a_1b_2> 0 \] so
\ [S-S1 = \ frac {a_2b_1-a_1b_2} {(b_1 + b_2) b_1}> 0 \ Rightarrow S>
S1 \] Similarly available, \ (S <S2 \) .
By analogy, no matter how we choose to always find a form such as \ (\ frac {a_i} { b_i} \) is the minimum score of the individual. This score is the all \ (a_i / b_i \) minimum sorted. Since there may be more than the minimum value, and a plurality of the same values together still the same, it is provided with a minimum value of \ (m \) th, the last program number is
\ [C_m ^ 1 + C_m ^ 2 +. .. + C_m ^ m = 2 ^ m-1 \]
Code
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <algorithm>
#include <cmath>
#define N 1000002
using namespace std;
const int mod=998442553;
const double eps=1e-10;
int t,n,i,cnt;
double a[N],b[N],c[N];
int poww(int a,int b)
{
long long ans=1,base=a;
while(b){
if(b&1) ans=ans*base%mod;
base=base*base%mod;
b>>=1;
}
return ans%mod;
}
int main()
{
freopen("mine.in","r",stdin);
freopen("mine.out","w",stdout);
cin>>t;
while(t--){
cin>>n;
for(i=1;i<=n;i++) cin>>a[i];
for(i=1;i<=n;i++) cin>>b[i];
for(i=1;i<=n;i++) c[i]=b[i]/a[i];
sort(c+1,c+n+1);
if(c[1]<=1.0*10000){
cnt=1,i=2;
while(i<=n&&fabs(c[i]-c[1])<=eps) cnt++,i++;
cout<<setprecision(8)<<fixed<<c[1]<<' '<<(poww(2,cnt)-1)%mod<<endl;
}
else cout<<"Impossible"<<endl;
}
fclose(stdin);
fclose(stdout);
return 0;
}