http://codeforces.com/contest/1029/problem/D You are given an array aa, consisting of nn positive integers. Let's call a concatenation of numbers xx and yy the number that is obtained by writing down numbers xx and yy one right after another without…
D. Concatenated Multiples You are given an array aa, consisting of nn positive integers. Let's call a concatenation of numbers xx and yy the number that is obtained by writing down numbers xx and yy one right after another without changing the order.…
题意: 给定n个数字,和一个模数k,从中选出两个数,直接拼接,问拼接成的数字是k的倍数的组合有多少个. 思路: 对于a,b两个数,假定len = length of (b),那么a,b满足条件就是a * (len个10) + b 是k的倍数,相当于a * (len个10)% k + b % k = k: 那么我们可以预处理出每个数字%k的结果,用map计数.然后枚举每个数字,每个数字都有10种可能,因为len最大为10.每一次查找map中的数字要用find函数,不要用[]运算,find是二分,…
思路:直接离线处理出每个ai 的10倍, 100倍, 1000倍的mod k 后的数值的个数,使用map<int,int >ss[12]存储, ss[x][y]表示 (ai*10x)%k=y的个数,最后处理一下,自己拼接自己的情况. #include<iostream> #include<cmath> #include<map> using namespace std; #define LL long long ; int n, m, a[maxn]; ma…