版本比较
题解:P9416 [POI 2021/2022 R1] Domino
正文
增加 16 行删除 16 行
7 行未改动891011121312131415161744 行未改动626364656666676869697071727273747575767777787980812 行未改动8485868788888990909192939495959697989910010010110210310410410510610710810910911011111211211311411511511611711811811912012112212 行未改动7 行未改动这里先考虑不放障碍的种类数。
枚举出前几个,数据如下表。
| N | 种类 | | :----------: | :----------: | | N | 种类 || :----------: | :----------: || 1 | 1 || 2 | 2 || 3 | 3 || 4 | 5 |44 行未改动 if(x==1){ ans=min(ans,xxx-1); return; }
int flg; flg=0; for(int i=2;i<=k;i++){ int nowx=x; int nowx=x; int nowflg=flg; int nowans=xxx;
while(nowx%cnt[i]==0){ nowx/=cnt[i]; nowflg++; nowans+=i+1; nowflg++; nowans+=i+1; }
if(nowflg!=flg){ flg=nowflg; work(nowx,nowans); }2 行未改动
signed main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n; cin>>n;
if(n==1){ cout<<1; return 0; }
if(n==2){ cout<<2; return 0; }
cnt[1]=1; cnt[2]=2; for(int i=3;cnt[i-1]<=n;i++){ cnt[i]=cnt[i-1]+cnt[i-2];
if(cnt[i]==n){ cout<<i; return 0; }
k=i; }
//cout<<k<<" "<<cnt[k]<<endl; work(n,0);
if(ans==1e18){ cout<<"NIE"; } } else{ cout<<ans; } return 0;12 行未改动