锘??xml version="1.0" encoding="utf-8" standalone="yes"?>久久久亚洲欧洲日产国码二区,久久精品亚洲欧美日韩久久,久久亚洲欧洲国产综合http://www.shnenglu.com/Wangzhihao/category/15608.html濂借鎬т笉濡傜儌絎斿ごzh-cnSun, 26 Dec 2010 12:36:01 GMTSun, 26 Dec 2010 12:36:01 GMT60sgu 118http://www.shnenglu.com/Wangzhihao/articles/136475.html鐜嬩箣鏄?/dc:creator>鐜嬩箣鏄?/author>Wed, 15 Dec 2010 03:48:00 GMThttp://www.shnenglu.com/Wangzhihao/articles/136475.htmlhttp://www.shnenglu.com/Wangzhihao/comments/136475.htmlhttp://www.shnenglu.com/Wangzhihao/articles/136475.html#Feedback0http://www.shnenglu.com/Wangzhihao/comments/commentRss/136475.htmlhttp://www.shnenglu.com/Wangzhihao/services/trackbacks/136475.html瀵逛簬“鏁版牴”錛堝畾涔夎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).錛夋敞鎰忚繖閲屽彧瀹氫箟姝f暣鏁扮殑“鏁版牴”錛屾墍浠ュ凡緇忔妸 0 鎺掗櫎浜嗐?br>
緇撹: 鏁版牴f(n)涓巒妯?鍚屼綑錛屼笖f(n)鐨勮寖鍥村睘浜嶽1,9].

璇佹槑錛氬鏋渘 = am*10m + am-1*10m-1 +...+ a0*10, 浠(n) = am+am-1+...+a0.    

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

涓棿鐨勬瘡涓幆鑺傞兘鏄ā9鍚屼綑鐨勶紝浼犻掍笅鍘伙紝鎵浠鍜宖(n)涔熸槸妯?鍚屼綑鐨?br>
 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



]]>
sgu 222http://www.shnenglu.com/Wangzhihao/articles/135739.html鐜嬩箣鏄?/dc:creator>鐜嬩箣鏄?/author>Tue, 07 Dec 2010 13:12:00 GMThttp://www.shnenglu.com/Wangzhihao/articles/135739.htmlhttp://www.shnenglu.com/Wangzhihao/comments/135739.htmlhttp://www.shnenglu.com/Wangzhihao/articles/135739.html#Feedback0http://www.shnenglu.com/Wangzhihao/comments/commentRss/135739.htmlhttp://www.shnenglu.com/Wangzhihao/services/trackbacks/135739.html

