日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

EOJ Monthly 2019.2 (based on February Selection) D.进制转换

發布時間:2024/7/5 编程问答 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 EOJ Monthly 2019.2 (based on February Selection) D.进制转换 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

題目鏈接:

  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)。

代碼實現如下:

?

1 #include <set> 2 #include <map> 3 #include <deque> 4 #include <queue> 5 #include <stack> 6 #include <cmath> 7 #include <ctime> 8 #include <bitset> 9 #include <cstdio> 10 #include <string> 11 #include <vector> 12 #include <cstdlib> 13 #include <cstring> 14 #include <iostream> 15 #include <algorithm> 16 using namespace std; 17 18 typedef long long LL; 19 typedef pair<LL, LL> pLL; 20 typedef pair<LL, int> pLi; 21 typedef pair<int, LL> pil;; 22 typedef pair<int, int> pii; 23 typedef unsigned long long uLL; 24 25 #define lson rt<<1 26 #define rson rt<<1|1 27 #define lowbit(x) x&(-x) 28 #define name2str(name) (#name) 29 #define bug printf("*********\n") 30 #define debug(x) cout<<#x"=["<<x<<"]" <<endl 31 #define FIN freopen("D://code//in.txt","r",stdin) 32 #define IO ios::sync_with_stdio(false),cin.tie(0) 33 34 const double eps = 1e-8; 35 const int mod = 1000000007; 36 const int maxn = 2e5 + 7; 37 const double pi = acos(-1); 38 const int inf = 0x3f3f3f3f; 39 const LL INF = 0x3f3f3f3f3f3f3f3fLL; 40 41 int t; 42 LL l, r, k, m; 43 44 int main(){ 45 scanf("%d", &t); 46 while(t--) { 47 scanf("%lld%lld%lld%lld", &l, &r, &k, &m); 48 int flag = 1; 49 LL ans = 0, tmp = 1; 50 for(int i = 1; i <= m; i++) { 51 if(r / tmp < k) { 52 flag = 0; 53 break; 54 } 55 tmp = tmp * k; 56 } 57 if(!flag) { 58 printf("0\n"); 59 continue; 60 } 61 ans = r / tmp - (l - 1) / tmp; 62 if(r / tmp >= k) { 63 tmp = tmp * k; 64 ans -= r / tmp - (l - 1) / tmp; 65 } 66 printf("%lld\n", ans); 67 } 68 return 0; 69 }

?

轉載于:https://www.cnblogs.com/Dillonh/p/10430190.html

總結

以上是生活随笔為你收集整理的EOJ Monthly 2019.2 (based on February Selection) D.进制转换的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。