Liam Neeson's newest film is about to come out. As a sequel to Taken, Given Back tells the story of Liam's revenge.
There are N characters involved in the story. Each of them has some integer code associated, not necessarily unique. Those who have code X are Liam's enemies, and must be taken care of. Your job is to get rid of them and output the remaining characters, in their initial order.
Input
The first line of input contains two integers N and X.
The second line of input contains N integers, separated by spaces, denoting the codes of all characters.
Output
The only line of output should contain the list of characters that are still living after Liam's revenge. If there's no one left, the output should be empty.
Restrictions
- 2 ≤ N ≤ 100
- 0 ≤ any code ≤ 20000
Sample
Input | Output |
---|---|
8 999 0 118 999 881 999 119 725 3 | 0 118 881 119 725 3 |
Python 3
1 n, x = input().split() 2 print(' '.join([e for e in input().split() if e != x]))
Rust
1 #![allow(unused_must_use)] 2 use std::io; 3 4 fn main() { 5 let mut nx = String::new(); 6 let mut xs = String::new(); 7 8 io::stdin().read_line(&mut nx); 9 let x = nx.trim().split(" ").collect::<Vec<&str>>()[1]; 10 11 io::stdin().read_line(&mut xs); 12 for e in xs.trim().split(" ").collect::<Vec<&str>>() { 13 if x != e { 14 print!("{} ", e); 15 } 16 } 17 println!(""); 18 }
C++
1 #include <iostream> 2 using namespace std; 3 4 int n, x, e; 5 6 int main() { 7 cin>>n>>x; 8 9 while(n--) { 10 cin>>e; 11 if(e != x) cout<<e<<" "; 12 } 13 14 cout<<"\n"; 15 return 0; 16 }