From c96882f67e87b0174c360bde27137b7cb2a40af3 Mon Sep 17 00:00:00 2001 From: Zengtudor Date: Mon, 27 Oct 2025 14:41:23 +0800 Subject: [PATCH] =?UTF-8?q?fix(P7990.cpp):=20=E4=BF=AE=E5=A4=8D=E6=AF=94?= =?UTF-8?q?=E8=BE=83=E8=BF=90=E7=AE=97=E7=AC=A6=E7=BC=BA=E5=B0=91const?= =?UTF-8?q?=E4=BF=AE=E9=A5=B0=E7=AC=A6=E7=9A=84=E9=97=AE=E9=A2=98=20feat(y?= =?UTF-8?q?acs101.cpp):=20=E6=B7=BB=E5=8A=A0=E6=96=B0=E9=A2=98=E7=9B=AE?= =?UTF-8?q?=E8=A7=A3=E6=B3=95=EF=BC=8C=E8=AE=A1=E7=AE=97=E5=A5=87=E5=81=B6?= =?UTF-8?q?=E6=95=B0=E4=B9=98=E7=A7=AF=20refactor(P1495.cpp):=20=E7=A7=BB?= =?UTF-8?q?=E9=99=A4=E6=9C=AA=E4=BD=BF=E7=94=A8=E7=9A=84=E6=89=A9=E5=B1=95?= =?UTF-8?q?=E6=AC=A7=E5=87=A0=E9=87=8C=E5=BE=97=E7=AE=97=E6=B3=95=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0=20refactor(P3811.cpp):=20=E9=87=8D=E6=9E=84=E6=A8=A1?= =?UTF-8?q?=E9=80=86=E5=85=83=E8=AE=A1=E7=AE=97=EF=BC=8C=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E6=89=A9=E5=B1=95=E6=AC=A7=E5=87=A0=E9=87=8C=E5=BE=97=E7=AE=97?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/10/17/P7990.cpp | 2 +- src/10/27/yacs101.cpp | 15 +++++++++++++++ src/2/P1495.cpp | 31 ------------------------------- src/2/P3811.cpp | 28 ++++++++++++++++++---------- 4 files changed, 34 insertions(+), 42 deletions(-) create mode 100644 src/10/27/yacs101.cpp diff --git a/src/10/17/P7990.cpp b/src/10/17/P7990.cpp index 551fb5e..482cb13 100644 --- a/src/10/17/P7990.cpp +++ b/src/10/17/P7990.cpp @@ -12,7 +12,7 @@ const ll maxn = 2e5+5; ll k,m,n,f[maxn],l[maxn],r[maxn]; struct C{ ll p,t; - inline bool operator<(const C& o){ + inline bool operator<(const C& o)const{ return p +#include +#include +using ll = int64_t; + +ll n,one,two; + +int main(){ + std::iostream::sync_with_stdio(false); + std::cin.tie(nullptr); + + std::cin>>n; + for(ll i=1;i<=n;i++)one+=i&1,two+=!(i&1); + std::cout< -#include -#include -#include - using ll = int64_t; -std::tuple exgcd(const ll &a,const ll &b){ - if(b==0){ - ll x=1,y=0; - return std::make_tuple(a,x,y); - } - auto[d,x,y] = exgcd(b, a%b); - const ll tmpy = y; - y=x-a/b*y; - x=tmpy; - return std::make_tuple(d,x,y); -} - -ll inv(const ll &n,const ll &p){ - auto[d,x,y]=exgcd(n, p); - x=(x%p+p)%p; - return x; -} int main(){ - ll N; - std::cin>>N; - std::vector p(N),n(N); - for(ll i{0};i>p[i]>>n[i]; - } - ll prod{1}; - for(ll pi:p){ - prod=prod*pi; - } } \ No newline at end of file diff --git a/src/2/P3811.cpp b/src/2/P3811.cpp index 68a96b9..d8e13c8 100644 --- a/src/2/P3811.cpp +++ b/src/2/P3811.cpp @@ -1,21 +1,29 @@ #include #include #include - using ll = int64_t; -const ll maxn=3e6+5; -ll inv[maxn]; +ll n,p; + +static inline ll exgcd(ll a,ll b,ll&x,ll&y){ + if(b==0){ + x=1; + y=0; + return a; + } + ll gcd=exgcd(b, a%b, y, x); + y-=a/b*x; + return gcd; +} int main(){ std::iostream::sync_with_stdio(false); - std::cout.tie(nullptr); - ll n,p; + std::cin.tie(nullptr); + std::cin>>n>>p; - inv[1]=1; - std::cout<<1<<'\n'; - for(ll i{2};i<=n;i++){ - inv[i]=(p-p/i)*inv[p%i]%p; - std::cout<