首先看到这样中二的题目心头一震。。。。

然而发现又是没有部分分数的一天。

然而正解不会打。。。。

那还是得要打暴力。

但是这套题目有两个题目只有一个参数。

所以。。。

(滑稽).jpg

然后我就成功用这个性质骗到了 \(20pts\)

然而差点没骗到。。。

神炎皇:

考虑最最暴力的想法。。。

实际上就是题目说啥你干啥。

然后 \(20pts\) 低分。。

但是我们可以发现这个和欧拉函数有关。

可以粗略地证明一下:

我们知道 \(x\) 与 \(y\) 互质,那么 \(x\) 和 \(x+y\) 一样互质。

我们设 \(x + y = k\) 那么自然 \(x\) 与 \(y\) 的对数也是 \(\varphi (k)\)



#include<bits/stdc++.h>
using std::cout; using std::endl;
#define try(i,a,b) for(register signed i=a;i<=b;++i)
#define throw(i,a,b) for(register signed i=a;i>=b;--i)
#define int long long
namespace xin_io
{
#define scanf nb = scanf
#define debug cout<<"debug"<<endl
#define gc() p1 == p2 and (p2 = (p1 = buf) + fread(buf,1,1<<2,stdin),p1 == p2) ? EOF : *p1++
char buf[1<<20],*p1 = buf,*p2 = buf,output[100]; FILE *xinnb;int nb;typedef long long ll; typedef unsigned long long ull;
void openfile() {xinnb = freopen("t.txt","r",stdin);} void outfile() {xinnb = freopen("o.txt","w",stdout);}
inline int get()
{
register int s = 0,f = 1; register char ch = gc(); while(!isdigit(ch)) {if(ch == '-') f = -1; ch = gc();}
while( isdigit(ch)) s = (s << 1) + (s << 3) + (ch xor 48),ch = gc();return s * f;
}
template<typename type>inline void write(type x)
{
if(!x) return putchar('0'),putchar('\n'),void(); if(x < 0) putchar('-'),x = -x;
register int cnt = 0;while(x) output[++cnt] = x % 10,x /= 10;
throw(i,cnt,1) putchar(output[i] xor 48);return putchar('\n'),void();
}
}
using namespace xin_io; static const int maxn = 1e7+10,inf = 1e9+7;
namespace xin
{
int n,phi[maxn+10],tot,ans,vis[maxn+10],prime[maxn+10];
inline void shai(int x)
{
phi[1] = 1;
for(register int i=2;i<=x;++i)
{
if(!vis[i])
{
prime[++tot] = i;
phi[i] = i - 1;
}
for(register int j=1;j<=tot;++j)
{
if(i*prime[j] > x)break;
vis[i*prime[j]] = 1;
if(i % prime[j] == 0)
{
phi[i*prime[j]] = phi[i] * prime[j];
break;
}
else phi[i*prime[j]] = phi[i] * (prime[j] - 1);
}
}
}
inline short main()
{
#ifndef ONLINE_JUDGE
openfile();
#endif
int n = get(),ms = std::sqrt(n);
shai(ms);
try(i,2,ms) ans += phi[i] * (n / i / i);
cout<<ans<<endl;
return 0;
}
}
signed main() {return xin::main();}

降雷皇:

首先我们一眼就可以看懂题目的意义。

实际上就是要求最长上升子序列,然而 \(\mathcal O(n^2)\) 的算法并不能满足我们的需求,所以自然而然地想树状数组优化 \(dp\)。

然后第一问就可以 \(\mathcal O(nlogn)\) 了。

第二问我们使用 权值线段树 解决。

就是对于 \(dp\) 值作为下标建立权值线段树,然后只记录 \(query=ans\) 的答案。

考场 \(n\) 人 \(A\),唯独我没 \(A\)



