奇异问题
  • 板块P1112 波浪数
  • 楼主cokkie
  • 当前回复2
  • 已保存回复2
  • 发布时间2023/11/24 23:53
  • 上次更新2023/11/25 10:13:31
查看原帖
奇异问题
695025
cokkie楼主2023/11/24 23:53

变量j的值莫名变化(把样例喂进去可以看出)

里面可能有一些调试代码

#include<bits/stdc++.h>
using namespace std;
int l,r,L,R,k,a[50]; 
int main(){
	cin >> l >> r >> L >> R >> k;
	for(int i=L;i<=R;i++){
		int cnt=0,p=i,si=0;
		for(int j=l;j<=r;j++){
			while(p){
				a[++si]=p%j;
				p/=j;
			}
			bool flag=1;
			for(int p=1;p<=si-2;p++){
				if(a[p]!=a[p+2]){
					flag=0;
					break;
				} 
			}
			if(flag) cnt++;
			//if(cnt>=k)break;
		}
		if(cnt>=k){
			cout << i << endl;
			for(int j=1;j<=si;j++) cout << a[j] << " ";
			cout << endl;
		}
	}
	return 0; 
}

2023/11/24 23:53
加载中...