版本比较
happy question round1 题解
正文
增加 89 行删除 13 行
4 行未改动5678910111284 行未改动979899100101102103104105474 行未改动全部展开58058158258358458558658758858959059159259359459559659759859939 行未改动63964064164264364464564664797 行未改动7457467477484 行未改动T1 ~ T3 由作者编写。T4 由 [Kai29](https://www.luogu.com.cn/user/2046255) 编写:::::info[T1]# T1 超过他84 行未改动F_{n}\\F_{n+1}\end{vmatrix}$明显,有:```cppvector<vector<int> >base(k,vector<int>(k));for(int i=0;i<k-1;i++){base[i][i+1]=1;474 行未改动全部展开```::::::::::::::info[T5]# T5 写巨作业::::info[思路]::::::::success[AC Code]::::::::::::::info[T6]# T6 前缀::::info[思路]这题主要是 LCP+ST 表,难点其实就是 ST 表(~~好久没写了,所以这对我有点难,勿喷~~)。## LCP39 行未改动没写代码,请读者自行思考。## 倍增 ST见 https://www.luogu.com.cn/problem/P3865。我的见解:就是 DP。我们这个基于二进制,于是要处理数组 $log_2$。97 行未改动}```:::::::::4 行未改动567891011121384 行未改动9899100101102103104105106107108109110111112113114115116117118119120121122474 行未改动全部展开59759859960060160260360460560639 行未改动64664764864965065165265365497 行未改动7527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238244 行未改动T1 ~ T3 由作者编写。T4 由 [Kai29](https://www.luogu.com.cn/user/2046255) 编写T5~T6 也为作者编写。:::::info[T1]# T1 超过他84 行未改动F_{n}\\F_{n+1}\end{vmatrix}$扩展一维,有:$\begin{vmatrix}0& 1& 0 \\0& 0& 1 \\1& 1& 1\end{vmatrix} \begin{vmatrix}F_{n-2}\\F_{n-1}\\F_{n}\end{vmatrix}=\begin{vmatrix}F_{n-1}\\F_{n}\\F_{n+1}\end{vmatrix}$明显,转移矩阵的最后一行全是 $1$,前面的 $n-1$ 行中的第 $i$ 行是第 $n-i$ 位置是 $1$,其余为 $0$ 的矩阵。所以有:```cppvector<vector<int> >base(k,vector<int>(k));for(int i=0;i<k-1;i++){base[i][i+1]=1;474 行未改动全部展开```::::::::::::::info[T5]# T5 前缀::::info[思路]这题主要是 LCP+ST 表,难点其实就是 ST 表(~~好久没写了,所以这对我有点难,勿喷~~)。## LCP39 行未改动没写代码,请读者自行思考。## 倍增 ST见 https://www.luogu.com.cn/problem/P3865 。我的见解:就是 DP。我们这个基于二进制,于是要处理数组 $log_2$。97 行未改动}```::::::::::::::info[T6]# T6 infty or only ONE::::info[思路]这是贝特朗悖论。有人证明他是有无穷解的。所以这题的 subtask1 就直接输出 `yes` 即可。而最后有人用题目里的最后一个条件证明只有 $0.5$ 才是正解。于是我们有代码。::::::::success[AC Code]```cpp//警示后人:十年OI一场空,不开long long见祖宗#include <bits/stdc++.h>using namespace std;#define int long longusing ll=long long;using pll=pair<int,int>;template<typename T>inline void readinVector(vector<T>& vec,int l,int r){for(int i=l;i<=r;i++)cin>>vec[i];}template<typename T>class matvec{public:vector<vector<T> >mat;matvec(){}matvec(int n){mat.resize(n+1);}void rs(int n){mat.resize(n+1);}matvec(int n,int m){mat.resize(n+1,vector<T>(m+1));}matvec(int n,int m,T v){mat.resize(n+1,vector<T>(m+1,v));}vector<T>& operator[](int i){return mat[i];}void p_b(const vector<T>&vec){mat.push_back(vec);}};int T=1;void solve(){int sub;double p;cin>>sub>>p;if(sub==1)cout<<"yes"<<endl;else if(p==0.5)cout<<"yes"<<endl;else cout<<"no"<<endl;}signed main(){// freopen("xxx.in","r",stdin);// freopen("xxx.out","w",stdout);ios::sync_with_stdio(false);cin.tie(nullptr);// cin>>T;while(T--)solve();return 0;}```:::::::::