E Easy problem
链接:https://ac.nowcoder.com/acm/contest/338/E
来源:牛客网
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.
备注:
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的更多相关文章
- UVA-11991 Easy Problem from Rujia Liu?
Problem E Easy Problem from Rujia Liu? Though Rujia Liu usually sets hard problems for contests (for ...
- An easy problem
An easy problem Time Limit:3000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Sub ...
- 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, ...
- POJ 2826 An Easy Problem?!
An Easy Problem?! Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7837 Accepted: 1145 ...
- hdu 5475 An easy problem(暴力 || 线段树区间单点更新)
http://acm.hdu.edu.cn/showproblem.php?pid=5475 An easy problem Time Limit: 8000/5000 MS (Java/Others ...
- 【暑假】[实用数据结构]UVa11991 Easy Problem from Rujia Liu?
UVa11991 Easy Problem from Rujia Liu? 思路: 构造数组data,使满足data[v][k]为第k个v的下标.因为不是每一个整数都会出现因此用到map,又因为每 ...
- HDU 5475 An easy problem 线段树
An easy problem Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pi ...
- 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, ...
- 数据结构(主席树):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 ...
- 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 ...
随机推荐
- 237-基于Xilinx Kintex-7 XC7K325T 的FMC/千兆以太网/SATA/四路光纤数据转发卡
基于Xilinx Kintex-7 XC7K325T 的FMC/千兆以太网/SATA/四路光纤数据转发卡 一. 板卡概述 本板卡基于Xilinx公司的FPGAXC7K325T-2FFG900 芯片, ...
- Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) - C
题目链接:http://codeforces.com/contest/831/problem/C 题意:给定k个评委,n个中间结果. 假设参赛者初始分数为x,按顺序累加这k个评委的给分后得到k个结果, ...
- JMETER - BEANSHELL获取响应结果
获取响应结果 添加后置处理器 //获取获取请求的返回值 String response = prev.getResponseDataAsString(); //日志打印获取请求的返回值 log ...
- (NOIP)CSP-S 2019前计划
前言 无 1.NOIP原题板刷 NOIP原题板刷 这是一篇咕了的blog 2.牛客 & ACwing & 洛谷 网课学习 收获还是蛮大的,不过我没有写博客 3.codeforces专项 ...
- 【容器化】容器技术实践.pdf_视频学习笔记
容器运行时 docker rkt gvisor containerd 容器编排系统:kubernetes (简称k8s)
- 爬虫技术:数据处理josn和pickle模块
一:json模块 json模块的作用就是讲json字符串("{"a":1,"b":1}")和python能够识别的字典进行相互转换. imp ...
- pandas.Series函数用法
class pandas.Series(data=None, index=None, dtype=None, name=None, copy=False, fastpath=False) e.g., ...
- 034:DTL常用过滤器(3)
default过滤器: 如果值被评估为 False .比如 [] , "" , None , {} 等这些在 if 判断中为 False 的值,都会使用 default 过滤器提供 ...
- 对Proxy的研究
概述 Proxy 用于修改某些操作的默认行为,等同于在语言层面做出修改,所以属于一种“元编程”(meta programming),即对编程语言进行编程. Proxy 可以理解成,在目标对象之前架设一 ...
- OC + RAC (五) RACMulticastConnection
-(void)_test5{ //弊端:有几个订阅者就会请求几次数据 // 1.创建信号 RACSignal *signal = [RACSignal createSignal:^RACDisposa ...