__F__ @ 2024-07-16 14:52:06
40分代码
#include<bits/stdc++.h>
using namespace std;
int main(){
int m,k,s=0;
cin>>m>>k;
int t=m;
while(t!=0){
if(t%10==3){
s++;
}
t=t/10;
}
if(s==k&&m%19==0)
{
cout<<"YES";
}else{
cout<<"NO";
}
return 0;
}
by rain_wu @ 2024-07-16 15:01:41
题目上说是10^15,而int最大值是2^31-1,也就是2147483647,2147483647<1000000000000000,那么就要开long long。
by 枫原万叶 @ 2024-07-16 15:18:10
@ yuhan09
怎么说你也用不了long long。
最多弄成这样70分,把判断条件改一下。
#include <bits/stdc++.h>
using namespace std;
int main() {
long long m, k, s = 0;
cin >> m >> k;
int t = m;
while (t != 0) {
if (t % 10 == 3) {
s++;
}
t = t / 10;
}
if (s == k) {
cout << "YES";
} else {
cout << "NO";
}
return 0;
}
还是需要用字符串才行。
#include <bits/stdc++.h>
using namespace std;
int main() {
string m;
int k;
cin >> m;
cin >> k;
for (int i = 0; i < m.size(); i++) {
if (m[i] == '3')
k--;
}
if (k == 0)
cout << "YES";
else
cout << "NO";
return 0;
}
这样就可以了
by Z_Zh @ 2024-07-16 15:22:03
@yuhan09 long long
using namespace std; const int N=1e6+10; int main(){ long long n,s=0,a,b,c,m,k; cin>>m>>k; while(m!=0){ a=m%10;m/=10; if(a==3) s++;
}
if(s==k){
cout<<"YES";
return 0;
}
else {
cout<<"NO";
}
return 0;
}
by playing_game @ 2024-07-16 16:08:45
@yuhan09 sdsdgg
by fangyuhan01 @ 2024-07-19 21:07:39
不是吧,你是另一个oj复制过来的吧
by fangyuhan01 @ 2024-07-19 21:09:51
题目没要求m要被19整除,把“&&m%19==0”删掉
by fangyuhan01 @ 2024-07-19 21:10:52
还要开
long long
by aaaaaa238 @ 2024-07-20 19:04:09
事实证明,不开long long他的确得见祖宗啊!接下来呈上我的AC 代码
#include <bits/stdc++.h>
using namespace std;
unsigned long long a;
int b;
bool jc(unsigned long long x, int y){
int cnt = 0;
while(x){
int cxk = x % 10;
if(cxk == 3) cnt++;
x /= 10;
}
if(cnt == y) return true;
return false;
}
int main(){
cin >> a >> b;
if(jc(a, b)) cout << "YES" << endl;
else cout << "NO" << endl;
return 0;
}