#16539: 測資 #5 #6

#### c0745077 (Haha)

School : Not Student
ID : 81434
IP address : [114.40.23.162]
2019-07-20 00:34:21
c459. 2. 自戀數 -- | From: [110.50.167.68] | Post Date : 2019-01-12 14:21

NA

#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int main()
{
string str;
int n=0;

while ( cin>>n>>str)
{
float num10=0;
float numchk=0;
int len=str.length();
vector <int> vecData;
for (int i=0;i<len;i++){
vecData.push_back(str[i]-'0');

}
for (int i=1;i<=len;i++){
num10+=vecData[i-1]*pow(n,len-i);
numchk+=pow(vecData[i-1],len);
}

if (num10==numchk){cout<<"YES"<<endl;
}
else
{cout<<"NO"<<endl;
}
vector<int>().swap(vecData);
}

return 0;
}

#17980: Re:測資 #5 #6

#### chuang091@gmail.com (APCS實作400分)

School : 臺北市私立復興實驗高級中學
ID : 96127
IP address : [60.250.123.203]
2019-06-06 20:19:19
c459. 2. 自戀數 -- | From: [39.10.73.212] | Post Date : 2019-06-07 18:02

NA

#include
#include <bits/stdc++.h>

using namespace std;

int main()
{
string str;
int n=0;

while ( cin>>n>>str)
{
float num10=0;
float numchk=0;
int len=str.length();
vector vecData;
for (int i=0;i<len;i++){
vecData.push_back(str[i]-'0');

}
for (int i=1;i<=len;i++){
num10+=vecData[i-1]*pow(n,len-i);
numchk+=pow(vecData[i-1],len);
}

if (num10==numchk){cout<<"YES"<<endl;
}
else
{cout<<"NO"<<endl;
}
vector().swap(vecData);
}

return 0;
}

ZeroJudge Forum