1 solutions
-
0
C :
#include <stdio.h> int main(){ int n, a, b, c, f; while(scanf("%d", &n) && n != 0){ a = n%10; b = n/10%10; c = n/100; if(a*a*a + b*b*b + c*c*c == n) puts("Yes"); else puts("No"); } return 0; }C++ :
#include <iostream> using namespace std; int main() { int n,a,b,c; while(cin>>n&&n){ a=n%10; b=n/10%10; c=n/100%10; if(n!=0) if(a*a*a+b*b*b+c*c*c==n){ cout<<"Yes"<<endl; }else{ cout<<"No"<<endl; } else break; } return 0; }Pascal :
var n,a,b,c:longint; begin read(n); while n<>0 do begin a:=n div 100; b:=n div 10-a*10; c:=n mod 10; if a*a*a+b*b*b+c*c*c=n then writeln('Yes') else writeln('No'); readln(n); end; end.Java :
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); while(sc.hasNext()) { int n=sc.nextInt(); if(n==0) break; String str=Integer.toString(n); int a=(int)Math.pow((str.charAt(0)-'0'),3); int b=(int)Math.pow((str.charAt(1)-'0'),3); int c=(int)Math.pow((str.charAt(2)-'0'),3); if(a+b+c==n) System.out.println("Yes"); else System.out.println("No"); } } }
- 1
Information
- ID
- 19013
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By