「杂题乱刷2」CF1513C
1.「杂题乱刷」洛谷P10642.「杂题乱刷」洛谷P22853.「杂题乱刷」洛谷P15444.「杂题乱刷」洛谷P12165.「杂题乱刷」CF1272D6.「杂题乱刷」CF1105C7.「杂题乱刷」洛谷P24268.「杂题乱刷」AT_abc280_e9.「杂题乱刷」AT_abc307_e10.「杂题乱刷」AT_abc208_e11.「杂题乱刷」P868712.「杂题乱刷」洛谷 P183113.「杂题乱刷」ZhengRui 611 【19寒假普转提】树的权14.「杂题乱刷」AT_abc314_e15.「杂题乱刷」AT_abc220_f16.「杂题乱刷」Zheng Rui 327 【2018普转提day17专题】洗17.「杂题乱刷」AT_abc354_f18.「杂题乱刷」 AT_abc285_e19.「杂题乱刷」P881620.「杂题乱刷」AT_abc358_g21.「杂题乱刷」CF1987D22.「杂题乱刷2」CF607B
23.「杂题乱刷2」CF1513C
24.「杂题乱刷2」CF1183E & CF1183H25.「杂题乱刷2」CF1839E26.「杂题乱刷2」CF1433F27.「杂题乱刷2」CF1354Eduel 到的。
题目链接
解题思路
我们发现,初始数列中的每个数字变为
状态为
转移显然。
按照这样的思路预处理即可。
参考代码
点击查看代码
/*
Tips:
你数组开小了吗?
你MLE了吗?
你觉得是贪心,是不是该想想dp?
一个小时没调出来,是不是该考虑换题?
打 cf 不要用 umap!!!
记住,rating 是身外之物。
该冲正解时冲正解!
Problem:
算法:
思路:
*/
#include<bits/stdc++.h>
using namespace std;
//#define map unordered_map
#define re register
#define ll long long
#define forl(i,a,b) for(re ll i=a;i<=b;i++)
#define forr(i,a,b) for(re ll i=a;i>=b;i--)
#define forll(i,a,b,c) for(re ll i=a;i<=b;i+=c)
#define forrr(i,a,b,c) for(re ll i=a;i>=b;i-=c)
#define mid ((l+r)>>1)
#define lowbit(x) (x&-x)
#define pb push_back
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);init();
#define endl '\n'
#define QwQ return 0;
#define db long double
#define ull unsigned long long
#define lcm(x,y) x/__gcd(x,y)*y
#define Sum(x,y) 1ll*(x+y)*(y-x+1)/2
#define aty cout<<"Yes\n";
#define atn cout<<"No\n";
#define cfy cout<<"YES\n";
#define cfn cout<<"NO\n";
#define xxy cout<<"yes\n";
#define xxn cout<<"no\n";
#define printcf(x) x?cout<<"YES\n":cout<<"NO\n";
#define printat(x) x?cout<<"Yes\n":cout<<"No\n";
#define printxx(x) x?cout<<"yes\n":cout<<"no\n";
#define maxqueue priority_queue<ll>
#define minqueue priority_queue<ll,vector<ll>,greater<ll>>
void Max(ll&x,ll y){x=max(x,y);}
void Min(ll&x,ll y){x=min(x,y);}
ll t;
ll n,m;
string s;
ll mod=1e9+7;
ll dp[200010][10],sum[200010],ans;
void _clear(){}
void solve()
{
_clear();
cin>>s>>m;
s=' '+s;
forl(i,1,(ll)s.size()-1)
{
if('9'+1-s[i]<=m)
ans+=sum[m-('9'+1-s[i])];
else
ans++;
ans%=mod;
}
cout<<ans<<endl;
ans=0;
}
void init()
{
dp[0][0]=1,dp[0][1]=1;
sum[0]=2;
forl(i,1,2e5+5)
{
forl(j,0,8)
dp[i][j+1]+=dp[i-1][j],dp[i][j+1]%=mod;
dp[i][0]+=dp[i-1][9];
dp[i][1]+=dp[i-1][9];
dp[i][0]%=mod;
dp[i][1]%=mod;
forl(j,0,9)
sum[i]+=dp[i][j],sum[i]%=mod;
}
}
int main()
{
IOS;
t=1;
cin>>t;
while(t--)
solve();
QwQ;
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?