[The Preliminary Contest for ICPC Asia Nanjing 2019] L-Digit sum
题意
$S_{b}(n)$表示数字$n$在$b$进制下各位的和,对于给定的数$N$和$b$,求出$\sum_{n=1}^{N}S_{b}(n)$ $[ link ]$
分析
题解上写的是签到题,这是个悲伤的故事。
直接$b$进制分解求$S_{b}(n)$,先预处理出$a[i][j]$表示$i$进制下从$1$到$j$每个数各位数求和后的总和
对于每组数据$O(1)$输出即可
Code
#include <cstdio>
const int n = 1e6+5;
int a[11][n];
int t, N, b;
int main()
{
scanf("%d", &t);
for (int i = 2; i <= 10; i++) {
for (int j = 1; j < n; j++) {
int sum = 0, p = j;
while(p>0) {
sum += p%i;
p /= i;
}
a[i][j] = a[i][j-1] + sum;
}
} for (int i = 1; i <= t; i++) {
scanf("%d%d", &N, &b);
printf("Case #%d: %d\n", i, a[b][N]);
}
}
[The Preliminary Contest for ICPC Asia Nanjing 2019] L-Digit sum的更多相关文章
- The Preliminary Contest for ICPC Asia Shanghai 2019 L. Digit sum
题目:https://nanti.jisuanke.com/t/41422 思路:预处理 #include<bits/stdc++.h> using namespace std; ][]= ...
- The Preliminary Contest for ICPC Asia Nanjing 2019/2019南京网络赛——题解
(施工中……已更新DF) 比赛传送门:https://www.jisuanke.com/contest/3004 D. Robots(期望dp) 题意 给一个DAG,保证入度为$0$的点只有$1$,出 ...
- [The Preliminary Contest for ICPC Asia Nanjing 2019] A-The beautiful values of the palace(二维偏序+思维)
>传送门< 前言 这题比赛的时候觉得能做,硬是怼了一个半小时,最后还是放弃了.开始想到用二维前缀和,结果$n\leq 10^{6}$时间和空间上都爆了,没有办法.赛后看题解用树状数组,一看 ...
- 计蒜客 The Preliminary Contest for ICPC Asia Nanjing 2019
F Greedy Sequence You're given a permutation aa of length nn (1 \le n \le 10^51≤n≤105). For each ...
- The Preliminary Contest for ICPC Asia Nanjing 2019
传送门 A. The beautiful values of the palace 题意: 给出一个\(n*n\)的矩阵,并满足\(n\)为奇数,矩阵中的数从右上角开始往下,类似于蛇形填数那样来填充. ...
- The Preliminary Contest for ICPC Asia Nanjing 2019 H. Holy Grail
题目链接:https://nanti.jisuanke.com/t/41305 题目说的很明白...只需要反向跑spfa然后输入-dis,然后添-dis的一条边就好了... #include < ...
- The Preliminary Contest for ICPC Asia Nanjing 2019 B. super_log (广义欧拉降幂)
In Complexity theory, some functions are nearly O(1)O(1), but it is greater then O(1)O(1). For examp ...
- 树状数组+二维前缀和(A.The beautiful values of the palace)--The Preliminary Contest for ICPC Asia Nanjing 2019
题意: 给你螺旋型的矩阵,告诉你那几个点有值,问你某一个矩阵区间的和是多少. 思路: 以后记住:二维前缀和sort+树状数组就行了!!!. #define IOS ios_base::sync_wit ...
- B.super_log(The Preliminary Contest for ICPC Asia Nanjing 2019)
同:https://www.cnblogs.com/--HPY-7m/p/11444923.html #define IOS ios_base::sync_with_stdio(0); cin.tie ...
- H.Holy Grail ( floyd )(The Preliminary Contest for ICPC Asia Nanjing 2019)
题意: 给出一个有向图,再给出6条原来不存在的路径,让你在这6条路径上添加一个最小的数,使图不存在负环. 思路: 直接6遍 floyd 输出就行了. #include <bits/stdc++. ...
随机推荐
- LeetCode 二分查找模板 III
模板 #3: int binarySearch(vector<int>& nums, int target){ if (nums.size() == 0) return -1; i ...
- ASP.NET Core错误处理中间件[1]: 呈现错误信息
NuGet包"Microsoft.AspNetCore.Diagnostics"中提供了几个与异常处理相关的中间件.当ASP.NET Core应用在处理请求过程中出现错误时,我们可 ...
- AgileConfig - RESTful API 介绍
AgileConfig AgileConfig是一个基于.net core开发的轻量级配置中心. AgileConfig秉承轻量化的特点,部署简单.配置简单.使用简单.学习简单,它只提取了必要的一些功 ...
- Spring Cloud微服务Sentinel+Apollo限流、熔断实战总结
在Spring Cloud微服务体系中,由于限流熔断组件Hystrix开源版本不在维护,因此国内不少有类似需求的公司已经将眼光转向阿里开源的Sentinel框架.而以下要介绍的正是作者最近两个月的真实 ...
- 【Sed】使用sed删除文件指定行的内容
sed多看帮助文档,受益良多 sed -i '$d' filename 例如删除 /etc/profile的最后一行 cat -n /etc/profile ... 101 export PA ...
- 转发:[服务器]SSL安装证书教程
[服务器]SSL安装证书教程 来自阿里云教程 Tomcat服务器安装SSL证书 安装PFX格式证书 https://help.aliyun.com/document_detail/98576.ht ...
- ctfhub技能树—信息泄露—git泄露—Stash
打开靶机环境 查看页面内容 使用dirsearch进行扫描 使用Githack工具处理git泄露情况 进入.git/refs目录 发现stash文件,使用notepad++打开文件 使用git dif ...
- Windows10下Canvas对象获得屏幕坐标不正确的原因排查与处理
因为Canvas没有直接将画布内容保存为图片的方法,所以很多时候是通过获得Canvas画布的坐标,然后通过截图的方式来将画布内容保存为本地图片. 如何取得Canvas画布的坐标呢,比较简单实用的方式如 ...
- 01-CentOS 8.1安装 Docker
官方参考地址:https://docs.docker.com/install/linux/docker-ce/centos/ 里面包含包下载地址:https://download.docker.com ...
- centos7 开放指定端口
centos7 开放指定端口 #开放8080端口 firewall-cmd --zone=public --add-port=8080/tcp --permanent #重载防火墙 firewall- ...