3773. 兔子跳

https://www.acwing.com/problem/content/3776/

这个注意是二维的,因此可以跳等腰三角形

#include<iostream>
using namespace std;
int main()
{
    
    
    int T,n,x;
    cin>>T;
    while(T--)
    {
    
    
        int t,a=0;
        int f=0;
        cin>>n>>x;
        while(n--)
        {
    
    
            cin>>t;
            if(t==x) f=1;
            a=max(a,t);
        }
        if(f) cout<<"1\n";
        else if(x<a) cout<<"2\n";
        else cout<<(x+a-1)/a<<"\n";
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/weixin_52341477/article/details/121172059