P1217只能过样例
  • 板块灌水区
  • 楼主Program_A2
  • 当前回复0
  • 已保存回复0
  • 发布时间2024/7/12 12:46
  • 上次更新2024/7/12 14:24:36
查看原帖
P1217只能过样例
1210103
Program_A2楼主2024/7/12 12:46

rt,本蒟蒻做一道普及−{\color{orange}普及-}的题目(我太菜了,这都不会),好多WA{\color{red}{WA}},甚至还有一个TLE,求助

代码:

#include <bits/stdc++.h>
using namespace std;
int main(){
	long long a,b,d=0;
	string c;
	cin>>a>>b;
	for(int i=a;i<=b;i++){
		c=to_string(i);
		if(c.length()%2==0){
			for(int l=0;l<=c.length()/2-1;l++){
	            if(c[l]==c[c.length()-1-l]){
					d+=2;
				}
			}
			if(c.length()==d){
				d=0;
				for(int l=2;l<i;l++){
					if(i%l==0){
						d+=1;
					}
				}
				if(d==0){
					cout<<c<<endl;
				}
				d=0;
			}
		}else{
			for(int l=0;l<c.length()/2;l++){
				if(c[l]==c[c.length()-1-l]){
					d+=2;
				}
			}
			if(c.length()-1==d){
				d=0;
			for(int l=2;l<i;l++){
				if(i%l==0){
					d+=1;
				}
			}
				if(d==0){
					cout<<c<<endl;
				}
				d=0;
			}
		}
	}
	return 0;
}
2024/7/12 12:46
加载中...