2021.03.18--2021.03.25

3.18

leetcode题:
1.

罗马数字转整数

https://leetcode-cn.com/problems/roman-to-integer/
这题足足写了三个小时。。。

先不考虑特殊规则,遍历s,将所有对应的罗马数字相加;
考虑特殊规则,遍历s;
出现IV或IX序列,整数-2;
出现XL或XC序列,整数-20;
出现CD或CM序列,整数-200;

2.复习考研数学(极限与连续1-2讲)

3.雅思词汇50个,韩语1-2讲

3.19

1.专业课相关:密码学

RSA维纳攻击算法py实现

import ContinuedFractions, Arithmetic, RSAvulnerableKeyGenerator
from Crypto.Util.number import long_to_bytes
from gmpy2 import *
from Crypto.Util import number

def hack_RSA(e,n):
    '''
    Finds d knowing (e,n)
    applying the Wiener continued fraction attack
    '''
    frac = ContinuedFractions.rational_to_contfrac(e, n)
    convergents = ContinuedFractions.convergents_from_contfrac(frac)
    
    for (k,d) in convergents:
        
        #check if d is actually the key
        if k!=0 and (e*d-1)%k == 0:
            phi = (e*d-1)//k
            s = n - phi + 1
            # check if the equation x^2 - s*x + n = 0
            # has integer roots
            discr = s*s - 4*n
            if(discr>=0):
                t = Arithmetic.is_perfect_square(discr)
                if t!=-1 and (s+t)%2==0:
                    print("Hacked!")
                    return d


def hack_RSA1():
    
        e = 12510698434174381708005477765066817419610127968526080594167807853435359414919472818589430357520797048998469284192585147859401229709788209454037515326020063459791596419317683981844652583663310669852418759297979212668512369595505146067905077381750825919444662633953569656128672342340962423964175056525474460377069009696264980558231721453428427750693166952115036237631914065810517401768179229616941309486770389868385325096288673194233892189200743653968629712755108007631558979737658706611826285576985654697897662054126683527427200610756044880520953713457593918049656682608585029569588936092588226610471577331464162697321
        n = 12101912329729737589641462595924233213482813976684036132965838341986187218219239413559865308434879870548661169567918208063164277456627686316547844155039745654282574038675877851483416776162348696164729856916938840008070967266093042320994441262521493079704882979398781412689595846961587603561197598137199552190644415137127304038039294380699526308518217680606679469801722208774852012171124016170016672475942082372988548814034860144144532316419863674087864307239508039364219786825719850572570275416863492256156111823464905682497068144837484385847110433697487335799892565042633559006715304497746414940355541121176771954591
        c = 6345095924537176892939102509084851834144996961449154569289370302204022667119946513913495896182344236671297118430731743822126772210352305554958792139511668352828006579439841379272533312061206820455321448889387797401794308175847204707739877304983482880539604531698066565660805838304117646372920395496202558162741038409798451023450508947201370523715733273269604044419796231091427374594619876862071565242272286577860132515579217851037380265724915500165310393910168400054800698496882400513490249747719051361162741600189260207452204596203420802235988770580036309786997219186772210017149969143771864717829565656459180539188
        d = hack_RSA(e, n) 
        m = pow(c, d, n)
        print(long_to_bytes(m))
    
if __name__ == "__main__":
    #test_is_perfect_square()
    #print("-------------------------")
    hack_RSA1()

2.雅思词汇50,韩语1讲

3.20

1.136 . 只出现一次的数字
https://leetcode-cn.com/problems/single-number/

若第一次出现,插入哈希集,第二次出现,冲哈希集内删除
最后剩下的就是那个只出现一次的数字。

2.考研数学:极限与连续3-4讲

3.21

1.忙了一天学生会的事情。。。
2.雅思词汇50

3.22

1.满课,,加上班级优良学风班的申报,各种杂事。
2.信息安全数学基础:整数与同余,用计算机实现欧几里德算法。
3.雅思词汇45
4.考研数学第五讲

3.23

重新拾起C++ Primer,看了1-20页的内容。课后习题代码写好全部保存。越是经典的书,越能发现自己平时学习的漏洞。有时间要把这本书好好研究一下。

3.24

leetcode
1.108 . 将有序数组转换为二叉搜索树
https://leetcode-cn.com/problems/convert-sorted-array-to-binary-search-tree/

构建父节点——构建父节点的左右子树——选择中间节点作为根节点——将根节点左侧的新数组构建为左子树——将根节点右侧的新数组构建为右子树——递归以上三步,结束条件为数组为空(l > r)

2.考研数学:极限与连续第六讲

3.25

1.大致了解了一下TF变换

总结:这周班级,学生会事情很多全部压在了一起。没有很好分配好时间。下周要好好把ROS的TF变换内容看下。
ROS编程的书已经买到了,476页,暂定每天十页。
不得不承认的是,数据结构的基础不牢。下周打算把青岛大学-王卓老师的数据结构的内容温习一遍。
雅思&&韩语还要继续,大英赛争取能入围省赛

上一篇:CSS hack


下一篇:CSS Hack