链接:https://ac.nowcoder.com/acm/contest/338/E
来源:牛客网

Zghh likes number, but he doesn't like writing problem description. So he will just give you a problem instead of telling a long story for it.
Now given a positive integer x and k digits a1,a2,...,ak, can you find a positive integer y such that y is the multiple of x and in decimal representation y contains all digits of a1,a2,...,ak.

输入描述:

The first line contains an integer T (1<=T<=10000) which is the number of test case.The following T lines each line is a test case, start with two integer x (1<=x<=1e8) and k (1<=k<=10), k integer a1,a2,..,ak (0<=ai<=9 for i=1..k and ai!=aj for i!=j) is following.

输出描述:

For each test case output your answer y. Your answer should be a positive integer without leading zero and should be no more than 1e18. Every answer that satisfy the conditions descripted above will be accepted.
示例1

输入

复制

3
5 3 1 5 7
21 4 2 5 6 9
10 9 0 1 2 3 4 5 6 7 9

输出

复制

175
2592576
976543210

说明

175 is the multiple of 5 and contains 1,5,7

2592576 is the multiple of 21 and contains 2,5,6,9

976543210 is the multiple of 10 and contains 0,1,2,3,4,5,6,7,9

备注:

Constraint of data

1<=T<=10000

1<=x<=1e8

1<=k<=10

0<=ai<=9,for i=1..k

ai!=aj for i!=j

your answer y should satisfy y <= 1e18

读懂题
题意•
找一个数(<=1e18),包含a1,a2,…,ak且是x的倍数。(<=ai<=,x<=1e8)
题解•
令N=
• ) N%x== , ans = N
• ) N%x!=, ans = N+(x-N%x)
• 那么显然对于x<=1e8, ans包含0到9且ans是x的倍

 
#include <stdio.h>

long long n = 123456789000000000LL;

int main()
{
int T,k,t,r;
char buf[111];
scanf("%d",&T);
getchar();
while(fgets(buf,100,stdin))
{
sscanf(buf,"%d",&k);
r = n % k;
t = k - r;
printf("%lld\n",n+t);
}
return 0;
}
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <bitset>
using namespace std; #define LL long long
const int maxn = 20;
int T;
LL x, k, ans;
int num[maxn]; int main()
{
#ifdef Dmaxiya
freopen("test.txt", "r", stdin);
#endif // Dmaxiya
ios::sync_with_stdio(false); scanf("%d", &T);
while(T--)
{
ans = 987654321000000000LL;
scanf("%lld%lld", &x, &k);
for(int i = 0; i < k; ++i)
{
scanf("%d", &num[i]);
}
printf("%lld\n", ans + (x - ans % x));
} return 0;
}

E Easy problem的更多相关文章

  1. UVA-11991 Easy Problem from Rujia Liu?

    Problem E Easy Problem from Rujia Liu? Though Rujia Liu usually sets hard problems for contests (for ...

  2. An easy problem

    An easy problem Time Limit:3000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Sub ...

  3. UVa 11991:Easy Problem from Rujia Liu?(STL练习,map+vector)

    Easy Problem from Rujia Liu? Though Rujia Liu usually sets hard problems for contests (for example, ...

  4. POJ 2826 An Easy Problem?!

    An Easy Problem?! Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7837   Accepted: 1145 ...

  5. hdu 5475 An easy problem(暴力 || 线段树区间单点更新)

    http://acm.hdu.edu.cn/showproblem.php?pid=5475 An easy problem Time Limit: 8000/5000 MS (Java/Others ...

  6. 【暑假】[实用数据结构]UVa11991 Easy Problem from Rujia Liu?

    UVa11991 Easy Problem from Rujia Liu?  思路:  构造数组data,使满足data[v][k]为第k个v的下标.因为不是每一个整数都会出现因此用到map,又因为每 ...

  7. HDU 5475 An easy problem 线段树

    An easy problem Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pi ...

  8. UVA 11991 Easy Problem from Rujia Liu?(vector map)

    Easy Problem from Rujia Liu? Though Rujia Liu usually sets hard problems for contests (for example, ...

  9. 数据结构(主席树):HDU 4729 An Easy Problem for Elfness

    An Easy Problem for Elfness Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 65535/65535 K (J ...

  10. HDOJ(HDU) 2132 An easy problem

    Problem Description We once did a lot of recursional problem . I think some of them is easy for you ...

随机推荐

  1. hdu4417 Super Mario (树状数组/分块/主席树)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4417 题目大意:给定一个长度为n的序列,有m个询问,每次询问包含l,r,h,即询问区间[l,r]小于等 ...

  2. jmeter中遇见的坑:url需要编码的

    在postman中能请求成功,但是在jmeter就是请求失败报500错. 请求的 url  :/graph/vertices?label=node&properties={"num& ...

  3. 在Node.js环境下使用Express创建Web项目实例

    序:如果你还不知道Node.js是什么,那么你可以先看看这篇:Node.js 究竟是什么?或者任何关于它的介绍. 一.安装Node.js 1.进入Node.js官网下载并安装 2.启动cmd输入命令查 ...

  4. Flask 之装饰器有关

    - 先记住一句话:自定义python装饰器时一定要记住使用@functools.wraps(func)修饰wrapper - 在Flask中使用装饰器遇到AssertionError: View fu ...

  5. LINUX的一些基本概念和操作

    LINUX和shell的关系: linux是核,是操作系统,用于分配软硬件资源,用于支持运行环境,shell是壳,是命令解析器. linux命令: linux命令行有一个输入输出的行为,输入命令,输出 ...

  6. [CSP-S模拟测试]:太阳神(莫比乌斯反演)

    题目描述 太阳神拉很喜欢最小公倍数,有一天他想到了一个关于最小公倍数的题目.求满足如下条件的数对$(a,b)$对数:$a,b$均为正整数且$a,b\leqslant n$而$lcm(a,b)>n ...

  7. [CSP-S模拟测试]:数论(数学)

    题目传送门(内部题11) 输入格式 第一行,三个整数$T,K,M$,分别代表数据组数.良好标准和整数范围.接下来$T$行,每行一个整数$n_i$,代表一个询问. 输出格式 输出$T$行,在第$i$行对 ...

  8. vue鼠标修饰符

    鼠标左键事件 <div @click.left="mouseClick" style="border: solid 1px red; width:500px; he ...

  9. 简单了解winform

    WinForm是·Net开发平台中对Windows Form的一种称谓. Windows窗体可用于设计窗体和可视控件,以创建丰富的基于Windows的窗体应用程序.可以访问数据库中的数据,并在窗体上显 ...

  10. sysbench - 数据库功能及性能测试工具

    sysbench 的 GitHub 参考资料 1.0 之后的版本使用方法跟之前的有所区别,下面所有内容基于 1.0.9 版本. 另外,为了方便管理测试,最好不要通过命令直接运行测试,而是写成脚本自动化 ...