博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Educational Codeforces Round 36 (Rated for Div. 2)
阅读量:6829 次
发布时间:2019-06-26

本文共 6681 字,大约阅读时间需要 22 分钟。

A. Garden
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Luba thinks about watering her garden. The garden can be represented as a segment of length k. Luba has got n buckets, the i-th bucket allows her to water some continuous subsegment of garden of length exactly ai each hour. Luba can't water any parts of the garden that were already watered, also she can't water the ground outside the garden.

Luba has to choose one of the buckets in order to water the garden as fast as possible (as mentioned above, each hour she will water some continuous subsegment of length ai if she chooses the i-th bucket). Help her to determine the minimum number of hours she has to spend watering the garden. It is guaranteed that Luba can always choose a bucket so it is possible water the garden.

See the examples for better understanding.

Input

The first line of input contains two integer numbers n and k (1 ≤ n, k ≤ 100) — the number of buckets and the length of the garden, respectively.

The second line of input contains n integer numbers ai (1 ≤ ai ≤ 100) — the length of the segment that can be watered by the i-th bucket in one hour.

It is guaranteed that there is at least one bucket such that it is possible to water the garden in integer number of hours using only this bucket.

Output

Print one integer number — the minimum number of hours required to water the garden.

Examples
input
Copy
3 6 2 3 5
output
2
input
Copy
6 7 1 2 3 4 5 6
output
7
Note

In the first test the best option is to choose the bucket that allows to water the segment of length 3. We can't choose the bucket that allows to water the segment of length 5 because then we can't water the whole garden.

In the second test we can choose only the bucket that allows us to water the segment of length 1.

 

 k能整除当前数的时候,找出那个最大的倍数

#include 
using namespace std;int a[105];int main(){ int n,k,f=1; cin>>n>>k; for(int i=0,x;i
>x; if(k%x==0&&x>f)f=x; } cout<
B. Browser
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Luba is surfing the Internet. She currently has n opened tabs in her browser, indexed from 1 to n from left to right. The mouse cursor is currently located at the pos-th tab. Luba needs to use the tabs with indices from l to r (inclusive) for her studies, and she wants to close all the tabs that don't belong to this segment as fast as possible.

Each second Luba can either try moving the cursor to the left or to the right (if the cursor is currently at the tab i, then she can move it to the tab max(i - 1, a) or to the tab min(i + 1, b)) or try closing all the tabs to the left or to the right of the cursor (if the cursor is currently at the tab i, she can close all the tabs with indices from segment [a, i - 1] or from segment [i + 1, b]). In the aforementioned expressions a and b denote the minimum and maximum index of an unclosed tab, respectively. For example, if there were 7 tabs initially and tabs 1, 2 and 7are closed, then a = 3, b = 6.

What is the minimum number of seconds Luba has to spend in order to leave only the tabs with initial indices from l to r inclusiveopened?

Input

The only line of input contains four integer numbers nposlr (1 ≤ n ≤ 100, 1 ≤ pos ≤ n1 ≤ l ≤ r ≤ n) — the number of the tabs, the cursor position and the segment which Luba needs to leave opened.

Output

Print one integer equal to the minimum number of seconds required to close all the tabs outside the segment [l, r].

Examples
input
Copy
6 3 2 4
output
5
input
Copy
6 3 1 3
output
1
input
Copy
5 2 1 5
output
0
Note

In the first test Luba can do the following operations: shift the mouse cursor to the tab 2, close all the tabs to the left of it, shift the mouse cursor to the tab 3, then to the tab 4, and then close all the tabs to the right of it.

In the second test she only needs to close all the tabs to the right of the current position of the cursor.

In the third test Luba doesn't need to do anything.

 

给你n pos l r,分别代表几个网页,你现在在第几个网页,你需要关闭l左边的网页,和r右边的网页,你可以移到一个网页把之前或之后的关闭,问你最少走几步

那么我枚举到l r的距离即可分别选择先向左还是先向右

#include 
using namespace std;int main(){ int n,pos,l,r,f=0; cin>>n>>pos>>l>>r; if(l==1&&r==n) f=0; else if(l==1) f=abs(pos-r)+1; else if(r==n) f=abs(pos-l)+1; else { if(pos
r) f=pos-l+2; else f=min(pos-l,r-pos)+r-l+2; } cout<
C. Permute Digits
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

You are given two positive integer numbers a and b. Permute (change order) of the digits of a to construct maximal number not exceeding b. No number in input and/or output can start with the digit 0.

It is allowed to leave a as it is.

Input

The first line contains integer a (1 ≤ a ≤ 1018). The second line contains integer b (1 ≤ b ≤ 1018). Numbers don't have leading zeroes. It is guaranteed that answer exists.

Output

Print the maximum possible number that is a permutation of digits of a and is not greater than b. The answer can't have any leading zeroes. It is guaranteed that the answer exists.

The number in the output should have exactly the same length as number a. It should be a permutation of digits of a.

Examples
input
Copy
123 222
output
213
input
Copy
3921 10000
output
9321
input
Copy
4940 5000
output
4940

 

 给你一个数x和n,你可以把m随意更改顺序构造不大于n的最大的数

当时我错的条件就是等于

#include 
using namespace std;string s,c;int cmp(char x,char y){ return x>y;}long long ans=1,b;void dfs(int f,long long x,string a){ if(c[f]) { long long x1=x; string bb=a; int mi=48,mif=-1,maf=-1; for(int i=0; a[i]; i++) if(a[i]==c[f])maf=i; else if(a[i]
=mi)mif=i,mi=a[i]; if(mif!=-1) { if(f==0&&a[mif]=='0') { } else { x=x*10+a[mif]-'0'; a[mif]=47; sort(a.begin(),a.end(),cmp); for(int i=0;i<(int)a.size()-f-1;i++) x=x*10+a[i]-'0'; if(x<=b)ans=max(ans,x); } } if(maf!=-1) { x1=x1*10+bb[maf]-'0'; bb[maf]=47; dfs(f+1,x1,bb); } } else { if(x<=b)ans=max(ans,x); return; }}int main(){ long long a; cin>>a>>b; stringstream ss; ss<

 

转载于:https://www.cnblogs.com/BobHuang/p/8480637.html

你可能感兴趣的文章
[转载]jquery 动态滚动
查看>>
POJ 3415 Common Substrings
查看>>
The run destination iPhone 5.0 Simulator is not valid for running the scheme 'MyApp'
查看>>
【C#】在父窗体菜单合并子窗体菜单
查看>>
反射(6)程序集加载上下文
查看>>
oracle触发器after update of |更改之后赋值|
查看>>
Oracle命令:授权-收回权限-角色-用户状态
查看>>
常用的Ubuntu APT命令参数
查看>>
成功加盟者的8个特点
查看>>
Java基础03 构造器与方法重载
查看>>
如何让你的服务屏蔽Shodan扫描
查看>>
SpringBoot+Elasticsearch
查看>>
Vim 操作符命令和动作命令
查看>>
动态代理
查看>>
C语言 格式化输出--%m.n
查看>>
gradle配置国内的镜像
查看>>
Gitlab安装与备份恢复
查看>>
LeetCode: Recover Binary Search Tree 解题报告
查看>>
艾伟_转载:把委托说透(2):深入理解委托
查看>>
通用权限管理系统组件 (GPM - General Permissions Manager) 中实现高性能的ASP.NET管理页面自动生成...
查看>>