• <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 王之昊 閱讀(207) 評論(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 © 王之昊

            精品免费tv久久久久久久| 国产精品欧美久久久久无广告 | 久久人人爽人人爽人人片AV高清| 久久无码专区国产精品发布| 久久丫精品国产亚洲av不卡| 久久强奷乱码老熟女网站| 国产精品99久久99久久久| 日韩精品国产自在久久现线拍| 狠狠色丁香久久婷婷综合| 色综合久久中文色婷婷| 精品一二三区久久aaa片| 久久996热精品xxxx| 99久久这里只有精品| 国产A三级久久精品| 久久免费99精品国产自在现线| 77777亚洲午夜久久多喷| 中文国产成人精品久久不卡| 久久99精品国产麻豆婷婷| 久久国产精品久久久| 久久夜色精品国产噜噜噜亚洲AV| 亚洲人成电影网站久久| 四虎影视久久久免费| 精品无码人妻久久久久久| 久久亚洲国产中v天仙www| 久久久国产精品亚洲一区| 无码国内精品久久人妻| 亚洲午夜久久久久久久久电影网| 欧美粉嫩小泬久久久久久久| 久久精品无码一区二区三区日韩 | 久久亚洲国产成人精品性色| 99久久无色码中文字幕人妻| 久久久久久久久波多野高潮| 伊人色综合久久天天人守人婷| 性做久久久久久久久老女人| 亚洲国产香蕉人人爽成AV片久久| 久久久精品人妻无码专区不卡| 久久久精品视频免费观看| 久久婷婷五月综合成人D啪| 一极黄色视频久久网站| 久久久久久久久久久久久久| 精品国产VA久久久久久久冰|