y - stage this hunkn - do not stage this hunkq - quit; do not stage this hunk or any of the remaining onesa - stage this hunk and all later hunks in the filed - do not stage this hunk or any of the later hunks in the fileg - select a hunk to go to/ - search for a hunk matching the given regexj - leave this hunk undecided, see next undecided hunkJ - leave this hunk undecided, see next hunke - manually edit the current hunk? - print help
这样公式大体就出来了, 然后, 我们需要再考虑下f(N, M) - M是负数的情况
于是公式就变成了这样
f(N-1, M) = (f(N, M) - M) % (N-1)
然后, 我们用逆向思维, 倒过来
f(N, M) = (f(N-1, M) + M) % N
12345678910111213
#include<iostream>usingnamespacestd;intmain(){// f(1, M) = 0int r = 0, n = 11, m = 3;for (int i = 2; i <= n; ++i) { r = (r + m) % i; }cout << r << endl;return0;}
❯ gpg --expert --edit-key your_id ## 使用专家模式, 不然没有认证的选项gpg (GnuPG) 2.2.12; Copyright (C) 2018 Free Software Foundation, Inc.This is free software: you are free to change and redistribute it.There is NO WARRANTY, to the extent permitted by law.Secret key is available.sec rsa2048/7DEFA5351BCE3C55 created: 2019-01-07 expires: 2021-01-06 usage: SC trust: ultimate validity: ultimatessb rsa2048/2FCE923F8ECB63F6 created: 2019-01-07 expires: 2021-01-06 usage: E[ultimate] (1). hhhhh <h@mail.com>gpg> addkeyPlease select what kind of key you want: (3) DSA (sign only) (4) RSA (sign only) (5) Elgamal (encrypt only) (6) RSA (encrypt only) (7) DSA (set your own capabilities) (8) RSA (set your own capabilities) (10) ECC (sign only) (11) ECC (set your own capabilities) (12) ECC (encrypt only) (13) Existing keyYour selection? 8 ## 选8, RSA, 自定义权限Possible actions for a RSA key: Sign Encrypt AuthenticateCurrent allowed actions: Sign Encrypt ## 这里显示默认有Sign和Encrypt两种权限 (S) Toggle the sign capability (E) Toggle the encrypt capability (A) Toggle the authenticate capability (Q) FinishedYour selection? S ## 关闭SignPossible actions for a RSA key: Sign Encrypt AuthenticateCurrent allowed actions: Encrypt (S) Toggle the sign capability (E) Toggle the encrypt capability (A) Toggle the authenticate capability (Q) FinishedYour selection? E ## 关闭EncryptPossible actions for a RSA key: Sign Encrypt AuthenticateCurrent allowed actions: (S) Toggle the sign capability (E) Toggle the encrypt capability (A) Toggle the authenticate capability (Q) FinishedYour selection? A ## 开启AuthenticatePossible actions for a RSA key: Sign Encrypt AuthenticateCurrent allowed actions: Authenticate (S) Toggle the sign capability (E) Toggle the encrypt capability (A) Toggle the authenticate capability (Q) FinishedYour selection? Q ## 退出RSA keys may be between 1024 and 4096 bits long.What keysize do you want? (2048) 4096Requested keysize is 4096 bitsPlease specify how long the key should be valid. 0 = key does not expire <n> = key expires in n days <n>w = key expires in n weeks <n>m = key expires in n months <n>y = key expires in n yearsKey is valid for? (0) 1y ## 有效期Key expires at Tue Jan 7 11:33:54 2020 CSTIs this correct? (y/N) yReally create? (y/N) yWe need to generate a lot of random bytes. It is a good idea to performsome other action (type on the keyboard, move the mouse, utilize thedisks) during the prime generation; this gives the random numbergenerator a better chance to gain enough entropy.sec rsa2048/7DEFA5351BCE3C55 created: 2019-01-07 expires: 2021-01-06 usage: SC trust: ultimate validity: ultimatessb rsa2048/2FCE923F8ECB63F6 created: 2019-01-07 expires: 2021-01-06 usage: Essb rsa4096/19D32A8839DCAA1F created: 2019-01-07 expires: 2020-01-07 usage: A[ultimate] (1). hhhhh <h@mail.com>gpg> save ## 保存