1 solutions

  • 0
    @ 2025-11-5 15:32:11

    C++ :

    #include<bits/stdc++.h>
    using namespace std;
    int n,m,t,a,b,c,s;
    int main(){
    	cin>>n>>m;
    	if(n>m)swap(n,m);
        for(int i=n;i<=m;i++)
    	{
    		t=i;a=t/100;b=t/10%10;c=t%10;
    		if(pow(a,3)+pow(b,3)+pow(c,3)==t)cout<<t<<endl,s++;
    	}
    	if(s==0)cout<<"NO";
        return 0;
    }
    

    Pascal :

    var a,b,c,e,s,i,f :longint;
    begin
    readln(a,b);
    for i:=a to b do
    begin
    c:=i;s:=0;
    repeat
    e:=c div 10;
    b:=c mod 10;
    c:=e;
    s:=s+b*b*b;
    until c=0;
    if i=s then
    begin
    writeln(i);
    inc(f);
    end;
    end;
    if f=0 then
    write('NO');
    end.
    
    
    • 1

    Information

    ID
    16899
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By