Palindrome Function
来源:互联网 发布:php网站数据库在哪里 编辑:程序博客网 时间:2024/05/29 08:34
Palindrome Function
Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 256000/256000 K (Java/Others)Total Submission(s): 0 Accepted Submission(s): 0
Problem Description
As we all know,a palindrome number is the number which reads the same backward as forward,such as 666 or 747.Some numbers are not the palindrome numbers in decimal form,but in other base,they may become the palindrome number.Like 288,it’s not a palindrome number under 10-base.But if we convert it to 17-base number,it’s GG,which becomes a palindrome number.So we define an interesting function f(n,k) as follow:
f(n,k)=k if n is a palindrome number under k-base.
Otherwise f(n,k)=1.
Now given you 4 integers L,R,l,r,you need to caluclate the mathematics expression∑Ri=L∑rj=lf(i,j) .
When representing the k-base(k>10) number,we need to use A to represent 10,B to represent 11,C to repesent 12 and so on.The biggest number is Z(35),so we only discuss about the situation at most 36-base number.
f(n,k)=k if n is a palindrome number under k-base.
Otherwise f(n,k)=1.
Now given you 4 integers L,R,l,r,you need to caluclate the mathematics expression
When representing the k-base(k>10) number,we need to use A to represent 10,B to represent 11,C to repesent 12 and so on.The biggest number is Z(35),so we only discuss about the situation at most 36-base number.
Input
The first line consists of an integer T,which denotes the number of test cases.
In the following T lines,each line consists of 4 integers L,R,l,r.
(1≤T≤105,1≤L≤R≤109,2≤l≤r≤36 )
In the following T lines,each line consists of 4 integers L,R,l,r.
(
Output
For each test case, output the answer in the form of “Case #i: ans” in a seperate line.
Sample Input
31 1 2 361 982180 10 10496690841 524639270 5 20
Sample Output
Case #1: 665Case #2: 1000000Case #3: 447525746
阅读全文
0 8
- Palindrome Function
- Palindrome Function
- Hdu 6156 Palindrome Function
- HDU 6156 Palindrome Function
- hdu 6156 Palindrome Function
- HDU6156-Palindrome Function
- hdu 6156 Palindrome Function
- HDU-6156 Palindrome Function
- HDU6156-Palindrome Function
- hdoj 6156 Palindrome Function
- HDU6156 Palindrome Function
- Palindrome Function HDU
- HDU6156 Palindrome Function[数位DP]
- hdu6156 Palindrome Function数位dp
- hdu6156 Palindrome Function 思维题
- Palindrome Function(回文数)
- hdu6156 Palindrome Function 数位dp
- hdu 6156 Palindrome Function 数位DP
- 第二十天总结
- 多线程快速入门
- Subsequence Count
- (二)SSM中mybatis一对一查询
- 服务器开发之简单的TCP回射服务器(0):程序说明
- Palindrome Function
- instanceof的使用: 对象与构造函数在原型链上是否有关系
- 交换排序-冒泡排序
- The Karting
- hdu2955(01背包)
- The Designer
- 笔记
- [2017-08-19 17:02:13
- HTTP状态码详解