accept code
 1 
 2 import java.util.Scanner;
 3 import java.util.*;
 4 import java.math.BigInteger;
 5 
 6 class rook{
 7     int n, k;
 8     
 9     long [][]C;
10     
11     rook(int _n, int _k){
12         n = _n;
13         k = _k;
14     }
15     
16     long fac(int k){
17         if(k==0)
18             return 1;
19         else
20             return k * fac(k-1);
21     }
22     
23     long count(){
24         
25         C = new long[n+1][n+1];
26         
27         for(int i = 0; i <= n; i++){
28             C[i][0= C[i][i] = 1;
29             for(int j = 1; j < i; j++)
30                 C[i][j] = C[i-1][j-1+ C[i-1][j];
31         }
32         
33         if(n < k){
34             return 0;
35         }
36         else{
37             long kk = C[n][k];
38             return kk * kk * fac( k );
39         }
40     }
41 }
42 
43 public class Solution{
44     public static void main(String[] args)throws Exception{
45         Scanner sc = new Scanner(System.in);
46         
47         rook r = new rook( sc.nextInt(), sc.nextInt() );
48         
49         System.out.println( r.count() );
50     }    
51 }




]]>
sgu 221http://www.shnenglu.com/Wangzhihao/articles/135733.html鐜嬩箣鏄?/dc:creator>鐜嬩箣鏄?/author>Tue, 07 Dec 2010 12:33:00 GMThttp://www.shnenglu.com/Wangzhihao/articles/135733.htmlhttp://www.shnenglu.com/Wangzhihao/comments/135733.htmlhttp://www.shnenglu.com/Wangzhihao/articles/135733.html#Feedback0http://www.shnenglu.com/Wangzhihao/comments/commentRss/135733.htmlhttp://www.shnenglu.com/Wangzhihao/services/trackbacks/135733.html
棣栧厛絎竴涓瀵熸槸鐧借壊鏍煎瓙鍜岄粦鑹叉牸瀛愭槸鐙珛鐨勶紝鍙互鍒嗗紑鑰冭檻錛屾敞鎰忎簩鑰呬笉涓瀹氬縐般傜劧鍚庢棆杞鐩橈紝寰楀埌涓涓彵褰㈢殑鏈熺浖錛屾敞鎰忓埌琛屽垪欏哄簭鏄棤鍏崇殑錛屾墍浠ュ彲浠ヤ氦鎹㈣鍒楋紝浠庡皬鍒板ぇ寮濮媎p銆?br>
闄勫綍涓錛歛ccept浠g爜錛坉p錛?br>
 1 //dp,榛戜功P243
 2 
 3 import java.util.Scanner;
 4 import java.util.*;
 5 import java.math.BigInteger;
 6 
 7 class biShop{
 8     int n, k;
 9     biShop(int _n, int _k){
10         n = _n;
11         k = _k;
12     }
13     
14     BigInteger [] countOneSide(Vector<Integer> upper){
15         int [] upp = new int[upper.size()];
16         for(int i = 0; i < upp.length; i++){
17             upp[i] = upper.get(i);
18         }
19         Arrays.sort(upp);
20         
21         BigInteger [] pre, now;
22         now = new BigInteger[1]; 
23         now[0= BigInteger.ONE;
24         
25         for(int i = 0; i < upp.length; i++){
26             pre = now;
27             now = new BigInteger[ upp[i] + 1 ];
28             for(int j = 0; j < now.length; j++){
29                 now[j] = BigInteger.ZERO;
30                 if( j < pre.length )
31                     now[j] = now[j].add( pre[j] );
32                 if0 < j && j <= pre.length)
33                     now[j] = now[j]. add( pre[j-1].multiply(BigInteger.valueOf(upp[i] - j + 1)) );
34             }
35         }
36         return now;
37     }
38     
39     BigInteger count(){
40         Vector<Integer> A = new Vector<Integer>();
41         Vector<Integer> B = new Vector<Integer>();
42         
43         A.add(n);
44         for(int i = n-1, j = 0; i > 0; i--, j++){
45             if( (j & 1== 0){
46                 B.add(i);
47                 B.add(i);
48             }else{
49                 A.add(i);
50                 A.add(i);
51             }
52         }
53         
54         BigInteger [] a = countOneSide(A);
55         BigInteger [] b = countOneSide(B);
56         BigInteger res = BigInteger.ZERO;
57         
58         for(int i = 0; i <= k; i++){
59             if(i >= a.length || k - i >= b.length)continue;
60             res = res.add( a[i] .multiply( b[k-i]) );
61         }
62         return res;
63     }
64 }
65 
66 public class Solution{
67     public static void main(String[] args)throws Exception{
68         Scanner sc = new Scanner(System.in);
69         
70         biShop b = new biShop( sc.nextInt(), sc.nextInt() );
71         
72         System.out.println( b.count() );
73     }    
74 }





]]>
sgu 502http://www.shnenglu.com/Wangzhihao/articles/135722.html鐜嬩箣鏄?/dc:creator>鐜嬩箣鏄?/author>Tue, 07 Dec 2010 10:23:00 GMThttp://www.shnenglu.com/Wangzhihao/articles/135722.htmlhttp://www.shnenglu.com/Wangzhihao/comments/135722.htmlhttp://www.shnenglu.com/Wangzhihao/articles/135722.html#Feedback0http://www.shnenglu.com/Wangzhihao/comments/commentRss/135722.htmlhttp://www.shnenglu.com/Wangzhihao/services/trackbacks/135722.html17), 鐜板湪鍙互閲嶆帓 n 鐨勬暟浣嶏紝瀵繪壘涓縐嶆帓鍒椾嬌寰楀叾鑳藉鏁撮櫎 17銆?br>
寮濮嬪啓浜嗕竴涓泦鍚圖P鐨勪唬鐮併傜粨鏋淭LE錛屾劅瑙夋瘮杈冨鎬紝綆楀鏉傚害鏄?7*17*(2^17)=3鍗冨涓囥備笉榪囪繃浜?00+鐨勪漢錛屽仛鍒拌繖閲屽氨鎰熻鑷繁鍋氬鏉備簡銆?br>
鍚庢潵鎵嶅彂鐜扮洿鎺ユ悳鍙互璺戝埌52ms錛屼笉榪囧埌鐜板湪榪樻槸涓嶄細浼拌鎼滅儲鐨勬晥鐜囥傚彧鏄劅瑙夋悳绱㈠緢寮哄ぇ銆?br>


