ARTS 打卡第三周

Algorithm

Project Euler 25. 1000-digit Fibonacci number
Simple - linear

import java.math.BigInteger;

public class Linear {

    public static void main(String[] args) {
        int i = 1;
        BigInteger fi = BigInteger.ONE, fj = BigInteger.ONE;
        while (fi.toString().length() < 1000) {
            BigInteger fk = fi.add(fj);
            fi = fj;
            fj = fk;
            ++i;
        }
        System.out.println(i);
    }
}

Jump - log linear

import java.math.BigInteger;
import java.util.HashMap;

public class LogLinear {

    public static void main(String[] args) {
        HashMap<Integer, BigInteger> m = new HashMap<>();
        m.put(1, BigInteger.ONE);
        m.put(2, BigInteger.ONE);
        m.put(3, BigInteger.valueOf(2));

        int i = 2;
        while (m.get(i).toString().length() < 1000) {
            m.put(2*i - 1, m.get(i - 1).multiply(m.get(i - 1)).add(m.get(i).multiply(m.get(i))));
            m.put(2*i + 1, m.get(i + 1).multiply(m.get(i + 1)).add(m.get(i).multiply(m.get(i))));
            m.put(2*i, m.get(2*i + 1).subtract(m.get(2*i - 1)));
            i = 2*i;
        }
        i = i/2;

        BigInteger fi = m.get(i), fj = m.get(i + 1);
        while (fi.toString().length() < 1000) {
            BigInteger fk = fi.add(fj);
            fi = fj;
            fj = fk;
            ++i;
        }
        System.out.println(i);
    }
}

Review

Understanding Zero-knowledge proofs through illustrated examples

Properties of zero-knowledge proof system

  • soundness
  • completeness
  • zero-knowledge

sometimes a zero-knowledge proof system is only statistical

Tip

Code reuse approaches

  • Inheritance
  • Composition
  • Mixin
  • Trait

Share

Tacit Knowledge

The software industry overvalues comprehension and explanation.
Knowing how to program is very different from explaining your program, or even understanding the program you just finished writing.

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 秋尽枯干满地飘 日落西山窃冷笑 寻常枝高傲世足 风寒踏过有今朝
    雨洁2018阅读 87评论 0 10
  • 东湖子,健康之歌 勤锻炼,多吃饭 勤劳锻炼体质棒,餐餐吃饱身体棒 多吃蔬菜少吃肉,路边摊来我拒绝 ...
    沈小丁子阅读 414评论 0 0
  • 成长是一个渐渐的过程,做为一名妈妈,她最大的欣慰,就是在他的旁边,见证着孩子渐渐成长的过程。 做为一名妈妈,一位将...
    智爱189阅读 510评论 0 1