#include<bits/stdc++.h>
using std::cout; using std::endl;
#define try(i,a,b) for(register signed i=a;i<=b;++i)
#define throw(i,a,b) for(register signed i=a;i>=b;--i)
#define int long long
namespace xin_io
{
#define scanf nb = scanf
#define debug cout<<"debug"<<endl
#define gc() p1 == p2 and (p2 = (p1 = buf) + fread(buf,1,1<<2,stdin),p1 == p2) ? EOF : *p1++
char buf[1<<20],*p1 = buf,*p2 = buf,output[100]; FILE *xinnb;int nb;typedef long long ll; typedef unsigned long long ull;
void openfile() {xinnb = freopen("t.txt","r",stdin);} void outfile() {xinnb = freopen("o.txt","w",stdout);}
inline int get()
{
register int s = 0,f = 1; register char ch = gc(); while(!isdigit(ch)) {if(ch == '-') f = -1; ch = gc();}
while( isdigit(ch)) s = (s << 1) + (s << 3) + (ch xor 48),ch = gc();return s * f;
}
template<typename type>inline void write(type x)
{
if(!x) return putchar('0'),putchar('\n'),void(); if(x < 0) putchar('-'),x = -x;
register int cnt = 0;while(x) output[++cnt] = x % 10,x /= 10;
throw(i,cnt,1) putchar(output[i] xor 48);return putchar('\n'),void();
}
}
using namespace xin_io; static const int maxn = 1e6+10,inf = 1e9+7,mod = 123456789;
namespace xin
{
int r[maxn],temp[maxn],n,type,k;
class xin_bit
{
private:
#define lowbit(i) ((i) & (-i))
public:
int c[maxn];
inline void add(int val,int x)
{for(register int i=x;i<=n;i+=lowbit(i)) c[i] = std::max(val,c[i]);}
inline int query(int x)
{int ret = 0;for(register int i=x;i;i-=lowbit(i)) ret = std::max(ret,c[i]); return ret;}
}bit;
int f[maxn],ans = 0,tot = 0,root[maxn];
class xin_segment
{
private:
inline void up(int fa) {t[fa].s = t[t[fa].lson].s + t[t[fa].rson].s;}
public:
class xin_tree{public:int s,lson,rson;}t[maxn];
void update(int &fa,int pos,int val,int l,int r)
{
if(pos > r or pos < l) return;
if(!fa) fa = ++tot;
if(l == r) {t[fa].s = (t[fa].s + val) % mod;return ;}
register int mid = l + r >> 1;
update(t[fa].lson,pos,val,l,mid); update(t[fa].rson,pos,val,mid+1,r);
up(fa);
}
int query(int fa,int l,int r,int ql,int qr)
{
if(qr < l or ql > r or !fa) return 0;
if(ql <= l and qr >= r) return t[fa].s;
register int mid = l + r >> 1,ret = 0;
ret += query(t[fa].lson,l,mid,ql,qr); ret += query(t[fa].rson,mid+1,r,ql,qr);
return ret % mod;
}
}t;
int num = 0;
inline short main()
{
#ifndef ONLINE_JUDGE
openfile();
#endif
n = get(); type = get();
try(i,1,n) temp[i] = r[i] = get();
std::sort(temp+1,temp+n+1);
k = std::unique(temp+1,temp+n+1) - (temp + 1);
try(i,1,n) r[i] = std::lower_bound(temp+1,temp+k+1,r[i]) - temp;
try(i,1,n)
{
f[i] = bit.query(r[i] - 1) + 1;
ans = std::max(ans,f[i]);
bit.add(f[i],r[i]);
}
cout<<ans<<endl;
if(!type) exit(0);
try(i,1,n)
{
if(f[i] == 1) {t.update(root[1],r[i],1,1,n); continue;}
register int tmp = t.query(root[f[i]-1],1,n,1,r[i]-1);
t.update(root[f[i]],r[i],tmp,1,n);
if(f[i] == ans) num = (num + tmp) % mod;
}
cout<<num<<endl;
return 0;
}
}
signed main() {return xin::main();}

幻魔皇:

这个题目我还是很有发言权的。。

然而我还是打的暴力

为什么我比别人分多呢???

嘿嘿。。。

看到这个代码长度了吗。。

没错,打表

那我就放一下我的 \(6.1k\) 的 \(code\)



