Skip to content

Commit 4f55b68

Browse files
author
wu-kan
committed
博客一篇
1 parent a46aee9 commit 4f55b68

8 files changed

+569
-286
lines changed

_posts/2018-08-14-2018 Multi-University Training Contest 1.md

Lines changed: 238 additions & 219 deletions
Large diffs are not rendered by default.

_posts/2018-09-23-ACM-ICPC 2018 北京赛区网络预赛.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ int main()
239239
{
240240
memset(a,0,sizeof(a));
241241
for (int j=1;j<=k;++j) {scanf("%d",&a[j].x);a[j].id=j;}
242-
for (int j=1;j<=k;++j)
242+
for (int j=1;j<=k;++j)
243243
{
244244
a[j].x=a[j].x-c[j];
245245
if(a[j].x<0) {a[j].x=-a[j].x;a[j].minus=true;}
@@ -248,7 +248,7 @@ int main()
248248
int res=r;
249249
for (int j=1;j<=k;++j)
250250
{
251-
if ((a[j].x-a[j+1].x)*j<=res)
251+
if ((a[j].x-a[j+1].x)*j<=res)
252252
{
253253
res-=(a[j].x-a[j+1].x)*j;
254254
}
@@ -260,7 +260,7 @@ int main()
260260
}
261261
}
262262
sort(a+1,a+k+1,cmpid);
263-
for (int j=1;j<=k;++j)
263+
for (int j=1;j<=k;++j)
264264
if (a[j].minus) printf("%.5lf ",-a[j].ans+c[j]);
265265
else printf("%.5lf ",a[j].ans+c[j]);
266266
puts("");

_posts/2018-11-23-单周期CPU设计.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ categories: 计算机组成原理
3535
### andi rt rs immediate
3636

3737
|010000|rs(5位)|rt(5位)|immediate(16位)|
38-
|-|-|-|-|-|
39-
||||||
38+
|-|-|-|-|
39+
|||||
4040

4141
功能:rt←rs & (zero-extend)immediate;immediate做“0”扩展再参加“与”运算。
4242
### and rd rs rt

_posts/2019-01-25-C++语言相关.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ lf getlf(FILE *in = stdin)
5959
struct Istream
6060
{
6161
char b[20 << 20], *i, *e; //20MB
62-
Istream(FILE *in) : i(b), e(b + fread(b, sizeof(*b), sizeof(b) - 1, in)) {}
62+
Istream(FILE *in) : i(b), e(b + fread(b, sizeof(*b), sizeof(b), in)) {}
6363
bool eof() const
6464
{
6565
return i == e;

_posts/2019-01-26-高精度.md

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -131,19 +131,19 @@ struct Wint : vector<int> //继承vector
131131
}
132132
Wint& operator*=(const Wint &b)//fft优化乘法,注意double仅15位有效数字,调小Wint::width不超过2,计算自2*log2(base)+2*log2(len)<53
133133
{
134-
vector<ll> ax(begin(),end()),bx(b.begin(),b.end());
135-
ax=FFT(size()+b.size()).ask(ax,bx);
136-
for(int i=1; i<ax.size(); ++i)
137-
ax[i]+=ax[i-1]/base,ax[i-1]%=base;
138-
return assign(ax.begin(),ax.end()),trim(0);
134+
vector<ll> ax(begin(),end()),bx(b.begin(),b.end());
135+
ax=FFT(size()+b.size()).ask(ax,bx);
136+
for(int i=1; i<ax.size(); ++i)
137+
ax[i]+=ax[i-1]/base,ax[i-1]%=base;
138+
return assign(ax.begin(),ax.end()),trim(0);
139139
}
140140
Wint& operator*=(const Wint &b)//ntt优化,Wint::width不超过2
141141
{
142-
vector<ll> ax(begin(),end()),bx(b.begin(),b.end());
143-
ax=FNTT(size()+b.size(),(7<<26)+1,3).ask(ax,bx);
144-
for(int i=1; i<ax.size(); ++i)
145-
ax[i]+=ax[i-1]/base,ax[i-1]%=base;
146-
return assign(ax.begin(),ax.end()),trim(0);
142+
vector<ll> ax(begin(),end()),bx(b.begin(),b.end());
143+
ax=FNTT(size()+b.size(),(7<<26)+1,3).ask(ax,bx);
144+
for(int i=1; i<ax.size(); ++i)
145+
ax[i]+=ax[i-1]/base,ax[i-1]%=base;
146+
return assign(ax.begin(),ax.end()),trim(0);
147147
}
148148
*/
149149
friend Wint operator*(Wint a, const Wint &b) { return a *= b; }
@@ -220,27 +220,27 @@ struct Wint : vector<int> //继承vector
220220
/*
221221
friend Wint sqrt(const Wint &a)//常规牛顿迭代实现的开平方算法,慢但是好敲
222222
{
223-
Wint b=a,c=(b+1)/2;
224-
while(b!=c)swap(b,c),c=(b+a/b)/2;
225-
return c;
223+
Wint b=a,c=(b+1)/2;
224+
while(b!=c)swap(b,c),c=(b+a/b)/2;
225+
return c;
226226
}
227227
friend Wint sqrt(const Wint &a)
228228
{
229-
Wint ret,t;
230-
ret.assign((a.size()+1)>>1,0);
231-
for(int i=ret.size()-1,l,r; ~i; --i)
232-
{
233-
for(l=0,r=a.base; r-l>1;)
234-
{
235-
ret[i]=l+(r-l)/2;
236-
t=ret*ret;
237-
if(a<t)r=ret[i];
238-
else l=ret[i];
239-
}
240-
if(!l&&i==ret.size()-1)ret.pop_back();
241-
else ret[i]=l;
242-
}
243-
return ret;
229+
Wint ret,t;
230+
ret.assign((a.size()+1)>>1,0);
231+
for(int i=ret.size()-1,l,r; ~i; --i)
232+
{
233+
for(l=0,r=a.base; r-l>1;)
234+
{
235+
ret[i]=l+(r-l)/2;
236+
t=ret*ret;
237+
if(a<t)r=ret[i];
238+
else l=ret[i];
239+
}
240+
if(!l&&i==ret.size()-1)ret.pop_back();
241+
else ret[i]=l;
242+
}
243+
return ret;
244244
}
245245
*/
246246
};

_posts/2019-02-01-数论.md

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ struct Rader : vector<int>
257257
};
258258
```
259259
### 快速傅里叶变换
260-
[使用示例](https://vjudge.net/solution/16891011),高精度乘法。
260+
[使用示例](https://vjudge.net/solution/19528209),高精度乘法。
261261
```cpp
262262
struct FFT : Rader
263263
{
@@ -277,8 +277,8 @@ struct FFT : Rader
277277
for (int j = 0; j < i; ++j)
278278
for (int k = j; k < size(); k += i << 1)
279279
{
280-
complex<lf> &l = x[k], &r = x[k + i], t = w[size() / (i << 1) * j] * r;
281-
r = l - t, l += t;
280+
complex<lf> t = w[size() / (i << 1) * j] * x[k + i];
281+
x[k + i] = x[k] - t, x[k] += t;
282282
}
283283
return x;
284284
}
@@ -303,7 +303,7 @@ struct FFT : Rader
303303