闄勫綍 涓錛歍LE浠g爜錛堥泦鍚圖P錛?br>
 1 import java.util.Scanner;
 2 
 3 class Permutation{
 4     int []digits;
 5     int [][]visit;
 6     int size;
 7     
 8     void read(){
 9         Scanner sc = new Scanner(System.in);
10         String str = sc.next();
11         digits = new int[str.length()];
12         for(int i = 0; i < str.length(); i++)
13             digits[i] = str.charAt(i) - '0';
14     
15         size = 1 << digits.length;
16         visit = new int[size][17];
17         for(int i = 0; i < size; i++)
18             for(int j = 0; j < 17; j++){
19                 visit[i][j] = -1;
20             }
21     }
22     
23     boolean find(int a, int b){
24         
25         if(a==0)return b==0;
26         
27         if(visit[a][b] == 0)return false;
28         if(visit[a][b] == 1)return true;
29             
30         for(int i = 0; i < digits.length; i++){
31             if( ( (1<<i) & a ) == 0)continue;
32             
33             int na = a ^ (1<<i);
34             int nb = (17 + b - digits[i]) * 12 % 17;
35             if(na == 0 && digits[i] == 0continue;
36             
37             if( find( na, nb) ){
38                 visit[a][b] = 1;
39                 return true;
40             }
41         }
42         
43         visit[a][b] = 0;
44         return false;
45     }
46     
47     void print(int a, int b){
48         if( a == 0)return;
49         for(int i = 0; i < digits.length; i++){
50             if( ( (1<<i) & a ) == 0)continue;
51             
52             int na = a ^ (1<<i);
53             int nb = (17 + b - digits[i]) * 12 % 17;
54             if(na == 0 && digits[i] == 0continue;
55             
56             if( find( na, nb) ){
57                 print(na, nb);
58                 System.out.print(digits[i]);
59                 break;
60             }
61         }
62     }
63     
64     void work(){
65         if( find(size-10) )
66         {
67             print(size-10);
68             System.out.println();
69         }
70         else
71             System.out.println(-1);
72     }
73 }
74 
75 public class Solution{
76     public static void main(String[] args)throws Exception{
77         Permutation P = new Permutation();
78         P.read();
79         P.work();
80     }    
81 }

闄勫綍浜岋細Accept浠g爜錛坉fs錛?br>
 1 import java.util.Scanner;
 2 import java.util.Arrays;
 3 class Permutation{
 4     int []digits;
 5     int []ans;
 6     static int size = 10;
 7     
 8     void read(){
 9         Scanner sc = new Scanner(System.in);
10         String str = sc.next();
11         
12         ans = new int[ str.length() ];
13         digits = new int[size];
14         Arrays.fill(digits, 0);
15         
16         for(int i = 0; i < str.length(); i++)
17             digits[ str.charAt(i) - '0' ] ++ ;
18     }
19     
20     boolean dfs(int len, int res){
21         if(len == ans.length)return res == 0;
22         
23         for(int i = 0; i < size; i++){
24             if(i==0 && len == 0)continue;
25             if(digits[i] > 0){
26                 digits[i]--;
27                 
28                 ans[len] = i;
29                 if(dfs(len+1, (res*10 + i) % 17) )return true;
30                 
31                 digits[i]++;
32             }
33         }
34         return false;
35     }
36     
37     void work(){
38         if( dfs(00) ){
39             for(int i = 0; i < ans.length; i++)
40                 System.out.print(ans[i]);
41             System.out.println();
42         }
43         else
44             System.out.println(-1);
45     }
46 }
47 
48 public class Solution{
49     public static void main(String[] args)throws Exception{
50         Permutation P = new Permutation();
51         P.read();
52         P.work();
53     }    
54 }



]]>
久久国产精品无码一区二区三区| 亚洲色欲久久久综合网东京热| 精品国产乱码久久久久久呢| 久久亚洲电影| 久久国产午夜精品一区二区三区| 久久久国产精品网站| 久久亚洲国产精品一区二区| 91久久九九无码成人网站| 99精品久久精品| 丁香五月综合久久激情| 国产成人久久精品二区三区| 久久青青草原精品国产软件 | 精品一二三区久久aaa片| 久久综合亚洲色HEZYO国产| 色悠久久久久久久综合网| 性欧美大战久久久久久久| 伊人久久大香线蕉精品不卡| 久久久久久久久久久| 久久久久亚洲精品无码蜜桃| 国产精品久久久久久久久| 99久久精品免费看国产| 三级韩国一区久久二区综合| 一本色道久久88—综合亚洲精品 | 久久国产精品-久久精品| 久久精品国产99久久久香蕉| 久久国产欧美日韩精品免费| 青青草原综合久久大伊人| 久久国产精品无码一区二区三区| 久久精品国产精品青草| 一级做a爰片久久毛片免费陪| 亚洲精品无码久久千人斩| 91精品国产91久久久久久青草| 要久久爱在线免费观看| 国产69精品久久久久777| 久久夜色精品国产www| 91精品国产91久久综合| 亚洲国产视频久久| 国产福利电影一区二区三区久久老子无码午夜伦不 | 欧美精品丝袜久久久中文字幕| 欧美亚洲色综久久精品国产| 久久亚洲2019中文字幕|