• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            sgu 118

            Posted on 2010-12-15 11:48 王之昊 閱讀(202) 評論(0)  編輯 收藏 引用 所屬分類: sgu
            對于“數根”(定義見Let f(n) be a sum of digits for positive integer n. If f(n) is one-digit number then it is a digital root for n and otherwise digital root of n is equal to digital root of f(n).)注意這里只定義正整數的“數根”,所以已經把 0 排除了。

            結論: 數根f(n)與n模9同余,且f(n)的范圍屬于[1,9].

            證明:如果n = am*10m + am-1*10m-1 +...+ a0*10, 令g(n) = am+am-1+...+a0.    

            n       ->        [n0=g(n)]      ->        [n1=g(n0)]       ->         [n2=g(n1)]       ->        ...      ->        f(n) 

            中間的每個環節都是模9同余的,傳遞下去,所以n和f(n)也是模9同余的

             1
             2import java.io.FileNotFoundException;
             3import java.util.Scanner;
             4
             5
             6/*
             7 * To change this template, choose Tools | Templates
             8 * and open the template in the editor.
             9 */

            10/**
            11 *
            12 * @author wangzhihao
            13 */

            14class Seq {
            15
            16    int[] A;
            17
            18    Seq(int[] a) {
            19    A = a;
            20    }

            21    int DigitSum() {
            22    int res = 0, term = 1;
            23    for (int i = 0; i < A.length; i++{
            24        term = term * ( A[i] % 9% 9;
            25        res = ( res + term ) % 9;
            26    }

            27    return res == 0 ? 9 : res;
            28    }

            29}

            30
            31public class Solution {
            32
            33    /**
            34     * @param args the command line arguments
            35     */

            36    public static void main(String[] args) throws FileNotFoundException {
            37    Scanner sc = new Scanner(System.in);
            38    int testCase = sc.nextInt();
            39    for (int cas = 1; cas <= testCase; cas++{
            40        int n = sc.nextInt();
            41        int[] a = new int[n];
            42        for (int i = 0; i < n; i++{
            43        a[i] = sc.nextInt();
            44        }

            45        Seq seq = new Seq(a);
            46        System.out.println(seq.DigitSum());
            47    }

            48    }

            49}

            50

            posts - 26, comments - 7, trackbacks - 0, articles - 17

            Copyright © 王之昊

            精品综合久久久久久97超人| 久久久久久无码国产精品中文字幕 | 国产A级毛片久久久精品毛片| 伊人久久大香线蕉AV一区二区| 中文字幕热久久久久久久| 波多野结衣中文字幕久久| 久久精品二区| 久久午夜无码鲁丝片| 久久天天日天天操综合伊人av| 久久99热这里只有精品国产| 93精91精品国产综合久久香蕉| 人人狠狠综合久久亚洲| 久久超碰97人人做人人爱| 污污内射久久一区二区欧美日韩| 亚洲精品乱码久久久久久| 久久精品国产亚洲一区二区三区| 欧美噜噜久久久XXX| 日本精品一区二区久久久| 99久久99久久精品国产片果冻| 精品熟女少妇AV免费久久| 久久精品国产欧美日韩| 精品国产一区二区三区久久| 亚洲国产精品无码久久一线| 中文字幕亚洲综合久久菠萝蜜| 国产精品成人99久久久久91gav | 波多野结衣AV无码久久一区| 久久亚洲AV无码西西人体| 国产一区二区三精品久久久无广告| 久久人爽人人爽人人片AV| 亚洲va久久久噜噜噜久久狠狠| 亚洲午夜无码AV毛片久久| 久久久久亚洲精品无码网址| 国产精品美女久久久久久2018| 中文字幕无码免费久久| 婷婷久久香蕉五月综合加勒比| 亚洲а∨天堂久久精品9966| 久久午夜福利电影| 国产精品久久久久久久久久影院| 一本综合久久国产二区| 久久精品国产亚洲AV蜜臀色欲| 国产精品成人久久久|