链接: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. openstack stein部署手册 9. neutron

    # 安装程序包 yum -y install openstack-neutron-linuxbridge ebtables ipset # 变更配置文件 mv /etc/neutron/neutron ...

  2. Mysql查询结果导出Excel表

    Mysql查询结果导出Excel表: 一句转换方式:$ mysql -uops -p'GCNgH000KP' dtbs -e 'select * from t_proxy__record;' --de ...

  3. 【爬虫】Selenium+chrome

    一.下载对应chrome版本的webdriver https://npm.taobao.org/mirrors/chromedriver 二.pom <dependency> <gr ...

  4. 基于Redis实现简单的分布式锁【理论】

    摘要 分布式锁在很多应用场景下是非常有效的手段,比如当运行在多个机器上的不同进程需要访问同一个竞争资源的时候,那么就会涉及到进程对资源的加锁和释放,这样才能保证数据的安全访问.分布式锁实现的方案有很多 ...

  5. windows下laravel 快速安装

    1. 安装composer  https://getcomposer.org/ 2. 安装git windows 客户端工具 https://git-scm.com/downloads 3. 更改co ...

  6. fiddler常见问题

    捕获https: tools>options https>decrypt https traffic :安装证书捕获客户端请求: tools>options connections& ...

  7. django 我的博客 (慕课网视频)笔记

    用到的命令 1.创建项目 django-admin startproject myBlog 2.创建appcd [项目名] python3 manage.py startapp blog 3.数据迁移 ...

  8. CKEditor粘贴图片上传功能

    很多时候我们用一些管理系统的时候,发布新闻.公告等文字类信息时,希望能很快的将word里面的内容直接粘贴到富文本编辑器里面,然后发布出来.减少排版复杂的工作量. 下面是借用百度doc 来快速实现这个w ...

  9. [IOI2018] meetings 会议

    https://www.luogu.org/problemnew/show/P5044 题解 这种关于最大值或者最小值的问题,可以往笛卡尔树的方面想. 先考虑一个朴素的\(dp\),设\(dp[l][ ...

  10. 晋江年下文爬取【xpath】

    ''' @Modify Time @Author 目标:晋江年下文 爬取6页 ------------ ------- http://www.jjwxc.net/search.php?kw=%C4%E ...