POJ 3070 Fibonacci(矩阵快速幂)

#include <iostream>#include <string.h>using namespace std;typedef long long ll;int mod=10000;const int N=3;int n=2;int aa[N][N],tmp[N][N],res[N][N];void mul(int a[][N],int b[][N],int n){ memset(tmp,0,sizeof(tmp)); for(int i=1;i
分类: 其他 发布时间: 01-04 19:19 阅读次数: 0

CF 1151 D Min Cost String

#include <bits/stdc++.h>using namespace std;typedef long long ll;int n,k;void f(int pos,int &id){ if(pos==k+1)f(0,id); if(id>=n)return; cout<<(char)('a'+pos); id++; if(id>=n)return; for(int i=1;i+pos<=k
分类: 其他 发布时间: 01-04 19:19 阅读次数: 0

CF 1594 C Make Them Equal

#include <bits/stdc++.h>using namespace std;typedef long long ll;const int N=300005;bool notprime[N]={};ll prime[N],k=0;void pr(){ notprime[1]=1; for(ll i=2;i<=300000;i++) { if(!notprime[i])prime[++k]=i; for(int
分类: 其他 发布时间: 01-04 19:19 阅读次数: 0

CCPC2021网络赛重赛 1010 Bigraph Extension

#include<bits/stdc++.h>using namespace std;typedef long long ll;vector<pair<ll,ll> >vp;ll uset[200005];ll find(ll x){ ll p=x,t; while(uset[p]!=p)p=uset[p]; while(x!=uset[x]) { t=uset[x]; uset[x]=p;
分类: 其他 发布时间: 01-04 19:19 阅读次数: 0

CF 1157 C. Moamen and XOR(dp)

#define _CRT_SECURE_NO_WARNINGS#include <bits/stdc++.h>using namespace std;typedef long long ll;ll mod=1e9+7;ll dp[200050][2];ll pw[200050];void init(){ pw[0]=1; for(int i=1;i<=200000;i++)pw[i]=pw[i-1]*2%mod;}void solve(){ ll
分类: 其他 发布时间: 01-04 19:19 阅读次数: 0

CF 1555 D. Say No to Palindromes(构造)

#include <bits/stdc++.h>using namespace std;typedef long long ll;int main(){ ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); int n,m; cin>>n>>m; string t,s="abc"; cin>>t; vector<vector<int>
分类: 其他 发布时间: 01-04 19:19 阅读次数: 0

CF 1553 D. Backspace(双指针 贪心)

#define _CRT_SECURE_NO_WARNINGS#include <bits/stdc++.h>using namespace std;typedef long long ll;void solve(){ string t,s; cin>>t>>s; int q=t.size()-1,p=s.size()-1; while(q>=0 && p>=0) { if(t[
分类: 其他 发布时间: 01-04 19:19 阅读次数: 0

CF 1538 F Interesting Function

#include <bits/stdc++.h>using namespace std;typedef long long ll;int main(){ int T; scanf("%d",&T); while(T--) { int l,r; scanf("%d %d",&l,&r); int sum=0; while(l!=0 || r!=0) {
分类: 其他 发布时间: 01-04 19:19 阅读次数: 0

CF 1561D1 Up the Strip (simplified version)

#include <bits/stdc++.h>using namespace std;typedef long long ll;int main(){ ll n,p,t; cin>>n>>p; ll dp[200050],pre[200050]; dp[1]=1,pre[1]=1; for(ll x=2;x<=n;x++) { ll flag=0; t=sqrt(x);
分类: 其他 发布时间: 01-04 19:19 阅读次数: 0

CF 1519D Maximum Sum of Products

#define _CRT_SECURE_NO_WARNINGS#include <bits/stdc++.h>using namespace std;typedef long long ll;ll aa[200005],bb[200005],n;ll f(ll *p){ ll cnt=0,sum=0; for(int i=0;i<=n;i++) { if(p[i]==0 || i==n){sum+=cnt*(cnt+1)/2;cnt=0;
分类: 其他 发布时间: 01-04 19:19 阅读次数: 0

CF 1535C Unstable String

