Educational Codeforces Round 84 E. Count The Blocks
传送门: 1327- E. Count The Blocks
题意:给你一个整数n,求10^n内(每个数有前导零)长度为1到n的块分别有多少个。块的含义是连续相同数字的长度。
题解:从n=1开始枚举,ans数组记录每个长度的块的个数。当前的ans[n]的值就是下一个n++后的ans[n]的值,这样每次只用算长度为1的块有多少个就好了。为了方便,将ans数组倒过来记录。长度为1的块实际上就是总数字个数减去长度为2~n所含有的数字个数。比如n=1时,长度为1的个数有10,当n=2时,长度为1的个数就是10^2*2-10*2=180,n=3时,长度为1的个数就是10^3*3-180*2-10*3=2610;
1 #include<bits/stdc++.h>
2 #define ll long long
3 using namespace std;
4
5 const ll mod=998244353;
6 ll ans[200100],p[200100];
7
8 ll quick(ll a,ll b)
9 {
10 ll res=1;
11 a=a%mod;
12 while(b){
13 if(b&1) res=(res*a)%mod;
14 a=(a*a)%mod;
15 b>>=1;
16 }
17 return res;
18 }
19
20 int main()
21 {
22 ios::sync_with_stdio(false);
23 cin.tie(0);
24 cout.tie(0);
25 ll n;
26 cin>>n;
27 ans[1]=10;
28 p[1]=10;
29 ll sum=p[1]+ans[1];
30 for(ll i=2;i<=n;i++){
31 ans[i]=quick(10,i)*i%mod-sum+mod;
32 ans[i]%=mod;
33 p[i]=p[i-1]+ans[i];
34 p[i]%=mod;
35 sum+=p[i]+ans[i];
36 sum%=mod;
37 }
38 for(int i=n;i>=1;i--)
39 cout<<ans[i]<<' ';
40 return 0;
41 }
Educational Codeforces Round 84 E. Count The Blocks的更多相关文章
- Educational Codeforces Round 84 (Div. 2)
Educational Codeforces Round 84 (Div. 2) 读题读题读题+脑筋急转弯 = =. A. Sum of Odd Integers 奇奇为奇,奇偶为偶,所以n,k奇偶性 ...
- Educational Codeforces Round 68 E. Count The Rectangles
Educational Codeforces Round 68 E. Count The Rectangles 传送门 题意: 给出不超过\(n,n\leq 5000\)条直线,问共形成多少个矩形. ...
- Educational Codeforces Round 84 (Rated for Div. 2)
A. Sum of Odd Integers(思维) 思路 这一题看完ans之后觉得是真简单,不过有一些地方还是要理解的. 这一题输出YES,有两个条件 kk%2 == n%2k,这个条件的意思是 k ...
- Educational Codeforces Round 83 D. Count the Arrays(组合,逆元,快速幂)
题意: 从 m 个数中选 n - 1 个数组成先增后减的长为 n 的数组. 思路: 因为 n 个数中有两个数相同,所以每种情况实际上只有 n - 1 个不同的数--$c_m^{n - 1}$, 除去最 ...
- Educational Codeforces Round 6 C. Pearls in a Row
Educational Codeforces Round 6 C. Pearls in a Row 题意:一个3e5范围的序列:要你分成最多数量的子序列,其中子序列必须是只有两个数相同, 其余的数只能 ...
- Educational Codeforces Round 32
http://codeforces.com/contest/888 A Local Extrema[水] [题意]:计算极值点个数 [分析]:除了第一个最后一个外,遇到极值点ans++,包括极大和极小 ...
- Educational Codeforces Round 41 967 E. Tufurama (CDQ分治 求 二维点数)
Educational Codeforces Round 41 (Rated for Div. 2) E. Tufurama (CDQ分治 求 二维点数) time limit per test 2 ...
- Educational Codeforces Round 53 E. Segment Sum(数位DP)
Educational Codeforces Round 53 E. Segment Sum 题意: 问[L,R]区间内有多少个数满足:其由不超过k种数字构成. 思路: 数位DP裸题,也比较好想.由于 ...
- Educational Codeforces Round 30
Educational Codeforces Round 30 A. Chores 把最大的换掉 view code #pragma GCC optimize("O3") #pr ...
随机推荐
- 【Linux】rsync模板配置问题
------------------------------------------------------------------------------------------------- | ...
- 【MySQL】一台服务器上搭建两个mysql节点
环境: CentOS 6.8 memory:1G Mysql 5.7 二进制安装包 1.安装相关的环境包 yum -y install gcc glibc libaio libstdc++ libs ...
- List使用Stream流进行集合Collection的各种运算汇总:对BigDecimal求和,某个字段的和、最大值、最小值、平均值,字段去重,过滤等
写Java接口的朋友都知道,Java 8的更新,经常会用到过滤 list<Object> 里的数据,本文就对List使用Stream流进行集合Collection的各种运算做一个汇总! 优 ...
- 使用Adobe Arcobat Pro DC生成PDF提示“PDFMaker文件遗失”新解决思路
环境: 1.Window 7 2.Adobe Arcobat Pro DC 2020.009.20065 3.Microsoft Office 2007 4.WPS 2019 虽然可以使用插件实现文件 ...
- python 编译EXE文件
以labelme测试 标注工具labelimg和labelme 矩形标注工具:labelimg 多边形标准工具:labelme 前者官网发布了可执行文件,后者只有python源码,如果需要编译wind ...
- JS实现植物大战僵尸小游戏,代码记录及效果展示
前几天看到了一个很有趣的demo,用js制作植物大战僵尸小游戏,本着学习的心态,对照着做了一下,发现这里面的一些代码设计的确很精妙,这里分享下源码和效果,如果有需要,可以看下. 效果如下: 下载地址
- Py数据类型—整形与字符串
数据类型 在指针的右边输入.可以触发功能列表: 数字(整形):也就是123之类的,不能是abcd和中文之类的,数据类型为int 1.强制字符转换 a="123" b=int(a) ...
- 从零开始学spring源码之ioc预热:bean的拓展和beanProcessor注册
上篇聊完了bean的解析,说起来做的事情很简单,把xml文件里面配置的标签全部解析到spring容器里面,但是spring做的时候,花了那么大代价去做,后面看看到底值不值得呢. 接下来看看prepar ...
- java.io.IOException: Could not find resource com/xxx/xxxMapper.xml
java.io.IOException: Could not find resource com/xxx/xxxMapper.xml 报错内容: org.apache.ibatis.exception ...
- Service Locator Pattern 服务定位
https://www.geeksforgeeks.org/service-locator-pattern/ Service Locator Pattern Last Updated: 06-03-2 ...