题目链接:

  https://acm.ecnu.edu.cn/contest/140/problem/D/

题目:

思路:

  我们知道一个数在某一个进制k下末尾零的个数x就是这个数整除kx,这题要求刚好末尾有m个0,还需要除去高位为0的情况,因此这题答案就是r / kx-(l-1)/kx-(r/kx+1-(l-1)/kx+1)。

代码实现如下:

 #include <set>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std; typedef long long LL;
typedef pair<LL, LL> pLL;
typedef pair<LL, int> pLi;
typedef pair<int, LL> pil;;
typedef pair<int, int> pii;
typedef unsigned long long uLL; #define lson rt<<1
#define rson rt<<1|1
#define lowbit(x) x&(-x)
#define name2str(name) (#name)
#define bug printf("*********\n")
#define debug(x) cout<<#x"=["<<x<<"]" <<endl
#define FIN freopen("D://code//in.txt","r",stdin)
#define IO ios::sync_with_stdio(false),cin.tie(0) const double eps = 1e-;
const int mod = ;
const int maxn = 2e5 + ;
const double pi = acos(-);
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3fLL; int t;
LL l, r, k, m; int main(){
scanf("%d", &t);
while(t--) {
scanf("%lld%lld%lld%lld", &l, &r, &k, &m);
int flag = ;
LL ans = , tmp = ;
for(int i = ; i <= m; i++) {
if(r / tmp < k) {
flag = ;
break;
}
tmp = tmp * k;
}
if(!flag) {
printf("0\n");
continue;
}
ans = r / tmp - (l - ) / tmp;
if(r / tmp >= k) {
tmp = tmp * k;
ans -= r / tmp - (l - ) / tmp;
}
printf("%lld\n", ans);
}
return ;
}

最新文章

  1. 创建PO
  2. 常用的PL/SQL开发原则
  3. 查看各个release版本 golang的改动
  4. Source insight 3572安装和版本号An invalid source insight serial number was detected解
  5. Python Data Visualization Cookbook 2.9.2
  6. mysql5.7.10和mysql5.5.39两个版本对于group by函数的处理差异
  7. Xamarin组件包 Xamarin.ToolKit
  8. RAC之常用方法-----新手入门
  9. 在TFS中通过程序动态创建Bug并感知Bug解决状态
  10. Altera FIFO IP核时序说明
  11. Oracle最新的Sql笔试题及答案
  12. bootstrap-fileinput视频上传
  13. 西安80投影坐标系转WGS84地理坐标系如何求七参数
  14. 学习笔记12之通过ajax动态添加选项
  15. redis内部数据结构和外部数据结构揭秘
  16. 洛谷 P1377 [TJOI2011]树的序 解题报告
  17. [ASP.NET MVC2 系列] ASP.Net MVC教程之《在15分钟内用ASP.Net MVC创建一个电影数据库应用程序》
  18. Advanced Installer 换产品ID,生成文件名
  19. 撩课-Java每天5道面试题第10天
  20. BZOJ 1010 [HNOI2008]玩具装箱 (斜率优化DP)

热门文章

  1. Robot Framework 教程 (2) - 页面元素定位
  2. SQLSERVER 的资源限制
  3. 【转】正确的 Composer 扩展包安装方法
  4. SpringBoot(十二)_springboot整合PageHelper
  5. [OS] 内核态和用户态的区别
  6. 如何调换antd中Modal对话框确认按钮和取消按钮两个按钮的位置
  7. Android 5.0 Activity切换动画
  8. mysqlbinlog- 处理二进制日志文件的实用工具 学习笔记
  9. 关于未来IT职业教育的思考
  10. Service Intent must be explicit的解决方法