CF 286B(Shifting-deque)

本文探讨了递归排列的概念,通过逐步操作实现特定序列的生成,并提供了算法实现的详细步骤。
B. Shifting
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

John Doe has found the beautiful permutation formula.

Let's take permutation p = p1, p2, ..., pn. Let's define transformation f of this permutation:

 k (k > 1) 是每段长度, r 是最大满足 rk ≤ 的整数  把 r 段和尾剩余部分(如果有)左移.

求序列 f(f( ... f(p = [1, 2, ..., n], 2) ... , n - 1), n) .

Input

一行 n (2 ≤ n ≤ 106).

Output

Print n distinct space-separated integers from 1 to n — a beautiful permutation of size n.

Sample test(s)
input
2
output
2 1 
input
3
output
1 3 2 
input
4
output
4 2 3 1 
Note

A note to the third test sample:

  • f([1, 2, 3, 4], 2) = [2, 1, 4, 3]
  • f([2, 1, 4, 3], 3) = [1, 4, 2, 3]
  • f([1, 4, 2, 3], 4) = [4, 2, 3, 1]


这题我是用WJMZBMR的神模拟过的。

先普及一下deque< >
deque<int> deq;   //建立双端队列
deq.push_back(x) 
deq.push_front(x) 
deq.pop_back(x) 
deq.pop_back(x) 
然后可以模拟了,每次把每段的最后搬上来。
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<queue>
using namespace std;
#define MAXN (1000000+10)
deque<int> deq;
int n;
int main()
{
	cin>>n;
	for (int i=1;i<=n;i++) deq.push_back(i);
	for (int i=2;i<=n;i++)
	{
		int l=(n-1)/i*i;deq.push_back(deq[l]);
		while (l-i>=0)		
		{
			deq[l]=deq[l-i];
			l-=i;
		}
		deq.pop_front();		
	}	
	for (int i=0;i<deq.size();i++) cout<<deq[i]<<' ';
	return 0;
}





关于Shape-from-Shifting技术的信息,在当前提供的参考资料中并未涉及相关内容[^1]。然而,基于专业知识库可以提供一些基础解释。 ### Shape-from-Shifting 技术概述 Shape-from-Shifting是一种用于计算机视觉领域中的三维重建方法之一。该技术主要依赖于物体表面反射特性变化来推断形状信息。具体来说,当光照条件改变时,观察到的目标物体会显示出不同的外观特征;通过对这些不同状态下图像序列的捕捉与分析,能够提取出有关目标几何结构的数据。 此过程通常涉及到以下几个方面: - **多视角成像**:利用多个摄像机从不同角度拍摄同一场景下的对象。 - **动态照明环境模拟**:创建可变光源设置以获取丰富的光影效果样本集。 - **算法建模**:开发特定数学模型处理采集来的数据并最终重构出精确度较高的3D模型。 值得注意的是,这项技术的应用范围广泛涵盖了电影特效制作、虚拟现实体验构建等领域之外还被应用于医疗影像学当中辅助医生更清晰直观地理解病灶位置关系等问题。 ```python import numpy as np from skimage import io, color def simulate_lighting_changes(image_path): img = io.imread(image_path) gray_img = color.rgb2gray(img) # Simulate lighting changes by adjusting brightness levels across the image. shifted_images = [] for i in range(-50, 60, 20): # Example values to shift brightness adjusted_image = np.clip(gray_img + (i / 100.), 0., 1.) shifted_images.append(adjusted_image) return shifted_images ``` 上述代码片段展示了如何简单模拟光线变化的效果,这对于研究Shape-from-Shifting具有一定的启发意义。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值