HDU 5936 Difference(思维+二分)——2016年中国大学生程序设计竞赛(杭州)
Posted ITAK
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了HDU 5936 Difference(思维+二分)——2016年中国大学生程序设计竞赛(杭州)相关的知识,希望对你有一定的参考价值。
Little Ruins is playing a number game, first he chooses two positive integers y andf(y,K)=∑z in every digits of yzK(f(233,2)=22+32+32=22)
then he gets the result
x=f(y,K)−y
As Ruins is forgetful, a few seconds later, he only remembers K ,
Input First line contains an integer T , which indicates the number of test cases.
Every test case contains one line with two integers
Limits
0≤x≤109
1≤K≤9
Output For every test case, you should output ’Case #x: y’, where x indicates the case number and counts from 1 and y is the result.
Sample Input
2 2 2 3 2
题目大意:
已知一个函数
f(y,k)−y=x
,其中
f(y,k)
表示
y
的每一位的
解题思路:
因为有一个很重要的条件就是
trick:
用 map 记录超时了,所以直接
upper_bound−lower_bound
就OK了
代码:
#include <iostream>
#include <string.h>
#include <string>
#include <algorithm>
#include <stdio.h>
HDU-5936 Difference(折半枚举)