B3978求调
  • 板块题目总版
  • 楼主jamie999
  • 当前回复0
  • 已保存回复0
  • 发布时间2025/1/22 23:11
  • 上次更新2025/1/23 10:28:08
查看原帖
B3978求调
1350295
jamie999楼主2025/1/22 23:11
#include <bits/stdc++.h>
using namespace std;
#define  pii  pair<int,int>
#define next next_permutation
const double pi=3.14159;
#define priority_queue pq
#define ull unsigned long long
const ull base=131;
const ull MOD=1e9+7;
const ull maxn=1000005;
const ull INF=1000000000;
using namespace std;
bool runnian(int x){
	if(x%4==0){
		if(x%100==0){
			if(x%400==0){
				return true;
			}
			else{
				return false;
			}
		}
		else{
			return true;
		}
	}
	else{
		return false;
	}
}
bool isprime(int x){
	if(x==1||x<=0){
		return false;
	}
	for(int i=2;i*i<=x;i++){
		if(x%i==0){
			return false;
		}
	}
	return true;
}
ull hashh(string s){
	ull hashhhh=0;
	for(int i=0;i<s.size();i++){
		hashhhh=(s[i]+hashhhh*base)%MOD;
	}
	return hashhhh;
}
int gcd(int a,int b){
	if(a%b==0){
		return b;
	}
	return gcd(b,a%b);
}
int a,b;
int ans;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>a>>b;
	for(int i=a;i<=b;i++){
		bool flag=true;
		int sjz=i;
		string ejz=0;
		while(1){
			if(sjz==0){
				break;
			}
//			ejz*=10;
			ejz+=(sjz%2)+'0';
			sjz/=2;
		}
		for(int i=0;i<ejz.size();i++){
			if(ejz[i]!=ejz[i+1]&&ejz[i]!=ejz[i-1]){
				flag=false;
				break;
			}
		}
		if(flag!=false){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

编译过后输出:“

terminate called after throwing an instance of 'std::logic_error'
  what():  basic_string::_S_construct null not valid

求调

2025/1/22 23:11
加载中...