ny714 Card Trick

Card Trick

时间限制:1000 ms  |  内存限制:65535 KB
难度:3
描述

The magician shuffles a small pack of cards, holds it face down and performs the following procedure:

  1. The top card is moved to the bottom of the pack. The new top card is dealt face up onto the table. It is the Ace of Spades.
  2. Two cards are moved one at a time from the top to the bottom. The next card is dealt face up onto the table. It is the Two of Spades.
  3. Three cards are moved one at a time…
  4. This goes on until the nth and last card turns out to be the n of Spades.

This impressive trick works if the magician knows how to arrange the cards beforehand (and knows how to give a false shuffle). Your program has to determine the initial order of the cards for a given number of cards, 1 ≤ n ≤ 13.

输入
On the first line of the input is a single positive integer k, telling the number of test cases to follow. 1 ≤ k ≤ 10 Each case consists of one line containing the integer n. 1 ≤ n ≤ 13
输出
For each test case, output a line with the correct permutation of the values 1 to n, space separated. The first number showing the top card of the pack, etc…
样例输入
2
4
5
样例输出
2 1 4 3
3 1 4 5 2
参考代码,用的双端队列写的
 1  
 2 #include<deque>
 3 #include<iostream>
 4 #include<cstring>
 5 using namespace std;
 6 int main()
 7 {
 8     deque<int>q;
 9     int t,n,a,m,i,k,j;
10     cin>>t;
11     while(t--)
12     {while(!q.empty())
13        q.pop_front();
14         cin>>n;
15        int mm=n-1,kk=2;
16        q.push_front(n);
17         for(i=n-1;i>=1;i--,mm--,++kk)
18         {
19         q.push_front(mm);
20             for(j=i%kk;j>0;j--)
21             {
22                 q.push_front(q.back());
23                 q.pop_back();
24             }
25         }
26         for(i=0;i<n;i++)
27             {
28                 cout<<q.front()<<" ";
29                 q.pop_front();
30             }
31         cout<<endl;
32     }
33     return 0;
34 }
35         

 

### Wine 使用技巧与方法 Wine 是一个开源项目,旨在让 Linux 和其他类 Unix 系统能够运行 Windows 应用程序。它通过模仿 Windows API 来实现这一目标,而无需实际安装 Windows 操作系统。以下是一些关于使用 Wine 的技巧和方法[^1]。 #### 安装应用程序 要安装 Windows 应用程序,用户可以简单地双击 `.exe` 文件,或者在终端中运行 `wine <application_name>.exe`。如果需要更高级的安装选项,可以使用 Winetricks 工具来安装依赖项和库[^2]。 ```bash winetricks vcrun2019 ``` 上述命令将安装 Visual C++ 2019 Redistributable,这是许多现代 Windows 应用程序所必需的。 #### 调整图形设置 某些应用程序可能需要特定的 DirectX 或 OpenGL 设置才能正常运行。可以通过 `winecfg` 工具调整这些设置: ```bash winecfg ``` 在 `Graphics` 标签页中,可以启用或禁用虚拟桌面,并调整分辨率和其他图形相关选项[^3]。 #### 使用前缀隔离环境 Wine 允许创建多个前缀(prefix),每个前缀相当于一个独立的 Windows 环境。这有助于隔离不同应用程序之间的冲突。创建新前缀的方法如下: ```bash WINEPREFIX=~/.new_prefix wineboot --init ``` 然后,在该前缀下运行应用程序时,需指定相同的 `WINEPREFIX` 环境变量。 #### 日志调试 如果某个应用程序无法正常运行,可以启用调试日志以获取更多信息。通过设置 `WINEDEBUG` 环境变量,可以控制输出的日志级别: ```bash WINEDEBUG=+all wine <application_name>.exe ``` 注意,生成的日志文件可能会非常大,因此建议仅在需要时启用此功能[^4]。 #### 性能优化 为了提高性能,可以禁用不必要的功能,例如字体平滑和视觉主题。同样,可以在 `winecfg` 中调整 CPU 数量和内存分配。 ```python import os # 设置 WINEDEBUG 环境变量 os.environ['WINEDEBUG'] = '+all' ``` #### 注意事项 确保系统已安装所有必要的依赖项,包括 32 位和 64 位库。此外,某些应用程序可能需要特定版本的 Wine 才能正常工作。在这种情况下,可以尝试使用 Wine Staging 版本,它通常包含更多实验性功能和支持[^5]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值