随机数基本使用方法

基本公式:

要取得[a,b)的随机整数,使用(rand() % (b-a))+ a;
要取得[a,b]的随机整数,使用(rand() % (b-a+1))+ a;
要取得(a,b]的随机整数,使用(rand() % (b-a))+ a + 1;
通用公式:a + rand() % n;其中的a是起始值,n是整数的范围。
要取得a到b之间的随机整数,另一种表示:a + (int)b * rand() / (RAND_MAX + 1)。
要取得0~1之间的浮点数,可以使用rand() / double(RAND_MAX)。

Chrome Extension recommendation

First of all, let’s see what extensions I am using now.

my daily extensions

Why do I write the blog?


I was using Microsoft Edge since I am a one hundred percent fan of Microsoft, also because I believe that the original one is the best one just like original desktop wallpaper, original antivirus software and so on. However, I have changed to Google Chrome Browser a few month ago. I realized that Chrome is truly worthy of the name. A multitude of wide-ranging extension, highly personalized costume and super fast response speed are the reason that I love this browser so much.

When I explore the Google Extension Shop, I found many interesting and perfect extensions. After my trying and experiencing, I got a list of the best extension recommended personally. Hope the following extensions would be helpful for you. Feel free to ask any kind of questions in the comment zone at the bottom of the blog!

Google Helper


Function

The name has already indicated the function of the extension which is helping you to surf on google… You can surf on the Internet around the world with it. I recommend it because its stability and stability. Just a Chrome extension can be the global proxy of your computer, which means you are allowed to watch YouTube without using Chrome.

google helper dashboard

It also has a version for mobile phone including IOS and Android.

How to use it

  1. Download Google Chrome Browser and install it.
  2. Download Google Helper and unzip the package.
  3. Open Chrome and type chrome://extensions/ in the address bar. You will find the same page like the following one .
  1. Press Load unpacked and a pop-up will appear. Select your unzip extension folder and confirm.

高精度模板

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
define N 1e5
struct bign
{
int len;
int v[N];

// 赋值 bign=bign
bign operator = (char* s)
{
len=strlen(s);
memset(v,0,sizeof(v));
for(int i=0;i<len;i++)
v[i]=s[len-i-1]-'0';
return *this;
}
//赋值 bign=int
bign operator = (int x)
{
char s[N];
sprintf(s,"%d",x);
return *this=s;
}

// 高精加
bign operator + (const bign &b) const
{
bign c;
memset(c.v,0,sizeof(c.v));
c.len=max(len,b.len);
for(int i=0;i<c.len;i++)
c.v[i]=v[i]+b.v[i];
for(int i=0;i<c.len;i++)
{
c.v[i+1]+=c.v[i]/10;
c.v[i]%=10;
}
if(c.v[c.len]) c.len++;
return c;
}
// 高精乘
bign operator * (const bign &b) const
{
bign c;
memset(c.v,0,sizeof(c.v));
c.len=len+b.len;
for(int i=0;i<len;i++)
for(int j=0;j<b.len;j++)
c.v[i+j]+=v[i]*b.v[j];
for(int i=0;i<len;i++)
{
c.v[i+1]=c.v[i]/10;
c.v[i]%=10;
}
while(c.len>1 && c.v[c.len-1]) c.len--;
return c;
}
// 高精加等于
bign operator += (const bign &b)
{
return *this+b;
}

// 比大小
bool operator < (const bign &b) const
{
if(len<b.len) return 1;
if(len>b.len) return 0;
for(int i=len-1;i>=0;i--)
{
if(v[i]<b.v[i]) return 1;
if(v[i]>b.v[i]) return 0;
}
return 0;//两个数相等返回flase
}

bool operator > (const bign &b) const
{
return b<*this;
}

bool operator <= (const bign &b) const
{
return !(b>*this);
}

bool operator >= (const bign &b) const
{
return !(b<*this);
}

bool operator == (const bign &b) const
{
return (b>*this)^(b<*this)
}
};
Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×