A - Presents
Problem description
Little Petya very much likes gifts. Recently he has received a new laptop as a New Year gift from his mother. He immediately decided to give it to somebody else as what can be more pleasant than giving somebody gifts. And on this occasion he organized a New Year party at his place and invited n his friends there.
If there's one thing Petya likes more that receiving gifts, that's watching others giving gifts to somebody else. Thus, he safely hid the laptop until the next New Year and made up his mind to watch his friends exchanging gifts while he does not participate in the process. He numbered all his friends with integers from 1 to n. Petya remembered that a friend number i gave a gift to a friend number pi. He also remembered that each of his friends received exactly one gift.
Now Petya wants to know for each friend i the number of a friend who has given him a gift.
Input
The first line contains one integer n (1 ≤ n ≤ 100) — the quantity of friends Petya invited to the party. The second line contains n space-separated integers: the i-th number is pi — the number of a friend who gave a gift to friend number i. It is guaranteed that each friend received exactly one gift. It is possible that some friends do not share Petya's ideas of giving gifts to somebody else. Those friends gave the gifts to themselves.
Output
Print n space-separated integers: the i-th number should equal the number of the friend who gave a gift to friend number i.
Examples
Input
4
2 3 4 1
Output
4 1 2 3
Input
3
1 3 2
Output
1 3 2
Input
2
1 2
Output
1 2
解题思路:输入n(n表示编号从1到n的学生总数)个数,第i个数表示编号为i的学生送礼物给编号为j的学生,要求输出编号为j的学生收到那个送他礼物的学生编号i,水过!
AC代码:
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,x,t[];
cin>>n;
for(int i=;i<=n;++i){cin>>x;t[x]=i;}
for(int i=;i<=n;++i)
cout<<t[i]<<(i==n?"\n":" ");
return ;
}
A - Presents的更多相关文章
- CodeForces 483B Friends and Presents
Friends and Presents Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I ...
- B. Friends and Presents(Codeforces Round #275(div2)
B. Friends and Presents time limit per test 1 second memory limit per test 256 megabytes input stand ...
- Codeforces483B. Friends and Presents(二分+容斥原理)
题目链接:传送门 题目: B. Friends and Presents time limit per test second memory limit per test megabytes inpu ...
- Codeforces 483B - Friends and Presents(二分+容斥)
483B - Friends and Presents 思路:这个博客写的不错:http://www.cnblogs.com/windysai/p/4058235.html 代码: #include& ...
- CF 483B. Friends and Presents 数学 (二分) 难度:1
B. Friends and Presents time limit per test 1 second memory limit per test 256 megabytes input stand ...
- Codeforces Round #348 (VK Cup 2016 Round 2, Div. 2 Edition) A. Little Artem and Presents 水题
A. Little Artem and Presents 题目连接: http://www.codeforces.com/contest/669/problem/A Description Littl ...
- codefoeces B. Friends and Presents
B. Friends and Presents time limit per test 1 second memory limit per test 256 megabytes input stand ...
- codeforces 669A A. Little Artem and Presents(水题)
题目链接: A. Little Artem and Presents time limit per test 2 seconds memory limit per test 256 megabytes ...
- Codeforces Round #275 (Div. 2) B. Friends and Presents 二分+数学
8493833 2014-10-31 08:41:26 njczy2010 B - Friends and Presents G ...
- A - Alice and the List of Presents (排列组合+快速幂取模)
https://codeforces.com/contest/1236/problem/B Alice got many presents these days. So she decided to ...
随机推荐
- Caffe: gflag编译出现问题汇总
1. 使用Unicode字符集: 出现问题 E:\CodeBase\ML\Caffe\ThirdPartySrc\gflags-master\src\gflags.cc(1340): error C2 ...
- 安卓代码迁移:Make.exe: *** [libs/armabi-v7a/gdbserver] Error 1
解决办法1:安装ndk和eclipse修改为x86操作系统 解决办法2:降低更换NDK版本
- (转)Arcgis for JS实现台风运动路径与影像范围的显示
http://blog.csdn.net/gisshixisheng/article/details/42025435 首先,看看具体的效果: 初始化状态 绘制中 绘制完成 首先,组织数据.我组织的数 ...
- java中反射讲解及实例
Java反射机制详解 java 反射 定义 功能 示例 概要: Java反射机制详解 | |目录 1反射机制是什么 2反射机制能做什么 3反射机制的相关API ·通过一个对象获得完整的包名和类名 ·实 ...
- 防止split没有切割的变量报错
var getSocketUrl = localStorage.getItem("socketUrl"); getSocketUrl = getSocketUrl &&am ...
- es5、es6函数调用
ES5中函数的4种调用 在ES5中函数内容的this指向和调用方法有关 1 函数调用模式 包括函数名()和匿名函数调用,this指向window function getSum() { console ...
- 51nod1126 求递推序列的第N项【递推】
有一个序列是这样定义的:f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7. 给出A,B和N,求f(n)的值. Input 输 ...
- 0728MySQL数据库InnoDB存储引擎重做日志漫游REDOLOG,UNDOLOG
转自http://www.mysqlops.com/2012/04/06/innodb-log1.html 00 – Undo LogUndo Log 是为了实现事务的原子性,在MySQL数据库Inn ...
- mongodb--find高级用法
链式查询 db.person.find().limit(4).sort({sex:-1}) // sort来说,1 是升序, -1 是降序 尽量不要用mongodb去做一些复杂的运算 分页的写法 ·· ...
- ROA与SOA概念
SOA:面向服务的架构,可以理解为从客户的角度,将软件设计为模块式结构,可以根据用户的需要自由添加.定制模块,偏重于向用户靠拢 ROA:面向资源的架构,从资源的角度,严格按照计算机规范设计软件,偏重科 ...