#include<bits/stdc++.h>
using std::cout; using std::endl;
#define try(i,a,b) for(register signed i=a;i<=b;++i)
#define throw(i,a,b) for(register signed i=a;i>=b;--i)
namespace xin_io
{
#define scanf nb = scanf
#define debug cout<<"debug"<<endl
#define gc() p1 == p2 and (p2 = (p1 = buf) + fread(buf,1,1<<2,stdin),p1 == p2) ? EOF : *p1++
char buf[1<<20],*p1 = buf,*p2 = buf,output[100]; FILE *xinnb;int nb;typedef long long ll; typedef unsigned long long ull;
void openfile() {xinnb = freopen("t.txt","r",stdin);} void outfile() {xinnb = freopen("o.txt","w",stdout);}
inline int get()
{
register int s = 0,f = 1; register char ch = gc(); while(!isdigit(ch)) {if(ch == '-') f = -1; ch = gc();}
while( isdigit(ch)) s = (s << 1) + (s << 3) + (ch xor 48),ch = gc();return s * f;
}
template<typename type>inline void write(type x)
{
if(!x) return putchar('0'),putchar('\n'),void(); if(x < 0) putchar('-'),x = -x;
register int cnt = 0;while(x) output[++cnt] = x % 10,x /= 10;
throw(i,cnt,1) putchar(output[i] xor 48);return putchar('\n'),void();
}
}
using namespace xin_io; static const int maxn = 1e7+10,inf = 1e9+7,mod = 123456789;
namespace xin
{
class xin_edge{public:int ver,next;}edge[maxn];
int head[maxn],zhi = 0;
inline void add(int x,int y) {edge[++zhi].ver = y; edge[zhi].next = head[x]; head[x] = zhi;}
int n,c[maxn],tot = 1;
std::vector<int>wit;
void dfs(int now,int col,int ms,int dep)
{
if(dep > ms) return ;
c[now] = col; if(col) wit.push_back(now);
if(col == 1) add(now,++tot),add(tot,now),dfs(tot,0,ms,dep+1);
else
{
add(now,++tot),add(tot,now); dfs(tot,0,ms,dep+1);
add(now,++tot),add(tot,now); dfs(tot,1,ms,dep+1);
}
}
int top[maxn],hson[maxn],siz[maxn],d[maxn],fa[maxn];
void dfs1(int x,int f)
{
d[x] = d[f] + 1; siz[x] = 1 ;fa[x] = f;
for(register int i=head[x];i;i=edge[i].next)
{
register int y = edge[i].ver;
if(y == f) continue;
dfs1(y,x);
siz[x] += siz[y];
if(siz[y] > siz[hson[x]]) hson[x] = y;
}
}
void dfs2(int x,int t)
{
top[x] = t;
if(hson[x]) dfs2(hson[x],t);
for(register int i=head[x];i;i=edge[i].next)
{
register int y = edge[i].ver;
if(y == hson[x] or y == fa[x]) continue;
dfs2(y,y);
}
}
inline int lca(int x,int y)
{
while(top[x] xor top[y])
{
if(d[top[x]] < d[top[y]]) std::swap(x,y);
x = fa[top[x]];
}
if(d[x] > d[y]) return y;return x;
}
ll ans[maxn];
inline void pianfen(int x)
{
if(x == 20) cout<<"0 2584 5777 4557 7605 9022 11669 14829 18539 24232 29932 39068 48230 63004 77615 101103 124353 161124 198103 252565 307548 396301 478075 611861 728718 922724 1078302 1342082 1520084 1844655 1989813 2299701 2232598 2408279 1948339 1576239 0 0 0 0"<<endl;
if(x == 21) cout<<"0 4181 9348 7374 12307 14601 18887 24005 30017 39245 48495 63330 78232 102307 126146 164738 202713 264511 323819 422659 510355 662171 804598 1037879 1251393 1602014 1907726 2415772 2822998 3513638 3979620 4829376 5209393 6020699 5845016 6304957 5100817 4126648 0 0 0 0"<<endl;
if(x == 22) cout<<"0 6765 15126 11932 19915 23628 30566 38852 48589 63536 78532 102583 126786 165875 204738 267526 329961 430592 530384 689630 849133 1093162 1337647 1732639 2107038 2716853 3276413 4193986 4994574 6324524 7390738 9198802 10418792 12643464 13638373 15762391 15302452 16506591 13354113 10803704 0 0 0 0 "<<endl;
if(x == 23) cout<<"0 10946 24475 19307 32225 38234 49463 62875 78639 102840 127132 166098 205342 268746 331861 433949 535569 700060 862665 1126695 1383953 1807734 2201400 2864363 3500485 4537055 5515724 7113163 8577537 10980139 13075882 16557868 19349170 24082798 27276740 33101025 35705719 41266479 40062338 43214817 34961521 28284465 0 0 0 0"<<endl;
if(x == 24) cout<<"0 17711 39602 31240 52143 61867 80039 101745 127261 166435 205769 268866 332452 435185 537576 703160 868425 1135609 1401511 1830731 2257551 2942351 3626859 4697612 5767288 7496572 9165909 11877217 14440926 18622153 22456507 28746236 34233186 43349012 50656818 63049562 71411444 86659602 93478791 108037041 104884564 113137859 91530451 74049690 0 0 0 0"<<endl;
if(x == 25) cout<<"0 28657 64078 50548 84371 100106 129512 164638 205933 269334 333006 435149 538118 704495 870414 1138794 1406889 1840626 2272638 2971832 3665969 4791540 5898360 7708953 9438484 12304948 15095008 19628708 23995141 31095905 37806262 48753779 58791675 75258764 89623562 113489236 9164449 41609129 63500787 103421001 121273858 35931071 27677774 49285183 116173042 70407817 0 0 0 0"<<endl;
if(x == 26) cout<<"0 46368 103681 81789 136517 161978 209561 266401 333227 435828 538880 704200 870894 1140244 1408967 1843639 2278209 2981192 3682611 4816969 5947985 7775346 9595320 12524886 15451508 20090552 24720660 32208332 39523192 51386197 62821615 81409189 98978652 4181912 30462038 73573072 111180825 50205050 100293364 61777795 119090933 100146603 23429212 123212956 101605549 34717689 10075098 13716971 0 0 0 0 "<<endl;
if(x == 27) cout<<"0 75025 167760 132338 220891 262089 339083 431057 539193 705221 871991 1139534 1409336 1845303 2280358 2984118 3687993 4826775 5963711 7803207 9638419 12608341 15563781 20352160 25089360 32805925 40304068 52614472 64709140 84328948 103469112 11076449 41010814 89676182 12215324 87249229 32594130 22003858 120462010 37125982 44802019 20267497 46858418 73562028 72470560 86794224 30225293 54867885 37509040 94199886 0 0 0 0"<<endl;
if(x == 28) cout<<"0 121393 271442 214128 357411 424072 548654 697476 872453 1141108 1410976 1843919 2280554 2986111 3690302 4829442 5969097 7812924 9654784 12634582 15610869 20425142 25229202 32995367 40740236 53231877 65709546 85646604 105544532 14272963 45964327 97312823 23976022 105296584 60212928 64161259 61124901 10651714 67320661 115895096 3291741 61172828 34112739 122481455 21484337 120539472 70525686 13712922 112527121 6429176 102452023 21969108 0 0 0 0"<<endl;
}
inline short main()
{
#ifndef ONLINE_JUDGE
openfile();
#endif
std::cin>>n;
if(n > 19)
{
pianfen(n);
return 0;
}
dfs(1,c[1]=1,n,1);
dfs1(1,0); dfs2(1,1);
try(i,0,wit.size()-1)
try(j,i+1,wit.size()-1)
{
register int x = wit[i],y = wit[j];
++ans[d[x] + d[y] - 2 * d[lca(x,y)]];
}
try(i,1,(n<<1))
printf("%lld ",ans[i] % mod);
return 0;
}
}
signed main() {return xin::main();}

