雷霹数(very 简单的方法)C/C++

在这里插入图片描述

在这里插入图片描述

思路:正常人肯定是循环切割,但是,我一直不是正常人
所以,完全没有循环切割的必要,只需要直接切就可以了,具体看代码very very good,very very 巧妙

#include<iostream>
#include<algorithm>
using namespace std;
#define llu unsigned long long


int main()
{
	llu l,r;
	cin >> l >> r ;
	llu num=0;
	if(l<80)l=80;
	for(llu i=l;i<=r;i++)
	{
		llu f=i;
		int a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12;
		a1=f/1000000;
		a2=f%1000000;
		a3=f/100000;
		a4=f%100000;
		a5=f/10000;
		a6=f%10000;
		a7=f/1000;
		a8=f%1000;
		a9=f/100;
		a10=f%100;
		a11=f/10;
		a12=f%10;

		if((a1+a2)*(a1+a2)==i){
			num++;
			cout << i << endl ;
			continue;
		}
		if((a3+a4)*(a3+a4)==i){
			num++;
			cout << i << endl ;
			continue;
		}
		if((a5+a6)*(a5+a6)==i){
			num++;
			cout << i << endl ;
			continue;
		}
		if((a7+a8)*(a7+a8)==i){
			num++;
			cout << i << endl ;
			continue;
		}
		if((a9+a10)*(a9+a10)==i){
			num++;
			cout << i << endl ;
			continue;
		}	
		if((a11+a12)*(a11+a12)==i){
			num++;
			cout << i << endl ;
			continue;
		}
	}
	if(num==0)cout << "NONE" << endl ;
	
	return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值