70分救命啊啊啊

B2078 含 k 个 3 的数

duaneryan @ 2024-03-25 19:18:27

来人啊啊啊啊,救救我,谢大佬

#include<bits/stdc++.h>
using namespace std;
int m,k,sumn=0;
int main() {
    cin>>m>>k;
    while(m>=1){
        if(m%10==3){
            sumn++;
        }
        m=m/10;
    }
    if(sumn==k){
        cout<<"YES";
    }
    else{
        cout<<"NO";
    }
}

想的是数位拆分,麻烦看看


by zhouzihang1 @ 2024-03-25 19:20:51

@duaneryan 1 < n \le 10^{15} 所以要开 long long


by Ravener @ 2024-03-25 19:27:34

要开long long
其实也不是不可以用string


by lyq123bc @ 2024-03-25 19:48:05

@duaneryan

#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
ll m,k,sumn=0;

int main()
{
    cin>>m>>k;
    while(m>=1)
    {
        if(m%10==3)
        {
            sumn++;
        }
        m/=10;
    }
    if(sumn==k)
    {
        cout<<"YES";
    }
    else
    {
        cout<<"NO";
    }

    return 0;
}

拿去吧


by duaneryan @ 2024-03-25 20:21:10

@lyq123bc ```cpp

ll m,k,sumn=0;



这里的ll是long long的缩写吗

by duaneryan @ 2024-03-25 20:24:16

@zhouzihang1 谢谢大佬(喜)


by duaneryan @ 2024-03-25 20:25:17

@Ravener 真的诶,谢谢(牢大)大佬


by zhouzihang1 @ 2024-03-25 20:26:12

@duaneryan

typedef long long ll;

这句话的意思是把所有的 ll 看成 long long 编译


|