题解 | 小红的k次方

小红的k次方

https://www.nowcoder.com/practice/05e92542a6ac4d6fbda993996e63fbc0

#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using ld = long double;
using PII=pair<ll,ll>;
using PIII=pair<int,pair<int,int>>;
const ld ESP = 1e-10;
const ld PI = acosl(-1);
const int N=1e5+10;
const int M=2e5+10;
// const int mod = 1000000007;
const int mod = 998244353;
//随机化
random_device rd;
mt19937 gen(rd());
uniform_int_distribution<> dis(1, 1000000000);
// cout<<fixed<<setprecision(10);
ll qmi(ll a,ll b){
    ll res=1;
    while(b){
        if(b&1)res=a*res;
        a=a*a;
        b>>=1;
    }
    return res;
}
void solve(){
    int n;
    cin>>n;
    int c2=0,c3=0,c5=0;
    for(int i=1;i<=n;i++){
        ll x;
        cin>>x;
        while(x%2==0){
            c2++;
            x/=2;
        }while(x%3==0){
            c3++;
            x/=3;
        }while(x%5==0){
            c5++;
            x/=5;
        }
    }
    cout<<min({c2,c3,c5})<<'\n';
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int _=1;
    // cin>>_;
    while(_--){
        solve();
    }
    return 0;
}

全部评论

相关推荐

牛客93169152...:可以发邮件,我停了三天没收到链接,发邮件问了一下,十分钟后就有了
点赞 评论 收藏
分享
03-19 09:58
河海大学 Java
最喜欢春天的奇亚籽很...:同学,是小红书不是小哄书,一眼就能看到的错误
投了多少份简历才上岸
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务