poj 2182
来源:互联网 发布:c语言如何实现多线程 编辑:程序博客网 时间:2024/05/18 01:11
#include<stdio.h>//从后向前
#define N 8100
int f[N];
int main() {
int a[N],b[N],n,m,i,h,j,d;
while(scanf("%d",&n)!=EOF) {
a[0]=0;
for(i=1;i<n;i++) {
scanf("%d",&a[i]);
b[i]=i;
}
b[n]=n;d=n;
for(i=n-1;i>=0;i--) {
m=a[i]+1;
h=0;
while(1) {
h++;
if(h>n)
h=1;
if(b[h]!=-1)
m--;
if(m==0)break;
}
b[h]=-1;
f[d--]=h;
}
for(i=1;i<=n;i++)
printf("%d\n",f[i]);
}
return 0;
}
#define N 8100
int f[N];
int main() {
int a[N],b[N],n,m,i,h,j,d;
while(scanf("%d",&n)!=EOF) {
a[0]=0;
for(i=1;i<n;i++) {
scanf("%d",&a[i]);
b[i]=i;
}
b[n]=n;d=n;
for(i=n-1;i>=0;i--) {
m=a[i]+1;
h=0;
while(1) {
h++;
if(h>n)
h=1;
if(b[h]!=-1)
m--;
if(m==0)break;
}
b[h]=-1;
f[d--]=h;
}
for(i=1;i<=n;i++)
printf("%d\n",f[i]);
}
return 0;
}
0 0
- POJ 2182
- poj 2182
- poj 2182
- poj 2182
- poj 2182
- poj 2182
- poj 2182
- poj 2182
- poj 2182
- poj 2182
- poj 2182
- poj 2182
- poj 2182
- POJ 2182 :Lost Cows
- poj 2182 Lost Cows
- poj 2182 Lost Cows
- poj 2182 Lost Cows
- POJ 2182 Lost Cows
- as3学习笔记4:URLLoader动态加载XML
- ios xy快速框架
- arm-linux-gcc的安装
- 红黑树
- 在Windows7上搭建Cocos2d-x 3.0开发环境
- poj 2182
- 小题
- GDataXMLNode 解析
- 散布矩阵(Scatter Matrix)(一)
- 最近要看的博客 关于anacona selinux
- androidpn 0.5.0客户端 asmack 类库更新到 android8-0.8.10
- 高端多媒体机房教室租赁
- iOS6和iOS7代码的适配(1)
- xml——python xml 解析