From b158ca18fc9b3b7c1056fb070348aa934ea68c71 Mon Sep 17 00:00:00 2001 From: Zengtudor Date: Sun, 9 Feb 2025 13:06:24 +0800 Subject: [PATCH] update --- .vscode/settings.json | 4 +++ src/2/P2719.cpp | 29 +++++++++++++++++ src/2/P3390.cpp | 72 +++++++++++++++++++++++++++++++++++++++++++ src/2/P3390.py | 7 +++++ 4 files changed, 112 insertions(+) create mode 100644 .vscode/settings.json create mode 100644 src/2/P2719.cpp create mode 100644 src/2/P3390.cpp create mode 100644 src/2/P3390.py diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..387f371 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "python.analysis.autoImportCompletions": true, + "python.analysis.typeCheckingMode": "strict" +} \ No newline at end of file diff --git a/src/2/P2719.cpp b/src/2/P2719.cpp new file mode 100644 index 0000000..7fac596 --- /dev/null +++ b/src/2/P2719.cpp @@ -0,0 +1,29 @@ +#include +#include +#include +#include +#include +#include +#include + +using ll = int64_t; +const ll maxn = 1250; +double dp[maxn+5][maxn+5]; + +int main(){ + std::iostream::sync_with_stdio(false),std::cin.tie(nullptr),std::cout.tie(nullptr); + + const ll n = []()->ll{ll n;std::cin>>n;return n/2;}(); + for(ll i=2;i<=n;i++){ + dp[i][0]=dp[0][i]=1.0; + } + for(ll i=1;i<=n;i++){ + for(ll j=1;j<=n;j++){ + dp[i][j]=(dp[i-1][j]+dp[i][j-1])/2; + } + } + + std::cout< +#include +#include +#include + + +using ll = int64_t; + +const ll p = 1e9+7; +template +T input(){ + T t; + std::cin>>t; + return t; +} +ll n=input(),k=input(); +void fnn(std::function func,std::function f = [](){}){ + for(ll i=1;i<=n;i++){ + for(ll j=1;j<=n;j++){ + func(i,j); + } + f(); + } +} +struct Mat{ + std::vector> vec; + Mat():vec(n+1,std::vector(n+1,0)){ + + } + Mat&setid(){ + for(ll i=1;i<=n;i++){ + vec[i][i]=1; + } + return *this; + } + Mat operator*(Mat&that){ + Mat res; + for(ll i=1;i<=n;i++){ + for(ll j=1;j<=n;j++){ + for(ll k=1;k<=n;k++){ + res.vec[i][j] = (res.vec[i][j] + vec[i][k]*that.vec[k][j]%p)%p; + } + } + } + return res; + } +}; + + +Mat a; +Mat mfp(){ + Mat res; + res.setid(); + while(k){ + if(k&1)res=res*a; + a=a*a; + k/=2; + } + return res; +} + +int main(){ + fnn([&](ll i,ll j){ + std::cin>>a.vec[i][j]; + }); + const Mat res = mfp(); + fnn([&](ll i,ll j){ + std::cout<