Digital Root-数字的根(数位拆解,每位相加)

The digital root of a positive integer is found by summing the digits of the integer. If the resulting value is a single digit then that digit is the digital root.

正整数  加每一位 结果是1位数  -- 是root

 

If the resulting value contains two or more digits, those digits are summed and the process is repeated. This is continued as long as necessary to obtain a single digit.

结果是2位数以上,再来一次,直到root

For example, consider the positive integer 24. Adding the 2 and the 4 yields a value of 6. Since 6 is a single digit, 6 is the digital root of 24.

Now consider the positive integer 39. Adding the 3 and the 9 yields 12. Since 12 is not a single digit, the process must be repeated. Adding the 1 and the 2 yeilds 3, a single digit and also the digital root of 39.

输入描述:
The input file will contain a list of positive integers, one per line.
The integer may consist of a large number of digits.

输出描述:
For each integer in the input, output its digital root on a separate line of the output.

样例输入:
24
39
样例输出:
6
3

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <map>
#include <stack>
using namespace std;



int getResult(int n) {
    int sum = 0;
    while (n > 0) {
        sum += n % 10;
        n /= 10;
    }

    return sum;
}

bool isQualified(int n) {
    if (n >= 0 && n <= 9) {
        return true;
    } else {
        return false;
    }

}


int getRoot(int n) {

    int root = getResult(n);
    while(!isQualified(root)){
        root = getResult(root);
    }
    return root;

}


int main() {

    int n;
    while (cin >> n){
        cout << getRoot(n) <<endl;
    }


}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
数字预失真(Digital Pre-Distortion,简称DPD)是一种信号处理技术,它被用于消除高功率无线通信系统中的非线性失真。在高功率放大器中,非线性失真是一个常见的问题,它导致系统性能下降,信号质量恶化。 数字预失真的基本原理是在发送信号之前对信号进行预处理,使其形状在放大过程中尽可能接近原始信号。它可以通过逆向建模放大器的非线性特性来实现,将修正信号添加到待放大信号中,以抵消非线性失真。通过在数字域中对信号进行处理,数字预失真可以实现精确的失真补偿,提高系统的线性度。 数字预失真的应用非常广泛,主要用于高功率放大器,例如通信基站、卫星通信、无线电波传输、雷达系统等。在这些系统中,高频信号常常遭受放大器的非线性影响,导致输出信号的频谱扩展和形状失真。通过使用数字预失真技术,可以有效地补偿这些失真,提高传输效率和信号质量。 数字预失真还可以实现功率放大器的效率提升。由于非线性失真会导致功率放大器的能耗增加,数字预失真可以在不牺牲信号质量的情况下,减少功率放大器的功耗。这对于无线通信系统和其他高功率应用非常重要,因为能量效率是一个关键的指标。 总之,数字预失真是一种用于消除高功率无线通信系统中非线性失真的信号处理技术。它的应用领域广泛,可以提高系统的线性度、信号质量和功率放大器的能效。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值