304304
[常见素数的原根](https://blog.csdn.net/hnust_xx/article/details/76572828)
305305

306-
[使用示例](https://vjudge.net/solution/18274507)
306+
[使用示例](https://vjudge.net/solution/19528002)
307307
```cpp
308308
struct FNTT : Rader, Mod
309309
{
@@ -319,15 +319,12 @@ struct FNTT : Rader, Mod
319319
vector<ll> x(size());
320320
for (int i = 0; i < a.size(); ++i)
321321
x[at(i)] = a[i];
322-
for (int i = 1; i < size(); i <<= 1)
322+
for (int i = 1, j; i < size(); i <<= 1)
323323
for (int j = 0; j < i; ++j)
324324
for (int k = j; k < size(); k += i << 1)
325325
{
326326
ll t = mul(w[size() / (i << 1) * j], x[k + i]);
327-
if (x[k + i] = x[k] - t, x[k + i] < 0)
328-
x[k + i] += M;
329-
if (x[k] += t, x[k] >= M)
330-
x[k] -= M;
327+
x[k + i] = qadd(x[k], M - t), x[k] = qadd(x[k], t);
331328
}
332329
return x;
333330
}

_posts/2019-02-03-数据结构.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -626,30 +626,30 @@ struct HashString : Mod
626626
```cpp
627627
struct KMP
628628
{
629-
const string s;
630-
vector<int> next;
631-
KMP(const string &s) : s(s), next(s.size() + 1, 0)
632-
{
633-
for (int i = 1, j; i < s.size(); ++i)
634-
{
635-
for (j = next[i]; j && s[i] != s[j];)
636-
j = next[j];
637-
next[i + 1] = s[i] == s[j] ? j + 1 : 0;
638-
}
639-
}
640-
bool find_in(const string &t)
641-
{
642-
for (int i = 0, j = 0; i < t.size(); ++i)
643-
{
644-
while (j && s[j] != t[i])
645-
j = next[j];
646-
if (s[j] == t[i])
647-
++j;
648-
if (j == s.size())
649-
return 1; //不return可得到t中s的所有匹配地址i+1-s.size()
650-
}
651-
return 0;
652-
}
629+
const string s;
630+
vector<int> next;
631+
KMP(const string &s) : s(s), next(s.size() + 1, 0)
632+
{
633+
for (int i = 1, j; i < s.size(); ++i)
634+
{
635+
for (j = next[i]; j && s[i] != s[j];)
636+
j = next[j];
637+
next[i + 1] = s[i] == s[j] ? j + 1 : 0;
638+
}
639+
}
640+
bool find_in(const string &t)
641+
{
642+
for (int i = 0, j = 0; i < t.size(); ++i)
643+
{
644+
while (j && s[j] != t[i])
645+
j = next[j];
646+
if (s[j] == t[i])
647+
++j;
648+
if (j == s.size())
649+
return 1; //不return可得到t中s的所有匹配地址i+1-s.size()
650+
}
651+
return 0;
652+
}
653653
};
654654
```
655655
### AC自动机

0 commit comments

Comments
 (0)