2020-9-9

After your death, you’re sent to a mysterious room. There are two guardian cats and two doors, one goes to heaven of AC problems and another goes to hell NO. One cat likes all divisors of an integer a and the other cat likes all multiples of an integer b. You where asked to write all integers that satisfies both. If you answer correctly, you may go to heaven of AC problems, full of balloons, otherwise you’re sent to hell NO.

Input
The input consists of two integers a and b, where 1 ≤ b ≤ a ≤ 1012.

Output
The output consists of one line with all integers from smallest to largest that satisfies both guardian cats.

Examples
Input
12 3
Output
3 6 12
Input
10 3
Output
Input
128 2
Output
2 4 8 16 32 64 128
题目大意: 求a的公约数,又是b的倍数,从小到大排序输出
暴力跑一遍0-a肯定t;
思路:用在0-sqrt(a)中找到公约数i‘加入set集合,同时a/i也加入其中(原理就是比如16 2,4 ,28,44,,必定有除数对应)其实做完之后才发现,其实直接用数组存就行了,就是sqrt(a)那里得特判一下。没必要用set存再赋值给数组,草率了。

#include<iostream>
#include<algorithm>
#include<string.h>
#include<math.h>
#include<queue>
typedef long long ll;
#include<vector>
#include<set>
#include<list>
using namespace std;
int main()
{
ll a,b;
cin>>a>>b;
set<ll> gcd;
ll index=0;
for(ll i=1;i<=sqrt(a);i++)
{
   if( a %i==0)
   {
      gcd.insert(i);
      gcd.insert(a/i);

   }
}
ll c[100086];
int j=0;
set<ll>::iterator it;
    for(it=gcd.begin ();it!=gcd.end ();it++)
    {
        if(*it%b==0)
        {
          c[j++] =*it;
        }
    }
    sort(c,c+j);
    for(int i=0;i<j;i++)
    {
        cout<<c[i]<<" ";
    }
}

amuelo is a very good friend of Roppa. Whenever they feel bored, they like to exchange secret messages.

To do that, they craft some text in such a way so that the hidden message is a subsequence of it. To make things harder, they never use whitespaces.

An example of message exchanged in the past is (hidden message is red and underlined):

It can be very hard to uncover a message hidden like that, but it’s usually not a problem for them since their minds are pretty much in sync.

Samuelo just wrote one of those messages. Roppa decided to take a step further this time and test their friendship by trying to guess the hidden message before even receiving it.

Given the message that Samuelo wrote and Roppa’s guess, help Roppa on figuring out if his guess is in fact hidden in Samuelo’s message.

Input
The first line the input contains a string s (1≤|s|≤106), indicating the message that Samuelo wrote. The second line of the input contains a string (1≤|t|≤106), indicating Roppa’s guess.

Both strings are composed only of lowercase English letters.

Output
Output YES if Roppa’s guess is hidden in Samuelo’s message. Otherwise, output NO.

Examples
Input
threeyellowfurryfiends
hellofriend
Output
YES
Input
hardcontest
easyac
Output
NO
题目意思简洁明了
。。

#include<iostream>
#include<algorithm>
#include<string.h>
#include<math.h>
#include<queue>
typedef long long ll;
#include<vector>
#include<set>
#include<list>
using namespace std;
int main()
{
string a,b;
cin>>a;
cin>>b;
int j=0;
for(int i=0;i<a.length();i++)
{
    if( b[j]==a[i] )
    {
        j++;
    }
}
if( j!=b.length() )
{
    cout<<"NO";
}else{
cout<<"YES";
}
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值