题目描述
输入一个整数n。 1、判断它是否为素数,是输出“Y',不是输出“N”. 2、输出这个数的各位数字之和。 3、求出这个数所有约数的和。 4、求出1到n的和。 5、输出这个数的倒序数(不包含前导0)。
输入格式
一行一个整数。
输出格式
五行; 第一行“Y'或“N”. 第二行,一个整数。 第三行,一个整数。 第四行,一个整数. 第五行,一个整数.
样例
样例输入
复制65
样例输出
复制N
11
84
2145
56
____________________________________________________________________________
日常发作业题解。
也是简单到爆爆爆爆爆爆爆爆爆爆爆爆爆爆爆爆爆爆爆爆爆爆爆爆爆爆爆爆爆爆爆爆爆爆爆表的题
写作不易,点个赞呗!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
____________________________________________________________________________
#include <bits/stdc++.h>
using namespace std;
int n,ans,cnt,m;
int node(int x){
int y=0;
for(int i=2;i<=sqrt(x);i++){
if(x%i==0)y++;
}
if(y==0)return 1;
else return 0;
}
void h(int x){
for(int i=1;i<=x;i++){
if(x%i==0)ans+=i;
}
}
int check(int x){
int y=0,z=x;
while(x>0){
m+=x%10;
y=y*10+x%10;
x/=10;
}
cnt=y;
if(y==z)return 1;
else return 0;
}
int main(){
cin>>n;
if(node(n)==0)cout<<"N\n";
else cout<<"Y\n";
check(n);
h(n);
cout<<m<<endl;
cout<<ans<<endl;
cout<<(n+1)*n/2<<endl;
cout<<cnt;
}