函数大聚会(c++题解)

题目描述

输入一个整数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;
}

相关推荐

  1. 函数聚会(c++题解)

    2024-02-03 14:36:01       44 阅读
  2. C语言题目集-函数题6

    2024-02-03 14:36:01       43 阅读
  3. 中位数(c++题解)

    2024-02-03 14:36:01       41 阅读
  4. python/c++ Leetcode题解——2744. 最字符串配对数目

    2024-02-03 14:36:01       48 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-02-03 14:36:01       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-02-03 14:36:01       101 阅读
  3. 在Django里面运行非项目文件

    2024-02-03 14:36:01       82 阅读
  4. Python语言-面向对象

    2024-02-03 14:36:01       91 阅读

热门阅读

  1. Nest 测试 について 常用的函数的含义

    2024-02-03 14:36:01       45 阅读
  2. uniapp父子组件通信

    2024-02-03 14:36:01       53 阅读
  3. Linux 系统 ubuntu22.04 发行版本 固定 USB 设备端口号

    2024-02-03 14:36:01       53 阅读
  4. RNN的具体实现

    2024-02-03 14:36:01       54 阅读
  5. 关于sql关键字及敏感数据脱敏

    2024-02-03 14:36:01       52 阅读
  6. 蓝桥杯客观题练习笔记

    2024-02-03 14:36:01       60 阅读
  7. C++设计模式之工厂模式

    2024-02-03 14:36:01       48 阅读