- 含k个3的数
对了9个,哪错了?
- 2023-12-13 20:20:49 @
~~~#include <bits/stdc++.h>
using namespace std;
int main()
{ long long m,k,c=0,d,z;
cin>>m>>k;
z=m;
while(z>0){
d=z%10;
z/=10;
if(d==3)c++;
}
if(c==k||m%19==0)cout<<"YES";
else if(c!=k&&m%19!=0)cout<<"NO";
return 0;
}
3 comments
-
Csvoner SU @ 2024-11-27 19:31:28Edited
你没有判断
n % 19 == 0
-
2023-12-13 20:36:01@
你那个有点麻烦,应该废了
-
2023-12-13 20:34:36@
#include <bits/stdc++.h> using namespace std; int main() { int m,k,n=0,a; cin >> m >> k; if(m%19==0) { while (m!=0) { a=m%10; if(a==3) n++; m=m/10; } if(n==k) cout << "YES" << endl; } else cout << "NO" << endl; return 0; }
- 1
Information
- ID
- 584
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 4
- Tags
- (None)
- # Submissions
- 226
- Accepted
- 106
- Uploaded By