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<