LOADING

加载过慢请开启缓存,浏览器默认开启

Waiting for the dawn

daily 2

2023/9/6

CF 1696E

ll quick_pow(ll x,ll exp,int p)
{
      ll ans=1;
      while(exp)
      {
        if(exp&1)ans=ans*x%p;
        exp>>=1;
        x=x*x%p;
      }
      return ans;
}
ll inv[MAXN],fac[MAXN];
void init(int n,int p)
{
  memset(inv,0,sizeof(inv));
  memset(fac,0,sizeof(fac));
  inv[0]=fac[0]=1;
  for(int i=1;i<=n;++i)
  {
    fac[i]=fac[i-1]*i%p;
  }
  inv[n]=quick_pow(fac[n],p-2,p)%p;
  for(int i=n;i>=1;--i)inv[i-1]=inv[i]*i%p;
}
ll C(ll n,ll m,ll p)
{
  if(m>n||m<0)return 0;
  return fac[n]*inv[n-m]%p*inv[m]%p;
}
void solve() {
  int n;
  cin >> n;
  ++n;
  vector<ll> a(n + 1);
  for (int i = 1 ; i <= n; ++i) {
    cin >> a[i];
  } 
  ll ans = 0;
  for (int i = 1; i <= n; ++i) {
    ans = (ans + C(a[i] + i - 1, a[i] - 1, MOD)) %MOD;
  }
  cout << ans << '\n';
  return ;
}

CF 1699C

void solve() {
  int n;
  cin >> n;
  vector<int> a(n), pos(n);
  for (int i = 0; i <= n - 1; ++i) {
    cin >> a[i];
    pos[a[i]] = i;
  }
  int l = pos[0], r = pos[0];
  ll ans = 1;
  for (int i = 1; i <= n - 1; ++i) {
    if (pos[i] < l) {
      l = pos[i];
    } else if (pos[i] > r) {
      r = pos[i];
    } else {
      ans = ans * (r - l + 1 - i) % MOD;
    }
  }
  cout << ans << '\n';
  return ;
}
阅读全文

daily 1

2023/9/5

CF 1717D

ll quick_pow(ll x, ll exp, int p) {
  ll ans = 1;
  while (exp) {
    if (exp & 1) ans = ans * x % p;
    exp >>= 1;
    x = x * x % p;
  }
  return ans;
}
ll inv[MAXN], fac[MAXN];
void init(int n, int p) {
  memset(inv, 0, sizeof(inv));
  memset(fac, 0, sizeof(fac));
  inv[0] = fac[0] = 1;
  for (int i = 1; i <= n; ++i) {
    fac[i] = fac[i - 1] * i % p;
  }
  inv[n] = quick_pow(fac[n], p - 2, p) % p;
  for (int i = n; i >= 1; --i) inv[i - 1] = inv[i] * i % p;
}
ll C(ll n, ll m, ll p) {
  if (m > n || m < 0) return 0;
  return fac[n] * inv[n - m] % p * inv[m] % p;
}
void solve() {
  int n, k;
  cin >> n >> k;
  ll ans = 1;
  for (int i = 1; i <= min(n, k); ++i) {
    ans = (ans + C(n, i, MOD) % MOD) % MOD;
  }
  cout << ans << '\n';
}
阅读全文

daily 1

2023/9/2

CF 50A

#include<iostream>
using namespace std;
int main(){
    int m,n,t=0,Sn=0;
    cin>>m>>n;
    if(m%2==0){
        t=1;
    }
    if(n%2==0){
        t=2;
    }

    if(t==1){
        Sn=n*(m/2);
    }
    else if(t==2) {
        Sn=m*(n/2);
    }
    else {
        Sn=m*((n-1)/2)+(m-1)/2;
    }
    cout<<Sn;

}
阅读全文

daily 1

2023/9/1

daily codeforces

阅读全文

daily 2

2023/8/31

daily codeforces

阅读全文

daily 2

2023/8/30

daily codeforces

阅读全文

daily 1

2023/8/29

