B. Recursive Queries 打表
Code:
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
const int maxn=1000000+4;
using namespace std;
void setio(string a){
freopen((a+".in").c_str(),"r",stdin),freopen((a+".out").c_str(),"w",stdout);
}
int f(int x){
if(x==0) return 0;
int rep=1;
while(x)
{
while(x%10==0) x/=10;
rep*=(x%10);
x/=10;
}
return rep;
}
int g(int x){
if(x<10) return x;
return g(f(x));
}
int c[maxn][12];
int main(){
//setio("input");
for(int i=1;i<=1000000;++i)
{
int x=g(i);
for(int j=1;j<=9;++j)
{
if(x==j) c[i][j]=c[i-1][j]+1;
else c[i][j]=c[i-1][j];
}
}
int q;
scanf("%d",&q);
while(q--)
{
int l,r,k;
scanf("%d%d%d",&l,&r,&k);
printf("%d\n",c[r][k]-c[l-1][k]);
}
return 0;
}
B. Recursive Queries 打表的更多相关文章
- sql script: Graphs, Trees, Hierarchies and Recursive Queries
--------------------------------------------------------------------- -- Inside Microsoft SQL Server ...
- sql server: Graphs, Trees, Hierarchies and Recursive Queries
--------------------------------------------------------------------- -- Chapter 09 - Graphs, Trees, ...
- Codeforces 932.B Recursive Queries
B. Recursive Queries time limit per test 2 seconds memory limit per test 256 megabytes input standar ...
- 笔记-Recursive Queries
Recursive Queries \[m_{l,r}=\textrm{id}(\max_{i=l}^r a_i)\\ f(l,r)= \begin{cases} (r-l+1)+f(l,m_{l,r ...
- 前缀和的应用 CodeForces - 932B Recursive Queries
题目链接: https://vjudge.net/problem/1377985/origin 题目大意就是要你把一个数字拆开,然后相乘. 要求得数要小于9,否则递归下去. 这里用到一个递归函数: i ...
- 前缀和:CodeForces 932B Recursive Queries
Description Let us define two functions f and g on positive integer numbers. You need to process Q q ...
- Codeforces 1117G Recursive Queries [线段树]
Codeforces 洛谷:咕咕咕 思路 设\(L_i,R_i\)为\(i\)左右第一个大于它的位置. 对于每一个询问\(l,r\),考虑区间每一个位置的贡献就是\(\min(r,R_i-1)-\ma ...
- Recursive Queries CodeForces - 1117G (线段树)
题面: 刚开始想复杂了, 还以为是个笛卡尔树.... 实际上我们发现, 对于询问(l,r)每个点的贡献是$min(r,R[i])-max(l,L[i])+1$ 数据范围比较大在线树套树的话明显过不了, ...
- CF1117G Recursive Queries
题意:给定一个序列,定义[l, r]的最大值在m处,求f(l, r) = f(l, m - 1) + (r - l + 1) + f(m + 1, r).多次询问.100w. 解:考虑这个区间内每个数 ...
随机推荐
- Pyhton学习——Day48
# 转载:http://www.cnblogs.com/yuanchenqi/articles/6437362.html#python关于mysql的API--pymysql模块# 执行sql语句# ...
- Flex tree展开节点问题!
问题: 使用 for each(var item:XML in menuTree.dataProvider) { menuTree.expandChildrenOf(item,true); ...
- HDU 2079 选课时间(母函数模板题)
链接:传送门 思路:母函数模板题 /************************************************************************* > Fil ...
- EXGSBS模板
EXBSGS模板 我之前把有一处b和c弄反了,有点困...然后调了半天 (exbsgs比excrt简单多了) 求x的最小正整数解 原式子拆成 在bsgs中,保证a,b互质,这样求出的逆元挪过去才对 但 ...
- pip常见用法汇总
1.pip安装 yum -y install epel-release && yum -y install python-pip 2.pip安装软件 (1)安装单个软件:pip ins ...
- Python学习笔记(一):基本数据类型
在Python3种,有六种标准数据类型: 数字(Number) 字符串(String) 列表(List) 元组(Tuple) 集合(Set) 字典(Dictionary) 这六种数据类型中,数字类型和 ...
- 第十一章 Servlet MVC模式
内包含案例,基于jsp+servlet的:MVC模式计算器:MVC模式登陆 第十一章 Servlet MVC模式 模型-视图-控制器(model-view-controller),简称MVC.MVC是 ...
- 创业笔记-Node.js入门之基于事件驱动的回调
基于事件驱动的回调 这个问题可不好回答(至少对我来说),不过这是Node.js原生的工作方式.它是事件驱动的,这也是它为什么这么快的原因. 你也许会想花点时间读一下Felix Geisendörfer ...
- [React] Understanding setState in componentDidMount to Measure Elements Without Transient UI State
In this lesson we'll explore using setState to synchronously update in componentDidMount. This allow ...
- 2015级C++第2周实践项目
[项目1 - 宣告"主权"] 你已经是CSDN博客主了,用IT人特有的方式,编一段程序.在屏幕上输出你想说的话.按要求公布博文,作为我们的开山之作. [项目2 - 胖子不想说体重] ...