50分求助

B2078 含 k 个 3 的数

Luochenhao88 @ 2024-11-26 20:48:37

#include <bits/stdc++.h>
using namespace std;
long long int m,k,a=0;
int main(){
    cin>>m>>k;
    for(int i=1;i<=k;i++){
        if(m%3==0){
            m=m/3;
            a++;
        }else{
            i+=100;
        }
    }
    if(m%3==0){
        a=0;
    }
    if(a==1){
        cout<<"YES";
    }else{
        cout<<"NO";
    }
    return 0;
}

by iranai @ 2024-11-26 20:54:16

@Luochenhao88

#include<bits/stdc++.h>
using namespace std;
long long n;
int sum,k;
int main(){
    cin>>n>>k;
    while(n!=0){
        if(n%10==3) sum++;
        n/=10;
    }
    if(sum==k) printf("YES");
    else printf("NO");
    return 0;
}

by Luochenhao88 @ 2024-11-26 21:12:58

@iranai谢谢


|