1 #include <stdio.h> 2 #include <math.h> 3 #include <string.h> 4 #include <stdlib.h> 5 #include <iostream> 6 #include <sstream> 7 #include <algorithm> 8 #include <string> 9 #include <queue> 10 #include <map> 11 #include <vector> 12 #include <iomanip> 13 using namespace std; 14 const int maxn = 1e3+50; 15 const int maxm = 1e4+10; 16 const int inf = 0x3f3f3f3f; 17 const double epx = 1e-10; 18 typedef long long ll; 19 const ll INF = 1e18; 20 const double pi = acos(-1.0); 21 int main() 22 { 23 int t,c; 24 double a,b; 25 cin>>t; 26 while(t--) 27 { 28 cin>>a>>b>>c; 29 cout<<setiosflags(ios::fixed)<<setprecision(c)<<(double)pow(a,exp(1))/b<<endl;//控制输出小数点后位数 30 } 31 }
I题 卡特兰数 出栈序列有多少种
1 #include <stdio.h> 2 #include <math.h> 3 #include <string.h> 4 #include <stdlib.h> 5 #include <iostream> 6 #include <sstream> 7 #include <algorithm> 8 #include <string> 9 #include <queue> 10 #include <map> 11 #include <vector> 12 #include <iomanip> 13 #define mem(a,b) memset(a,b,sizeof(a)) 14 using namespace std; 15 const int maxn = 5e5+50; 16 const int inf = 0x3f3f3f3f; 17 const double epx = 1e-10; 18 const double pi = acos(-1.0); 19 typedef long long ll; 20 const ll INF = 1e18; 21 const ll mod = 998244353; 22 ll n,f[maxn]; 23 void ff() 24 { 25 f[0]=1; 26 for(int i=1;i<=500000;i++) 27 f[i]=(i*f[i-1])%mod; 28 } 29 ll poww(ll n,ll m) 30 { 31 ll ans = 1; 32 while(m > 0) 33 { 34 if(m & 1)ans = (ans * n) % mod; 35 m = m >> 1; 36 n = (n * n) % mod; 37 } 38 return ans; 39 } 40 ll cc(ll n,ll m) 41 { 42 ll ans=f[n]; 43 ans=(ans*poww(f[m],mod-2))%mod; 44 ans=(ans*poww(f[n-m],mod-2))%mod; 45 return ans; 46 } 47 int main() 48 { 49 int t,kase=1; 50 cin>>t; 51 ff(); 52 //cout<<cc(6,3)<<endl; 53 while(t--) 54 { 55 cin>>n; 56 int m=n-1; 57 ll ans1=(cc(2*n,n)-cc(2*n,n+1))%mod; 58 ll ans2=(cc(2*m,m)-cc(2*m,m+1))%mod; 59 //cout<<ans1<<" "<<ans2<<endl; 60 printf("Case #%d: %lld\n",kase++,(ans1-ans2+2*mod)%mod); 61 } 62 }