LightOJ
来源:互联网 发布:手机淘宝手机官方版 编辑:程序博客网 时间:2024/05/19 01:13
题意:
给定 n 和 b, 求 n的阶乘 在 b 进制下的位数
思路:
知识点:一个数 n 在 b 进制下在位数: log(b)n
这样的话需要打表预处理,用换底公式自己推一下
#include<iostream>#include<algorithm>#include<cstdio>#include<cstdlib>#include<cstring>#include<string>#include<cmath>#include<set>#include<queue>#include<stack>#include<map>#define PI acos(-1.0)#define in freopen("in.txt", "r", stdin)#define out freopen("out.txt", "w", stdout)using namespace std;typedef long long ll;typedef unsigned long long ull;const int maxn = 1e6 + 7, maxd = 20 + 7, mod = 1e9 + 7;const int INF = 0x7f7f7f7f;double a[maxn];void init() { for(int i = 1; i < maxn; ++i) { a[i] = a[i-1] + log(i); }}int main() { init(); int T; scanf("%d", &T); for(int tt = 1; tt <= T; ++tt) { int n, b; scanf("%d %d", &n, &b); if(n == 0) printf("Case %d: 1\n", tt); else { double ans = a[n] / log(b) + 1; printf("Case %d: %d\n", tt, (int)ans); } } return 0;}
阅读全文
1 0
- LightOJ
- LightOJ
- LightOJ
- LightOJ
- LightOJ
- [LightOJ
- LightOJ
- LightOJ
- LightOJ
- LightOJ
- LightOJ
- LightOJ
- LightOJ
- LightOJ
- LightOJ
- LightOJ
- LightOJ
- LightOJ
- Game of Connections HDU
- How to uninstall/update/ your python in Linux
- sftp常用命令
- 安卓listview或Recycle中防止图片被抓包
- MyBatis批量增删改查操作
- LightOJ
- spring boot 初体验
- replaceall 的java正则表达式实现
- The Zen of Python
- Android防止输入框自动弹出
- Autolabor Simulation(AS)实现机器人路径规划与障碍物避障
- 数据分析处理库Pandas-数据预处理
- android 控件多次点击控制
- permission denied (publickey)问题的解决