A
来源:互联网 发布:上瘾网络剧拍摄花絮5 编辑:程序博客网 时间:2024/06/05 15:36
代码:
#include <iostream>#include <cstring>#include <cstdio>#include <algorithm>using namespace std;typedef long long LL;LL f[35][35]; LL x, y, b;int pos[35];int len;void init(){memset(f, 0, sizeof(f));f[0][0] = 1;for (int i = 1; i <= 32; i++){f[i][0] = f[i - 1][0];for (int j = 1; j <= i; j++){f[i][j] = f[i - 1][j - 1] + f[i - 1][j];}}}LL solve(LL t, LL k){len = 1;while (t){pos[len++] = t % b;t /= b;}LL ans = 0;for (int i = len - 1; i >= 1; i--){if (pos[i] > 1){ans += f[i - 1][k] + f[i - 1][k - 1];break;}else if (pos[i] == 1){ans += f[i - 1][k];k--;}if (k < 0)break;}return ans;}int main(){ios::sync_with_stdio(false); init();LL k;while (cin >> x >> y >> k >> b){cout << solve(y + 1, k) - solve(x, k)<< endl;}return 0;}
阅读全文
1 0
- a
- a
- a
- a
- a
- a
- a
- a
- a
- a
- a
- a
- a
- A
- A*
- a
- A
- a
- 我的第一篇博客
- 开始android 之路(废话篇)
- Django-restframework26 Versioning(版本控制)
- C++笔试题(单向链表)
- Your MATLAB license will expire in 05 days
- A
- 发稿排行>更多
- Spring security实战(2)-----搭建SpringBoot
- Django-restframework27 Content negotiation(内容协议)
- 跳跃游戏-----原博主的分析很精彩
- 计算乘积之和
- Django-restframework28 Metadata
- springMVC
- Django-restframework29 Schemas(概要,模式,架构)