标签:char color 展开 pac bsp ack for bit line
康拓展开- - 正运算会逆运算竟然忘了怎么写- - 晕死。
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int maxn=25; ll a[maxn],jie[maxn]; int main(){ int n,m; scanf("%d%d",&n,&m); jie[0]=1; for(int i=1;i<=n;++i)jie[i]=jie[i-1]*i; for(int i=1;i<=m;++i){ char opt[2]; scanf("%s",opt); if(opt[0]==‘P‘){ ll k; scanf("%lld",&k); k--; vector<int>v; for(int i=1;i<=n;++i)v.push_back(i); for(int i=1;i<=n;++i){ int t1=k/jie[n-i]; k%=jie[n-i]; a[i]=v[t1]; v.erase(v.begin()+t1); } for(int i=1;i<=n;++i)printf("%d ",a[i]); printf("\n"); } else{ ll ans=0; for(int i=1;i<=n;++i){ scanf("%lld",&a[i]); int t1=a[i],t2=a[i]; for(int j=1;j<=i;++j){ if(a[j]<=t1)--t2; } ans+=t2*jie[n-i]; } printf("%lld\n",ans+1); } } return 0; }
luoguP3014 [USACO11FEB]牛线Cow Line
标签:char color 展开 pac bsp ack for bit line
原文地址:https://www.cnblogs.com/Dream-Runner/p/9425986.html