全WA求助(悬赏关注)
查看原帖
全WA求助(悬赏关注)
660871
2011Andy楼主2022/11/6 11:50

原本想刷水题

结果被水题刷了(QAQ)

dalao , 神犇 来纠错

code:

#include<bits/stdc++.h>
using namespace std;
bool is_prime(int x){
    if(x <= 1){
        return false;
    }
    for(int i = 2 ; i <= x / i ; i++){
        if(x % i == 0){
            return false;
        }
    }
    return true;
}
int main(){
    int m , n , s = 0 , cnt = 0;
    cin >> m >> n;
    for(int i = m ; i <= n ; i++){
    	if(is_prime(i)){
    		int a = i;
    		while(a != 0){
				s = s * 10 + a % 10;
				a = a / 10;
			}
			if(is_prime(s)){
				cout << i << ',';
				cnt++;
			}
		}
	}
	if(cnt = 0){
		cout << "No";
	}
    return 0;
}
2022/11/6 11:50
加载中...