ZOJ Problem Set
来源:互联网 发布:大数据挖掘与应用 编辑:程序博客网 时间:2024/05/17 23:26
写一个从0x000000到x的结果的函数,依此来推出结果
#include<iostream>#include<string>using namespace std;int s[] = { 6,8,13,18,22,27,33,36,43,49,55,60,64,69,74,78 };long long int f(long long int x){ long long int t = 1; long long int r = 1; long long int re=0; for (int i = 0; i < 8; ++i) { int A = x & 0xf; x >>= 4; re += (A==0)?s[0]*r:(s[A]-s[A-1])*r; if (A) re += s[A - 1] * t; re += x*s[15]*t; r = r+ A*t; t<<=4; } return re;}int main(){ long long int N; long long int a, n; scanf("%u", &N); while (N--) { long long int re = 0; scanf("%llu", &n); scanf("%llx", &a); --n; long long int b = a + n; if (a == 0) { printf("%lld\n", f(b)); continue; } if (b > 0xffffffff) { re += f(0xffffffff) - f(a - 1); b &= 0xffffffff; re += f(b); printf("%lld\n", re); } else { re += f(b) - f(a - 1); printf("%lld\n", re); } }}
0 0
- ZOJ Problem Set - 2060
- ZOJ Problem Set - 2972
- ZOJ Problem Set - 1037
- ZOJ Problem Set - 1048
- ZOJ Problem Set - 1049
- ZOJ Problem Set - 1051
- ZOJ Problem Set - 1067
- ZOJ Problem Set - 1115
- ZOJ Problem Set - 1151
- ZOJ Problem Set - 1205
- ZOJ Problem Set - 1025
- ZOJ Problem Set - 1029
- ZOJ Problem Set - 1076
- ZOJ Problem Set - 1117
- ZOJ Problem Set - 1041
- ZOJ Problem Set - 1004
- ZOJ Problem Set - 1005
- ZOJ Problem Set - 1016
- hdu 3033 分组背包,每组最少取一个
- ffmpeg源码简析(六)编码-av_write_frame(),av_write_trailer()
- 构建自己的违例 和 finally
- 容器的内嵌类——迭代器
- PHP 对接招商银行网银接口
- ZOJ Problem Set
- 前端练习——弹窗、判断语句 (星座测试)
- spring、springMVC简单应用FutureTask(线程池)
- Git常用命令
- ¥¥%%%%%Ubuntu下用matplotlib作图时显示中文###重点第5条可以用!!!!%%%%%
- 系统还原点
- VmWare 安装XP系统 出现未找到硬盘驱动器的错误
- 《剑指offer》002-实现Singleton模式(java实现)
- SDK manager打不开解决办法