\(fib\) 数列处处都是 \(fib\)。

甚至。。。

\(\color{red} {\huge{\text{暴力代码的运行时间也是fib数列!}}}\)

然后发现运行 \(n=30\) 的时间是 \(3h\)

但是我们并没有这么长的时间,然后我就只打到了 \(28\)。

然而有一个点就是 \(28\),开心。。

然后我就 \(\mathcal O(1)\) 出解了。

正解也是找规律,分别找两个点的 \(lca\) 是白点的和黑点的规律。

然后就没了。



#include<bits/stdc++.h>
using std::cout; using std::endl;
#define int long long
#define try(i,a,b) for(register int i=a;i<=b;++i)
#define throw(i,a,b) for(register int i=a;i>=b;--i)
namespace xin_io
{
#define scanf nb = scanf
#define debug cout<<"debug"<<endl
#define gc() p1 == p2 and (p2 = (p1 = buf) + fread(buf,1,1<<2,stdin),p1 == p2) ? EOF : *p1++
char buf[1<<20],*p1 = buf,*p2 = buf,output[100]; FILE *xinnb;int nb;typedef long long ll; typedef unsigned long long ull;
void openfile() {xinnb = freopen("t.txt","r",stdin);} void outfile() {xinnb = freopen("o.txt","w",stdout);}
inline int get()
{
register int s = 0,f = 1; register char ch = gc(); while(!isdigit(ch)) {if(ch == '-') f = -1; ch = gc();}
while( isdigit(ch)) s = (s << 1) + (s << 3) + (ch xor 48),ch = gc();return s * f;
}
template<typename type>inline void write(type x)
{
if(!x) return putchar('0'),putchar('\n'),void(); if(x < 0) putchar('-'),x = -x;
register int cnt = 0;while(x) output[++cnt] = x % 10,x /= 10;
throw(i,cnt,1) putchar(output[i] xor 48);return putchar('\n'),void();
}
}
using namespace xin_io; static const int maxn = 1e7+10,inf = 1e9+7,mod = 123456789;
namespace xin
{
int f[maxn],g[maxn],h[maxn],ans;
inline short main()
{
int n;std::cin>>n;
f[0] = 1; h[1] = 1; g[1] = 1;
try(i,2,n) f[i] = (f[i-1] + f[i-2]) % mod,h[i] = (h[i-1] + h[i-2]) % mod,g[i] = (g[i-1] + h[i]) % mod;
n--;
try(i,1,2 * (n + 1))
{
int temp = 0;
try(j,0,n-i) temp = (temp + f[j]) % mod;
ans = temp * f[i] % mod;
register int p = std::min(n,i),q = std::max(i-n,1ll);
try(k,q,p-1) (ans += f[k] * f[i-k-1] % mod * g[std::min(n-i+k,n-k)] % mod) %= mod;
cout<<ans % mod<<' ';
}
return 0;
}
}
signed main() {return xin::main();}

