#include<iostream> #include<cstring> #include<algorithm> #include<cstdio> #include<vector> #include<queue> #include<stack> #include<bitset> #include<set> usingnamespace std; //#define int long long typedeflonglong ll; #define MAXN 200006 #define MAXM 450 #define pb push_back #define pii pair<int,int> #define fi first #define se second #define mp make_pair #define inf 0x3f3f3f3f #define cmx( a , b ) a = max( a , b ) #define cmn( a , b ) a = min( a , b ) #define upd( a , b ) ( a = ( a + b ) % P ) //#define P 1000000007 int n; int a[MAXN]; voidread( signed& x ){ scanf("%d",&x); } voidread( ll& x ){ scanf("%lld",&x); } longdouble res = 0.0; intmain(){ read( n ); for( int i = 1 ; i <= n ; ++ i ) { read( a[i] ); if( i != 1 ) res += ( longdouble ) a[i] / ( a[i] + a[1] ); } res += 1.0; printf("%.8Lf",res); }
/* * Things you should pay attention to * inf is big enough? * out of bounds? * long long ? */
#include<iostream> #include<cstring> #include<algorithm> #include<cstdio> #include<vector> #include<queue> #include<stack> #include<bitset> #include<set> usingnamespace std; //#define int long long typedeflonglong ll; #define MAXN 200006 #define MAXM 450 #define pb push_back #define pii pair<int,int> #define fi first #define se second #define mp make_pair #define inf 0x3f3f3f3f #define cmx( a , b ) a = max( a , b ) #define cmn( a , b ) a = min( a , b ) #define upd( a , b ) ( a = ( a + b ) % P ) //#define P 1000000007
int n , m , k , blo; int A[MAXN] , S[MAXN] , smid[MAXN]; voidread( signed& x ){ scanf("%d",&x); } voidread( ll& x ){ scanf("%lld",&x); } int a[MAXN]; boolchk( int x ){ int cur = 0 , kel = 0; for( int i = 1 ; i <= n ; ++ i ) { if( a[i] > x ) returnfalse; if( cur + a[i] > x ) cur = a[i] , ++ kel; else cur += a[i]; } if( cur ) ++ kel; return kel <= k; } int P[MAXN]; intmain(){ cin >> n >> m >> k; blo = log2( n ); for( int i = 1 ; i <= n ; ++ i ) read( A[i] ) , a[i] = A[i]; int l = 0 , r = 1e9; while( l <= r ) { int mid = l + r >> 1; if( chk( mid ) ) r = mid - 1; else l = mid + 1; } int cures = l; for( int i = 1 ; i < m ; ++ i ) P[i] = i; random_shuffle( P + 1 , P + m ); for( int i = 1 ; i < m ; ++ i ) { int j = P[i]; for( int i = 1 ; i <= n ; ++ i ) a[i] = ( A[i] + j ) % m; if( ! chk( cures - 1 ) ) continue; int l = 0 , r = cures - 1; while( l <= r ) { int mid = l + r >> 1; if( chk( mid ) ) r = mid - 1; else l = mid + 1; } cures = l; } printf("%d\n",cures); }
/* * Things you should pay attention to * inf is big enough? * out of bounds? * long long ? */
#include<iostream> #include<cstring> #include<algorithm> #include<cstdio> #include<vector> #include<queue> #include<stack> #include<bitset> #include<set> usingnamespace std; #define int long long typedeflonglong ll; #define MAXN 200006 #define MAXM 450 #define pb push_back #define pii pair<int,int> #define fi first #define se second #define mp make_pair #define inf 0x3f3f3f3f #define cmx( a , b ) a = max( a , b ) #define cmn( a , b ) a = min( a , b ) #define upd( a , b ) ( a = ( a + b ) % P ) #define P 998244353 int n; voidread( signed& x ){ scanf("%d",&x); } voidread( ll& x ){ scanf("%lld",&x); }
intpower(int x, int a , int p){ int cur = x % P , ans = 1; while( a ) { if( a & 1 ) ans = mul( ans , cur , p ); cur = mul( cur , cur , p ) , a >>= 1; } return ans; }
boolprime(int x){ for(int i = 1; i <= 30; i++) { int p = 1ll * rand() * rand() % x * rand() % x + 1; while(p == x) p = 1ll * rand() * rand() % x * rand() % x + 1; if(power(p, x - 1 , x) != 1) returnfalse; } returntrue; }
int val[MAXN], tp , ans = 0; voiddfs(int now, int rev){ if(now == tp + 1) { int tmp = 1; for( int i = 1; i <= tp; i++ ) tmp *= (val[i] + 1), tmp %= P - 1; ans = (ans + rev * (power(2, tmp , P) - 1) ) % P; return; } dfs(now + 1, rev); if(val[now] >= 1) -- val[now] , dfs(now + 1, (P - 2) * rev % P), ++ val[now]; if(val[now] >= 2) val[now] -= 2, dfs(now + 1, rev), val[now] += 2; } signedmain(){ srand( 19260817 ); read( n ); for(int i = 2 ; i <= 1000000 && n > 1; i++) { // primes lower than 1e6 if( !( n % i ) ) ++ tp; while( !( n % i ) ) val[tp]++ , n /= i; } if(n > 1) { if( prime(n) ) val[++tp] = 1; // n == prime * ppp elseif( (int)sqrt(n) * (int)sqrt(n) == n ) val[++tp] = 2; // n == prime * prime * ppp else val[ ++tp ] = 1, val[ ++tp ] = 1; // elsewhise, val = 1 } dfs(1, 1); cout << ( ans + P ) % P ; }
/* * Things you should pay attention to * inf is big enough? * out of bounds? * long long ? */