1 条题解
-
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"); } } }
Python :
# coding=utf-8 def solve(num): res=0 for i in str(num): res+=int(i)**3 return res==num while(True): a=int(input()) if a==0: break if solve(a)==True: print("Yes") else: print("No")
- 1
信息
- ID
- 2007
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者