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 ...
随机推荐
- No enclosing instance of type test is accessible. Must qualify the allocation with an enclosing inst
今日遇到一个报错如下: No enclosing instance of type test is accessible. Must qualify the allocation with an en ...
- 【数据结构】二叉树的遍历(前、中、后序及层次遍历)及leetcode107题python实现
文章目录 二叉树及遍历 二叉树概念 二叉树的遍历及python实现 二叉树的遍历 python实现 leetcode107题python实现 题目描述 python实现 二叉树及遍历 二叉树概念 二叉 ...
- 归并排序(包含逆序数对的个数51Nod1019)
归并排序是效率很好的排序方式,和快排效率一样高,但在稳定性上优于快排,下面我们来介绍归并排序. 归并排序运用递归将序列不断二分(其原理就是分治),就像一棵树不断向下分支,最后分到只剩一个元素,这样这个 ...
- pytorch安装及基本用法
20180425更新 安装pytorch0.4.0: conda uninstall pytorch # 如果是CUDA版本的话 conda uninstall cuda80 cuda90 # 如果 ...
- C++逐词读取txt
这一篇来写下std::ifstream读取txt的另一种方式,逐词读取,上一篇是按行读取,逐词读取的话每个单词都以空格或者换行等符号间隔开. 代码如下: #include "stdafx.h ...
- Python自学之路---Day13
目录 Python自学之路---Day13 常用的三个方法 匹配单个字符 边界匹配 数量匹配 逻辑与分组 编译正则表达式 其他方法 Python自学之路---Day13 常用的三个方法 1.re.ma ...
- CTF -bugku-misc(持续更新直到全部刷完)
1.签到题 点开可见.(这题就不浪费键盘了) CTF- 2.这是一张单纯的图片 图片保存到本地,老规矩,winhex看一看 拉到最后发现 因为做过ctf新手的密码 所以一看就知道unicode 百度站 ...
- Redis 在NETCore中的应用
Redis 在NETCore中的应用 Redis 在netFramework中的应用 也一样 新建.NETCORE(webapi)项目 安装NuGet //查询NuGet语句 Find-Packag ...
- Physicoochemical|CG content|
NCBI存在的问题: 数据用户的增长 软件开发受限 数据分析缺乏 有些传统束缚,仅用底层语言书写 Pangenome Open gene是随菌株数量增大而增大的gene,Closed gene是随菌株 ...
- D11 列表 list 元祖 字典dict
取值 name = "alexdfg" print(name[3:5]) 取出 ex name = "alexdfg" print(name[3]) 取出e 列 ...