Operator↵
↵
Problem:↵
↵
In order to welcome Christmas, the students of the Informatics Interest Group held a grand party under the leadership of the tutors. The first content of the party was to play games: guess the number. The teacher gave each student a card with a number (this number is non-negative and less than 255). Each number is different from each other. The teacher made the following rules of the game: In the first round, each student squared the numbers of his number and then added them to get a group of numbers. The students with numbers in this group were eliminated; In the second round, the rest of the students cube the numbers they numbered to get a new set of numbers. The students whose numbers appear in this set of numbers will be eliminated; In the third round, the remaining students will add the numbers four times to get a new set of numbers. The students whose numbers appear in this set of numbers will be eliminated, and so on. After n rounds, the remaining students will get a special Christmas gift. The number on the card is the lucky number of 2009. (Assuming that the class size does not exceed 200)↵
↵
Input format↵
The first line is a positive integer n (n<8), indicating that there are n rounds of games↵
The second line is the different numbers on the cards, separated by spaces.↵
Output format↵
Output a line for the remaining auspicious numbers, from small to large, with a space between each two numbers.↵
↵
```cpp↵
#include<bits/stdc++.h>↵
using namespace std;↵
class node{↵
public:↵
int value;↵
int operator ^(int b){//Overload the "xor" operator to make it a power↵
int tmp=b,tp=0,tp2=this->value;↵
while(tp2){↵
tp+=pow(tp2%10,tmp);↵
tp2/=10;↵
}↵
return tp;↵
}↵
};↵
node a[205];↵
int p,tab[205];↵
bool cmp(node a,node b){↵
if(a.value<b.value)return 1;↵
else return 0;↵
}↵
int main(){↵
int n,t;↵
cin>>n;↵
while(cin>>a[p++].value);↵
sort(a,a+p,cmp);↵
for(int i=2;i<=n+1;i++){↵
memset(tab,0,sizeof(tab));↵
for(int j=0;j<p;j++)if(a[j].value!=-1)tab[j]=a[j]^i;↵
for(int j=0;j<p;j++)↵
for(int k=0;k<p;k++)if(tab[j]==a[k].value)a[k].value=-1;↵
}↵
for(int i=0;i<p;i++)if(a[i].value!=-1)cout<<a[i].value<<" ";↵
}↵
```
↵
Problem:↵
↵
In order to welcome Christmas, the students of the Informatics Interest Group held a grand party under the leadership of the tutors. The first content of the party was to play games: guess the number. The teacher gave each student a card with a number (this number is non-negative and less than 255). Each number is different from each other. The teacher made the following rules of the game: In the first round, each student squared the numbers of his number and then added them to get a group of numbers. The students with numbers in this group were eliminated; In the second round, the rest of the students cube the numbers they numbered to get a new set of numbers. The students whose numbers appear in this set of numbers will be eliminated; In the third round, the remaining students will add the numbers four times to get a new set of numbers. The students whose numbers appear in this set of numbers will be eliminated, and so on. After n rounds, the remaining students will get a special Christmas gift. The number on the card is the lucky number of 2009. (Assuming that the class size does not exceed 200)↵
↵
Input format↵
The first line is a positive integer n (n<8), indicating that there are n rounds of games↵
The second line is the different numbers on the cards, separated by spaces.↵
Output format↵
Output a line for the remaining auspicious numbers, from small to large, with a space between each two numbers.↵
↵
```cpp↵
#include<bits/stdc++.h>↵
using namespace std;↵
class node{↵
public:↵
int value;↵
int operator ^(int b){//Overload the "xor" operator to make it a power↵
int tmp=b,tp=0,tp2=this->value;↵
while(tp2){↵
tp+=pow(tp2%10,tmp);↵
tp2/=10;↵
}↵
return tp;↵
}↵
};↵
node a[205];↵
int p,tab[205];↵
bool cmp(node a,node b){↵
if(a.value<b.value)return 1;↵
else return 0;↵
}↵
int main(){↵
int n,t;↵
cin>>n;↵
while(cin>>a[p++].value);↵
sort(a,a+p,cmp);↵
for(int i=2;i<=n+1;i++){↵
memset(tab,0,sizeof(tab));↵
for(int j=0;j<p;j++)if(a[j].value!=-1)tab[j]=a[j]^i;↵
for(int j=0;j<p;j++)↵
for(int k=0;k<p;k++)if(tab[j]==a[k].value)a[k].value=-1;↵
}↵
for(int i=0;i<p;i++)if(a[i].value!=-1)cout<<a[i].value<<" ";↵
}↵
```