#define _CRT_SECURE_NO_WARNINGS#include <bits/stdc++.h>using namespace std;typedef long long ll;ll aa[200005],bb[200005],n;ll f(ll *p){ ll cnt=0,sum=0; for(int i=0;i<=n;i++) { if(p[i]==0 || i==n){sum+=cnt*(cnt+1)/2;cnt=0;
分类: 其他 发布时间: 01-04 19:19 阅读次数: 0

CF 1537 E1. Erase and Extend(构造)

#include <bits/stdc++.h>using namespace std;typedef long long ll;int main(){ ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); int n,k,ok=0; cin>>n>>k; char t[5006]; int ans=n; cin>>t; for(int len=1
分类: 其他 发布时间: 01-04 19:19 阅读次数: 0

CF 1536 C. Diluc and Kaeya(构造)

#define _CRT_SECURE_NO_WARNINGS#include <bits/stdc++.h>using namespace std;typedef long long ll;map<pair<int,int>,int> mp;int gcd(int x,int y){ return y==0?x:gcd(y,x%y);}void solve(){ int n; mp.clear(); scanf("%d",&
分类: 其他 发布时间: 01-04 19:18 阅读次数: 0

CF 1528 B. Kavi on Pairing Duty(dp,组合数学)

#include <bits/stdc++.h>using namespace std;typedef long long ll;ll dp[2000050],pre[2000050],mod=998244353,f[2000050];int main(){ for(int i=2;i<=2000000;i+=2) { for(int j=i;j<=2000000;j+=i)f[j]++; } int n; cin&g
分类: 其他 发布时间: 01-04 19:18 阅读次数: 0

CF 1526 C1. Potions (Easy Version)(二维背包dp)

#include <bits/stdc++.h>using namespace std;typedef long long ll;ll aa[2050],dp[2050][2050];int main(){ ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); ll n; cin>>n; memset(dp,-1,sizeof(dp)); dp[0][0]=0; for(ll
分类: 其他 发布时间: 01-04 19:18 阅读次数: 0

CF 1513 C. Add One

#include <bits/stdc++.h>using namespace std;typedef long long ll;ll dp[10][200060],mod=1e9+7;void solve(){ int n,m; scanf("%d %d",&n,&m); ll sum=0; while(n) { sum+=dp[n%10][m]; sum%=mod; n/=10;
分类: 其他 发布时间: 01-04 19:18 阅读次数: 0

CF 1512 G. Short Task

#include <bits/stdc++.h>using namespace std;typedef long long ll;const int N=1e7+5;int p[N],d[N],ans[N];void solve(){ int n; scanf("%d",&n); printf("%d\n",ans[n]);}int main(){ fill(p,p+N,-1); p[1]=1; for(int i=2;i*
分类: 其他 发布时间: 01-04 19:18 阅读次数: 0

CF 1476 D. Journey(线性dp)

#include <bits/stdc++.h>using namespace std;typedef long long ll;int dp[300050][2][2];string cc;void solve(){ int n; cin>>n; for(int i=0;i<=n;i++)dp[i][0][0]=dp[i][0][1]=dp[i][1][0]=dp[i][1][1]=0; cin>>(cc); dp
分类: 其他 发布时间: 01-04 19:18 阅读次数: 0

CF1604 C. Di-visible Confusion(lcm)

#include <bits/stdc++.h>using namespace std;typedef long long ll;ll gcd(ll a,ll b){ ll sum=b==0?a:gcd(b,a%b); return sum;}ll lcm(ll a,ll b){ ll g=gcd(a,b); ll sum=a*b/g; return sum;}void solve(){ int n; scanf("%d"
分类: 其他 发布时间: 01-04 19:18 阅读次数: 0

CF 1622D Shuffle 组合数学 构造

题解:枚举最左和最右发生改变的位置,可看作将j-i+1个位置上的1重新分配。如果末端位置的数为0,直接分配一个1,如果末端位置的数为1,分配一个零,然后将[c1+c0][c0]加给答案;代码:#include <bits/stdc++.h>using namespace std;typedef long long ll;int mod=998244353;int C[5005][5005],pre[5005];int add(int x,int y){return (x+y)%mo
分类: 其他 发布时间: 01-04 19:18 阅读次数: 0