# 2019广东工业大学新生杯决赛 I-迷途的怪物(2019 Guangdong University of technology freshman Cup final I – lost monster)-其他

## 2019广东工业大学新生杯决赛 I-迷途的怪物(2019 Guangdong University of technology freshman Cup final I – lost monster)

``````#include <iostream>
using namespace std;
typedef long long ll;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T;
cin >> T;
while (T--)
{
ll p;
string n;
cin >> p >> n;
int t = n[n.size() - 1] - '0';
if (t % 2 == 0)
cout << 1 << endl;
else
cout << p - 1 << endl;
}
return 0;
}``````
————————

Title: i-i-lost monster_ 2019 Guangdong University of technology Tencent cup freshman program design competition (synchronous competition) (nowcoder. Com)

< strong > if you disassemble (p-1) ^ n according to the polynomial theorem, you will find that only one item has no P, and the other items have p, which can be directly reduced

< strong > therefore, the answer can be obtained by judging the parity of n (why I don’t know when the answer is P-1 when n is an odd number. I’ll come back later to supplement qwq)

code:

``````#include <iostream>
using namespace std;
typedef long long ll;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T;
cin >> T;
while (T--)
{
ll p;
string n;
cin >> p >> n;
int t = n[n.size() - 1] - '0';
if (t % 2 == 0)
cout << 1 << endl;
else
cout << p - 1 << endl;
}
return 0;
}``````