14 条题解
-
12
#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; }
-
1
实际上就是一道比较简单的一道题 也是一道初学者学习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次!
好了,就这样
-
0
#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
#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; }
-
0
本题思路:分别将每个数提取出,并进行判断。
计算乘方的快捷方式: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"; }
-
-1
#include
using namespace std;
int main(){
int x,y; cin>>x>>y; if(x+y>10){ cout<<x*y; }else{ cout<<x-y; }
}
-
-1
#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; }
- 1
信息
- ID
- 884
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 4
- 标签
- 递交数
- 1046
- 已通过
- 459
- 上传者