首页 > 代码库 > 1704 卡片游戏
1704 卡片游戏
1704 卡片游戏
时间限制: 1 s
空间限制: 128000 KB
题目等级 : 白银 Silver
题目描述 Description
桌面上有一叠牌,从第一张牌(即位于顶面的牌)开始从上往下依次编号为1~n.当至少还剩两张排时进行一下操作:把第一张牌扔掉,然后把新的第一张牌放到整叠牌的最后。输入n。输出每次扔掉的牌,以及最后剩下的牌。。
输入描述 Input Description
输入n
输出描述 Output Description
输出每次扔掉的牌,以及最后剩下的牌
样例输入 Sample Input
7
样例输出 Sample Output
1 3 5 7 4 2 6
数据范围及提示 Data Size & Hint
1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 using namespace std; 6 int a[20001]; 7 void in(int x) 8 { 9 for(int i;i<=x;i++)10 {11 a[i]=i;12 }13 }14 void doit(int x)15 {16 int now=x;17 int c=1;18 for(int i=1;i<=now;i++)19 {20 cout<<a[i]<<" ";21 i++;22 a[++now]=a[i];23 }24 }25 bool vis[100001];26 int main()27 {28 int n;29 scanf("%d",&n);30 in(n);31 doit(n);32 }
1704 卡片游戏
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。