有做软件的网站有哪些,广州建设银行官方网站,赣州建设局 网站,有没有免费的网站空间题意#xff1a;一个非常有趣的问题#xff0c;就是给一摞煎饼#xff0c;然后从下面拿起来一张#xff0c;然后把该张上面的所有馅饼反转#xff0c;求最后使得馅饼从小到大的最小的步数。 思路#xff1a;贪心。每次都把没排好序的最大数反转到最上面#xff0c;然后在…题意一个非常有趣的问题就是给一摞煎饼然后从下面拿起来一张然后把该张上面的所有馅饼反转求最后使得馅饼从小到大的最小的步数。 思路贪心。每次都把没排好序的最大数反转到最上面然后在一次反转到最下面也就是最多需要2n步就能够把所有的馅饼排好。 Code #include iostream
#include cstdio
#include algorithm
#include string
#include sstream
#include cstring
#include cmath
#include map
#include vector
#include queue
#include set
using namespace std;typedef long long ll;
typedef unsigned long long ull;
const int N1000000;
const int M105;
const int mod10000007;
const int INF0x3f3f3f3f;
const ll LINF0x3f3f3f3f3f3f3f3f;
const double eps1e-9;
const double paiacos(-1.0);
#define lson l,m,rt1
#define rson m1,r,rt1|1
#define cls(x,c) memset(x,c,sizeof(x))
#define fr(i,n) for (int i0;in;i)int a[35],len;
int tran(int j)
{int tj;for (int i0;ij;i)if (a[i]a[t]) ti;return t;
}
int main()
{string s;int i,j;while (getline(cin,s)){if (s) break;coutsendl;stringstream ss;sss;len0;while (ssa[len]) len;//fr (i,len) coutbug2a[i]endl;for (int ilen-1;i0;i--){jtran(i);//coutbug jendl;if (ji) continue;if (j!0){printf(%d ,len-j);reverse(a,aj1);}reverse(a,ai1);printf(%d ,len-i);}puts(0);}
}