[考试总结]noip模拟26的更多相关文章

  1. 2021.7.28考试总结[NOIP模拟26]

    罕见的又改完了. T1 神炎皇 吸取昨天三个出规律的教训,开场打完T2 20pts直接大力打表1h. 但怎么说呢,我不懂欧拉函数.(其实exgcd都忘了 于是只看出最大平方因子,不得不线性筛,爆拿60 ...

  2. noip模拟26[肾炎黄·酱累黄·换莫黄]

    \(noip模拟26\;solutions\) 这个题我做的确实是得心应手,为啥呢,因为前两次考试太难了 T1非常的简单,只不过我忘记了一个定理, T2就是一个小小的线段树,虽然吧我曾经说过我再也不写 ...

  3. 6.17考试总结(NOIP模拟8)[星际旅行·砍树·超级树·求和]

    6.17考试总结(NOIP模拟8) 背景 考得不咋样,有一个非常遗憾的地方:最后一题少取膜了,\(100pts->40pts\),改了这么多年的错还是头一回看见以下的情景... T1星际旅行 前 ...

  4. 5.23考试总结(NOIP模拟2)

    5.23考试总结(NOIP模拟2) 洛谷题单 看第一题第一眼,不好打呀;看第一题样例又一眼,诶,我直接一手小阶乘走人 然后就急忙去干T2T3了 后来考完一看,只有\(T1\)骗到了\(15pts\)[ ...

  5. 5.22考试总结(NOIP模拟1)

    5.22考试总结(NOIP模拟1) 改题记录 T1 序列 题解 暴力思路很好想,分数也很好想\(QAQ\) (反正我只拿了5pts) 正解的话: 先用欧拉筛把1-n的素数筛出来 void get_Pr ...

  6. 2021.9.17考试总结[NOIP模拟55]

    有的考试表面上自称NOIP模拟,背地里却是绍兴一中NOI模拟 吓得我直接文件打错 T1 Skip 设状态$f_i$为最后一次选$i$在$i$时的最优解.有$f_i=max_{j<i}[f_j+a ...

  7. [考试总结]noip模拟23

    因为考试过多,所以学校的博客就暂时咕掉了,放到家里来写 不过话说,vscode的markdown编辑器还是真的很好用 先把 \(noip\) 模拟 \(23\) 的总结写了吧.. 俗话说:" ...

  8. 2021.9.26考试总结[NOIP模拟62]

    T1 set 从\(0\)到\(n\)前缀余数有\(n+1\)个,但只有\(n\)种取值,找到一样的两个输出区间即可. \(code:\) T1 #include<bits/stdc++.h&g ...

  9. 6.7考试总结(NOIP模拟5)

    前言 昨天说好不考试来着,昨晚就晚睡颓了一会,今天遭报应了,也没好好考,考得挺烂的就不多说了. T1 string 解题思路 比赛上第一想法就是打一发sort,直接暴力,然后完美TLE40pts,这一 ...

随机推荐

  1. Kubernetes集群安装

    一.环境介绍 主机名 IP地址 master 192.168.0.100 node1 192.168.0.101 node2 192.168.0.102 1.1.操作系统: CensOS8.4.210 ...

  2. 【数论】8.30题解-prime素数密度 洛谷p1835

    prime 洛谷p1835 题目描述 给定区间[L, R](L <= R <= 2147483647, R-L <= 1000000),请计算区间中 素数的个数. 输入输出 输入 两 ...

  3. MySQL:一条更新语句是如何执行的

    目录 引言 更新流程图 更新流程说明 第一步:更新数据 数据页内存 Change Buffer 第二步:缓存日志内容 redo log buffer binlog cache 第三步:日志写入磁盘 两 ...

  4. Android开发问题之Installation failed due to invalid URI!

    真机调试遇到以下问题: [2017-07-20 13:43:53 - VCL02PANEL] Installation failed due to invalid URI![2017-07-20 13 ...

  5. 手摸手,带你用Beego撸商城系列二(登录篇)

    完整项目地址: go-shop-b2c 系列文章: 手摸手,带你用 Beego撸商城 系列一(基础篇) 手摸手,带你用 Beego撸商城 系列二(登录篇) 手摸手,带你用 Beego撸商城 系列三(系 ...

  6. SystemVerilog 中的相等运算符:== or === ?

    1. 四值逻辑的逻辑运算 在对比SystemVerilog中的相等运算符之前,先来看一下三种最基本的逻辑运算符,下文中以·表示与运算,以+表示或运算,以'表示非运算.我们都知道在逻辑代数中,只有0和1 ...

  7. 四QT通过递归获取当前对象的全部子对象

    children()只能获取到当前对象的子项,但是子项的子项就获取不到了,于是想到了用递归去获取全部子项.主要代码如下: void HomePage::getAllChild(QObjectList ...

  8. 44、wget和curl的常用参数

    1.wget: wget是文件下载的工具: 不加任何参数是直接下载该文件: (1)-O: 将下载的文件指定为特定的文件名: wget -O baidu.html www.baidu.com --201 ...

  9. KDE桌面环境下konsole,kate等软件无法切换中文输入法

    解决方案(arch): 修改/etc/profile,增加以下语句: #fcitxexport XIM_PROGRAM=fcitxexport XIM=fcitxexport GTK_IM_MODUL ...

  10. hdu 6030 矩阵快速幂

    大致题意: 一条长度为n的项链,由红色珠子和蓝色珠子(分别用1和0表示)组成,在连续的素数子段中,红色珠子的个数不能少于蓝色珠子.问组成这个项链有多少种方案,求方案数模1000000007 分析: 首 ...