CF 299A Ksusha and Array

给一个数组,输出一个数,这个数:

Each test print a single integer — the number from the array, such that all array elements are divisible by it. If such number doesn't exist, print -1.

刚开始想的有点复杂,后来慢慢知道这个数要从数组中找,那么……  肯定是最小的那个拉! 当然还不一定能成功……  再检测一下……  


#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define N 10000000
int t,n;
long long num[100005];
int main()
{
   

    while(cin>>n)
    {
        long long  min=1000000009;
        for(int i=0;i<n;++i)
        {
           cin>>num[i];
            min=(min>num[i]?num[i]:min);
        }
        bool bo=true;
        for(int i=0;i<n;++i)
        {
            if(num[i]%min)
            {
                bo=false;
                break;
            }
        }
        if(bo)cout<<min<<endl;
        else cout<<-1<<endl;

    }
    return 0;
}



下面这个题也是水题,但也要总结一下,因为他是英文版的,读了好几遍才看明白题意!

Roma (a popular Russian name that means 'Roman') loves the Little Lvov Elephant's lucky numbers.

Let us remind you that lucky numbers are positive integers whose decimal representation only contains lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.

Roma's got n positive integers. He wonders, how many of those integers have not more than k lucky digits? Help him, write the program that solves the problem.


题目大意:love   lucky numbers.  然后对所给的数中看看有几个满足要求,什么要求?   how many of those integers have not more than k lucky digits?

有多少个数含有不超过k位的lucky    关键是这个digits!




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值