Codeforces 1288B - Yet Another Meme Problem
题目大意:
令conc(a,b)函数得出的结果为将ab拼接得到的数字。
例如:conc(12,23)=1223
a和b不会包括前导0!
接下来,你已知A和B,问有多少对的(a,b)满足
1≤a≤A , 1≤b≤B
a*b+a+b=conc(a,b)
解题思路:
想法题,只需要满足b这个数字每一位全为9,那么等式 a*b+a+b=conc(a,b) 恒成立
因为 a*b+a+b=a*(b+1)+b
b+1为一个首位是1,其余位全为0的数,且长度为b的长度+1
所以a*(b+1)+b相当于a*(Length(b)+1)+b,即满足conc(a,b)的功能
故,只要计算1到B中有多少每一位全为9的数,再乘以A即可(a任取恒满足)
注意,最坏情况下a有1e9种,b有9种,最大的答案为9e9,超出int范围,必须用long long
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=;
bool isnine(ll in){
while(in){
if(in%!=)
return false;
in/=;
}
return true;
}
int len(ll in){
int ans=;
do{
in/=;
ans++;
}while(in);
return ans;
}
int main(){
ios::sync_with_stdio();
cin.tie();cout.tie();
ll T,A,B,i,j,k;
cin>>T;
while(T--){
cin>>A>>B;
if(isnine(B))
cout<<A*len(B)<<endl;
else
cout<<A*(len(B)-)<<endl;
} return ;
}
Codeforces 1288B - Yet Another Meme Problem的更多相关文章
- 【codeforces 442B】 Andrey and Problem
http://codeforces.com/problemset/problem/442/B (题目链接) 题意 n个人,每个人有p[i]的概率出一道题.问如何选择其中s个人使得这些人正好只出1道题的 ...
- Codeforces Gym 100015A Another Rock-Paper-Scissors Problem 找规律
Another Rock-Paper-Scissors Problem 题目连接: http://codeforces.com/gym/100015/attachments Description S ...
- 屏蔽Codeforces做题时的Problem tags提示
当在Codeforces上做题的时,有时会无意撇到右侧的Problem tags边栏,但是原本并不希望能够看到它. 能否把它屏蔽了呢?答案是显然的,我们只需要加一段很短的CSS即可. span.tag ...
- codeforces#253 D - Andrey and Problem里的数学知识
这道题是这种,给主人公一堆事件的成功概率,他仅仅想恰好成功一件. 于是,问题来了,他要选择哪些事件去做,才干使他的想法实现的概率最大. 我的第一个想法是枚举,枚举的话我想到用dfs,但是认为太麻烦. ...
- Codeforces Round #243 (Div. 2) Problem B - Sereja and Mirroring 解读
http://codeforces.com/contest/426/problem/B 对称标题的意思大概是.应当指出的,当线数为奇数时,答案是线路本身的数 #include<iostream& ...
- Codeforces 803 G. Periodic RMQ Problem
题目链接:http://codeforces.com/problemset/problem/803/G 大致就是线段树动态开节点. 然后考虑到如果一个点还没有出现过,那么这个点显然未被修改,就将这个点 ...
- C. Meme Problem
链接 [http://codeforces.com/contest/1076/problem/C] 题意 a+b=d and a⋅b=d. 计算出a和b 分析 ab=a(d-a)=d aa-ad+d= ...
- Codeforces 903G Yet Another Maxflow Problem - 线段树
题目传送门 传送门I 传送门II 传送门III 题目大意 给定一个网络.网络分为$A$,$B$两个部分,每边各有$n$个点.对于$A_{i} \ (1\leqslant i < n)$会向$A_ ...
- Codeforces Round #439 (Div. 2) Problem E (Codeforces 869E) - 暴力 - 随机化 - 二维树状数组 - 差分
Adieu l'ami. Koyomi is helping Oshino, an acquaintance of his, to take care of an open space around ...
随机推荐
- python格式字符
- Swift字符串截取与Range使用
1.String.Index String.Index表示一个位置,使用String与String.Index可以获取该位置的Character let str = "123456789&q ...
- AttributeError: 'list' object has no attribute 'data'智障错误
import urllib.requestimport urllib.parse url = ['http://fanyi.youdao.com/translate?smartresult=dict& ...
- 计划任务常用在线工具-微服务信息整-seafile网盘-亿图操作-正则工具
正则工具 https://regex101.com/ http://www.regexp.cn/Regex 身份证匹配 ^(\\d{}|\d{})(\\d|[xX])$ \d{}[-9Xx]|\d{} ...
- [题解] CF622F The Sum of the k-th Powers
CF622F The Sum of the k-th Powers 题意:给\(n\)和\(k\),让你求\(\sum\limits_{i = 1} ^ n i^k \ mod \ 10^9 + 7\ ...
- C/C++学习笔记_gdb调试
1.前提条件:可执行文件包含调试信息 gcc -g 2.gdb 文件名 ---启动gdb调试 3.查看代码的命令 当前文件: list 行号(函数名) 指定文件: list 文件名:行号(函数名)4. ...
- java里mongodb复合查询
Query query = new Query();Criteria criteria = Criteria.where("packetTitle").is(redPacketSt ...
- 2019.1的IDEA的Pulgins无法使用解决
第一步 第二步
- Ubuntu16.04上安装cudnn教程和opencv
https://blog.csdn.net/wang15061955806/article/details/80791112 Ubuntu16.04上安装cudnn教程 2018年06月24日 14: ...
- 读书笔记 - js高级程序设计 - 第六章 面向对象的程序设计
EcmaScript有两种属性 数据属性 和 访问器属性 数据属性有4个特性 Configurable Enumerable Writable Value 前三个值的默认值都为false ...