提交时间:2023-08-09 18:05:22
运行 ID: 81669
#include<bits/stdc++.h> using namespace std; int t; unsigned long long n; string x(string str1, string str2){ int sum[114514],a[114514],b[114514]; memset(sum,0,sizeof(sum)); memset(a,0,sizeof(a)); memset(b,0,sizeof(b)); int len1=str1.size(),len2=str2.size(); for(int i=1;i<=len1;i++) a[i]=str1[len1-i]-48; for(int i=1;i<=len2;i++) b[i]=str2[len2-i]-48; int lenS=len1+len2-1; for(int i=1;i<=len1;i++){ for(int j=1;j<=len2;j++){ sum[i+j-1]+=a[i]*b[j]; sum[i+j]+=sum[i+j-1]/10; sum[i+j-1]%=10; } } while(sum[lenS+1]) lenS++; string ans; for(int i=lenS;i>=1;i--) ans+=sum[i]+'0'; return ans; } int main(){ cin>>t>>n; if(t==1) cout<<n*(n-1)/2; if(t==2) cout<<n*(n-1)/2*(n-2)/3*(n-3)/4; if(t==3){ string s="2"; for(int i=2;i<n;i++) s=x(s,"2"); cout<<s; } return 0; }