CF 1667B

struct fenwick {
  ll PartialSum[MAXN];
  fenwick() {
    for (int i = 0; i < MAXN; i++) PartialSum[i] = 0;
  }
  inline void add(ll index, ll increase) {
    while (index < MAXN) {
      PartialSum[index] = max(increase, PartialSum[index]);
      index += index & -index;
    }
  }
  inline ll get(int index) {
    ll sum = -INF;
    while (index) {
      sum = max(sum, PartialSum[index]);
      index -= index & -index;
    }
    return sum;
  }
};
ll a[MAXN], ord[MAXN], dp[MAXN], sum[MAXN];
void solve() {
  int T;
  cin >> T;
  int n;
  fenwick tr;
  while (T--) {
   cin >> n;
   vector<pii> pre;
   for (int i = 1; i <= n; ++i) {
     tr.PartialSum[i] = -INF;
   }
   for (int i = 1; i <= n; ++i) {
     cin >> a[i];
     sum[i] = sum[i - 1] + a[i];
     pre.push_back({sum[i], -i});
   }
   sort(pre.begin(), pre.end());
   for (int i = 1; i <= n; ++i) {
     ord[-pre[i - 1].second] = i;
   }
   for (int i = 1; i <= n; ++i) {
     dp[i] = dp[i - 1] + (a[i] > 0 ? 1 : (a[i] < 0 ? -1 : 0));
     auto pp = tr.get(ord[i]);
     dp[i] = max(dp[i], tr.get(ord[i]) + i);
     if (sum[i] > 0) dp[i] = i;
     tr.add(ord[i], dp[i] - i);
   }
   cout << dp[n] << '\n';
   dp[0] = sum[0] = 0;
  } 
  return ;
}
阅读全文

daily 2

2023/8/29
阅读全文

daily 1

2023/8/28

CF 900C

struct fenwick {
  ll PartialSum[MAXN];
  fenwick() {
    for (int i = 0; i < MAXN; i++) PartialSum[i] = 0;
  }
  inline void add(ll index, ll increase) {
    while (index < MAXN) {
      PartialSum[index] += increase;
      index += index & -index;
    }
  }
  inline ll get(int index) {
    ll sum = 0;
    while (index) {
      sum += PartialSum[index];
      index -= index & -index;
    }
    return sum;
  }
};
void solve() {
  int n;
  cin >> n;
  vector<int> p(n + 1);
  fenwick tr;
  for (int i = 1; i <= n; ++i) {
    cin >> p[i];
  }
  ll ans = -1, ans_i = 1;
  int cur_max = -1;
  vector<int> cnt(n + 1);
  for (int i = 1; i <= n; ++i) {
    cur_max = max(cur_max, p[i]);
    int cur_num = tr.get(p[i]);
    if (cur_num == i - 2) {
      cnt[cur_max]++;
    } else if (cur_num == i - 1){
      cnt[cur_max]--;
    }
    tr.add(p[i], 1);
  }
  for (int i = 1; i <= n; ++i) {
    if (cnt[i] > ans) {
      ans = cnt[i];
      ans_i = i;
    }
  }
  cout << ans_i << '\n';
  return;
}
阅读全文

daily 1

2023/8/27

CF 49A

#include<bits/stdc++.h>
using namespace std;
int main()
{
    char ch;
    bool flag=false;                
    while((ch=getchar())!=EOF)
    {
        if(ch=='A'||ch=='a'||ch=='E'||ch=='e'||ch=='I'||ch=='i'||ch=='O'||ch=='o'||ch=='U'||ch=='u'||ch=='V'||ch=='v'||ch=='Y'||ch=='y')
            flag=true;
        else if((ch>='A'&&ch<='Z')||(ch>='a'&&ch<='z'))
            flag=false;
    }
    if(flag)
        cout<<"YES";
    else
        cout<<"NO";
    return 0;
}
阅读全文
1 ... 9 10 11 12 13 ... 30
avatar
Yanxin Xiang

愿有一天能和你最重要的人再次相逢