Problem Description
Problem Analysis
1
2
3
4
5
6
7
8
9
10
11
12
| #include<stdio.h>
#include<math.h>
int main() {
int m;
while(scanf("%d",&m),m!=0) {
if(pow(m%10,3)+pow(m/10%10,3)+pow(m/100,3)==m)
printf("Yes\n");
else
printf("No\n");
}
return 0;
}
|
The official solution is pretty shameless.
-.-
Still, when it comes to ? :
I really do need to strengthen my awareness of using it.
Right now I have no thought of using ? at all.
1
2
3
4
5
6
7
8
9
10
11
12
| #include<iostream>
using namespace std;
int main()
{
int a;
while(1)
{
cin>>a;
if(a==0) break;
cout<<((a==153||a==370||a==371||a==407)?"Yes":"No")<<endl;
}
}
|
Mm~
Then let me rewrite my own version in ? form.
1
2
3
4
5
6
7
8
9
| #include<stdio.h>
#include<math.h>
int main() {
int m;
while(scanf("%d",&m),m!=0) {
printf("%s\n",pow(m%10,3)+pow(m/10%10,3)+pow(m/100,3)==m?"Yes":"No");
}
return 0;
}
|
Problem link: [NYOJ] [v1-39] Narcissistic Number