判断能否被2、5整除怎么做

?基础算法小测1

\color{green}{AC核心}

if (num % 2 == 0 && num % 5 == 0) {
    cout << "2 5" << endl;
} else if (num % 2 == 0) {
    cout << "2" << endl;
} else if (num % 5 == 0) {
    cout << "5" << endl;
} else {
    cout << "no" << endl;
}

return 0;

if(a[a.length()-1] == ‘0’){
cout<<2<<" "<<5;
}else if(a[a.length()-1] == ‘5’){
cout<<5;
}else if(int(a[a.length()-1])%2 == 0){
cout<<2;
试过了,你那个55;
这个是AC核心

确定不是10的150次方?

哦哦哦

在座的有集训的吗

10^150次方,只关注末尾不就行了,是2,4,6,8就是被2整除,5就是被5整除,是0就是都能整除
关帖了