# -*- coding: utf-8 -*-
"""
Created on Mon Mar 21 20:38:06 2016
@author: yanjie
"""
'''
1 + 11 + 1111+ 11111+ ..... + 11111(2016个)
结果是几位数
用什么数据结构
有几个6
写算法
'''
a = [];
m = 0;
six = 0;
for i in range(2016,0,-1):
b = (i+m) % 10;
m = (i+m) / 10;
a.append(b)
if b==6:
six = six + 1;
while m>0:
b = m % 10;
m = m /10;
a.append(b)
print len(a) #2016
print six #226
print 'hello'
'''
c = reversed(a)
for i in list(c):
print i,;
'''
package test1;
public class Test1 {
public static void main(String[] args) {
// TODO Auto-generated method stub
fun1();
}
public static void fun1(){
int count = 0;
int jinwei = 0;
int six = 0;
for(int i=2016; i>0; i--){
int b = (i + jinwei)%10;
jinwei = (i + jinwei)/10;
if(b==6){
six++;
}
count++;
}
while(jinwei>0){
jinwei = jinwei/10;
count++;
}
System.out.println(count);
System.out.println("jinwei:"+jinwei);
System.out.println("six:"+six);
}
}