why TLE on #10
  • 板块P1112 波浪数
  • 楼主MuLinnnnn
  • 当前回复1
  • 已保存回复1
  • 发布时间2023/11/15 21:05
  • 上次更新2023/11/15 22:24:15
查看原帖
why TLE on #10
757040
MuLinnnnn楼主2023/11/15 21:05

同标题。

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>
typedef long long ll;
#define endl '\n'
using namespace std;
map<ll, ll> mp;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	ll l, r, L, R, c;
	cin >> l >> r >> L >> R >> c;
	for(ll k = l; k <= r; ++k){
		for(ll i = 1; i < k; ++i){
			for(ll j = 0; j < k; ++j){
				if(i != j){
					ll num = 0;
					ll tmp = 0;
					while(num <= R){
						if(tmp & 1){
							num *= k;
							num += j;
							++tmp;
						}else{
							num *= k;
							num += i;
							++tmp;
						}
						if(num >= L && num <= R){
							mp[num]++;
						}
					}
				}
			}
		}
	}
	for(ll i = L; i <= R; ++i){
		if(mp[i] == c){
			cout << i << endl;
		}
	}
	return 0;
}

2023/11/15 21:05
加载中...