16 条题解

  • 13
    @ 2022-1-3 11:04:39
    #include <queue>
    #include <math.h>
    #include <stack>
    #include <stdio.h>
    #include <iostream>
    #include <vector>
    #include <iomanip>
    #include <string.h>
    #include <algorithm>
    using namespace std;
    #define LL long long
    const int N = 1e5 + 10;
    const int INF = 0x3f3f3f3f;
    int main()
    {	
    	int n;
    	cin >> n;
    	int b,s,g;
    	b = n/100;
    	s = n/10%10;
    	g = n%10;
    	if(b*b*b + g*g*g + s*s*s ==n)
    	{
    		cout <<"YES";
    	}
    	else
    	{
    		cout <<"NO";
    	}
    	return 0;
    }	
    
  • 2
    @ 2025-7-8 16:52:27

    实际上就是一道比较简单的一道题 也是一道初学者学习C++的经典例题

    想要代码的先看这里

    #include <bits/stdc++.h>
    using namespace std;
    int a,b,c,n;
    int main()
    {
    	cin >> n;
    	int m = n;
    	c = n % 10;
    	n /= 10;
    	b = n % 10;
    	n /= 10;
    	a = n;
    	if(a*a*a+b*b*b+c*c*c==m)
    	{
    		cout << "YES";
    	}
    	else
    	{
    		cout << "NO";
    	}
    	return 0;
    }
    

    不过我还是不建议你这样做,毕竟复制粘贴谁都会是吧

    你可以看看这个注释版,理解一下这个代码

    #include <bits/stdc++.h> 
    //万能头文件,如果你是初学者的话直接抄很容易被老师发现 
    //建议改成  #include <iostream> 
    using namespace std;//命名空间 
    int a,b,c,n;//题目的输入是一个三位数,我们分别用a,b,c储存这个数的个十百位数
    //n则用来储存输入的数 
    int main()
    {
    	cin >> n;//首先,我们要先输入这个数 
    	int m=n;//因为这个n要用来运算,为了后面的比较,我们要先储存n 
    	c = n%10;//c是n的个位数,这个“%”是取余,所以这里的c就是n除以10的余数 
    	n /= 10;//意思是n变成n除以10的商 
    	b = n%10;//同上 
    	n /= 10; 
    	a = n;//最后a=n; 
    	if(a*a*a+b*b*b+c*c*c==m)//判断水仙花数(根据题意) 
    	{
    		cout << "YES";//是的话输出YES 
    	}
    	else
    	{
    		cout << "NO";//不是就输出NO 
    	}
    	return 0;
    }
    
    

    注意!! 1、输出的字母全是大写,不然0分! 2、不要把%和/弄混了! 3、是三次方,要乘3次!

    好了,就这样

    • 1
      @ 2025-12-6 19:35:16

      #include using namespace std; short a,b,n1,n2,n3,num; int main() { cin >> a; b = a % 100; n1 = b % 10; n2 = (b - n1) / 10; n3 = a / 100; num = n1 * n1 * n1 + n2 * n2 * n2 + n3 * n3 * n3; if (num == a) cout << "YES"; else cout << "NO"; return 0; }

      • 0
        @ 2025-12-16 19:06:50

        #include<bits/stdc++.h> using namespace std; int a,b,c,n; int main() { cin >> n; int m = n; c = n % 10; n /= 10; b = n % 10; n /= 10; a = n; if(aaa+bbb+ccc==m) { cout << "YES"; } else { cout << "NO"; } return 0; }

        • 0
          @ 2025-7-22 9:40:51
          #include <iostream>
          #include <cmath>
          using namespace std;
          
          int main(){
          	/*
          	声明即将要用到的变量 
          	num:输入的数字
          	unitsDigit:个位数字
          	tensDigit:十位数字
          	hundredsDigit:百位数字 
          	*/ 
          	int num,unitsDigit,tensDigit,hundredsDigit,sum;
          	
          	 
          	cin >> num;
          	hundredsDigit = num / 100;   //求百位的数字 
          	tensDigit = num % 100 / 10;  //求十位的数字 
          	unitsDigit = num % 10;	     //求个位的数字 
          	
          	sum = pow(unitsDigit,3) + pow(tensDigit,3) + pow(hundredsDigit,3);
          	
          	if (num == sum) {
          		cout << "YES"; 
          	}
          	else{
          		cout <<   "NO"; 
          	}
          		
          	
          	return 0;
          }
          
          
          • 0
            @ 2024-6-1 19:06:13
            #include <iostream>
            using namespace std;
            int main(){
                    int n,num;
                    cin>>n;
                    num=n;
                    int sum=0;
                    for(int j=0;j<3;j++){
                        sum+=(n%10)*(n%10)*(n%10);
                        n/=10;
                    }
                    if(sum==num)
                        cout<<"YES"<<endl;
                    else   
                        cout<<"NO"<<endl;
                return 0;
            }
            //钟鼎皓
            
            • -1
              @ 2025-7-8 16:40:58

              #include using namespace std; int main() {

              int n;
              cin >> n;
              int x,y,z;
              x = n/100;
              y = n/10%10;
              z = n%10;
              if(x*x*x + y*y*y + z*z*z ==n)
              {
              	cout <<"YES";
              }
              else
              {
              	cout <<"NO";
              }
              return 0;
              

              }

              • -1
                @ 2023-12-24 12:35:43

                #include #include using namespace std; const int N=1e3+10; const int INF=0x3f3f3f3f; int a,g,s,b; int main(){ cin>>a; g=a%10; b=a/100; s=a/10%10; if(sss+bbb+ggg==a) cout<<"YES"; else cout<<"NO"; }

                • -1
                  @ 2023-4-10 17:09:00
                  #include <iostream>
                  using namespace std;
                  int main(){
                          int n,num;
                          cin>>n;
                          num=n;
                          int sum=0;
                          for(int j=0;j<3;j++){
                              sum+=(n%10)*(n%10)*(n%10);
                              n/=10;
                          }
                          if(sum==num)
                              cout<<"YES"<<endl;
                          else   
                              cout<<"NO"<<endl;
                      return 0;
                  }
                  
                  • -1
                    @ 2023-4-5 16:56:30

                    #include<bits/stdc++.h> using namespace std; int f(int n) { int bai,shi,ge; for(int i=100; i<=n; i++) { bai=i/100; shi=(i/10)%10; ge=i%10; if(baibaibai+shishishi+gegege==i) { return true; } } return false; } int main() { int n; cin>>n; if(f(n)) cout<<"YES"; else cout<<"NO"; return 0; }

                    • -1
                      @ 2022-1-23 13:12:44
                      #include <iostream>
                      using namespace std;
                      int main(){
                              int n,num;
                              cin>>n;
                              num=n;
                              int sum=0;
                              for(int j=0;j<3;j++){
                                  sum+=(n%10)*(n%10)*(n%10);
                                  n/=10;
                              }
                              if(sum==num)
                                  cout<<"YES"<<endl;
                              else   
                                  cout<<"NO"<<endl;
                          return 0;
                      }
                      • -1
                        @ 2021-12-4 12:23:25

                        本题思路:分别将每个数提取出,并进行判断。
                        计算乘方的快捷方式:

                        pow(double x, double y);
                        

                        返回值:x的y次方
                        注意:此函数需要包括库:

                        #include <cmath>
                        

                        附上代码(很早以前写的很烂见谅)

                        //Write by: FSC711300
                        #include <bits/stdc++.h>
                        using namespace std;
                        int main(){
                            int n;
                            cin>>n;
                            int hund=(n-n%100)/100;
                            int ten=(n-n%10)/10-hund*10;
                            int one=n-hund*100-ten*10;
                            if(pow(hund,3)+pow(ten,3)+pow(one,3)==n) cout<<"YES";
                            else cout<<"NO";
                        }
                        
                        • -2
                          @ 2023-1-12 16:09:04

                          #include

                          using namespace std;

                          int main(){

                          int x,y;
                          
                          cin>>x>>y;
                          
                          if(x+y>10){
                          
                          	cout<<x*y;
                          
                          }else{
                          
                          	cout<<x-y;
                          
                          }
                          

                          Copy

                          }

                          • -2
                            @ 2022-7-2 18:10:44

                            #include<stdio.h> #include using namespace std; int main() { int a; cin>>a; int b=a%10; int c=a/10%10; int d=a/100; if(bbb+ccc+ddd==a) { cout<<"YES"<<endl; }else { cout<<"NO"<<endl; } }

                            • -2
                              @ 2022-2-9 11:07:17

                              #include #include <math.h> #include #include <stdio.h> #include #include #include #include <string.h> #include using namespace std; #define LL long long const int N = 1e5 + 10; const int INF = 0x3f3f3f3f; int main() { int n; cin >> n; int b,s,g; b = n/100; s = n/10%10; g = n%10; if(bbb + ggg + sss ==n) { cout <<"YES"; } else { cout <<"NO"; } return 0; }

                              • -2
                                @ 2022-1-3 11:03:34
                                #include <stdio.h>
                                #include <iostream>
                                using namespace std;
                                int main()
                                {
                                	int n;
                                	cin >> n;
                                	int b,s,g;
                                	b = n/100;
                                	s = n/10%10;
                                	g = n%10;
                                	if(b*b*b + g*g*g+s*s*s ==n)
                                	{
                                		cout<<"YES";
                                
                                
                                	}
                                	else
                                	{
                                		cout << "NO";
                                
                                	}
                                
                                	
                                
                                
                                
                                
                                
                                
                                
                                
                                }
                                
                                
                                • 1

                                信息

                                ID
                                884
                                时间
                                1000ms
                                内存
                                128MiB
                                难度
                                4
                                标签
                                递交数
                                1116
                                已通过
                                482
                                上传者