复杂度


点击查看代码
for(int i=1;i<=n;i++)
{
  for(int j=i;j<=min(i*2,n);j++)
}
for(int i=1;i<=n;i++)
{
  for(int j=1;j<=n;j+=i)
}
for(int i=1;i<=n;i++)
{
  for(int j=1;j<=i;j+=j)
}
n^2 nlogn nlogn
点击查看代码nloglogn
void work(int n)
{
	if(n==0) return;
	work(n/2);
	printf("a");
	for(int i=1;i<=n;i++)ans++;
	return;
}
点击查看nlogn
void work(int n)
{
	if(n==0) return;
	work(n/2);
        work(n/2);
	printf("a");
	for(int i=1;i<=n;i++)ans++;
	return;
}
ios::sync_with_stdio(false); 加后cin cout与scanf printf速度相当,但不能同时用scanf printf scanf(" \n%c",&c);==cin
block
#include
#include
using namespace std;

const int maxn=30;
int n;
vectorpile[maxn];

void find (int a,int&p,int&h) {
	for(p=0; p>n;
	int a,b;
	string s1,s2;
	for(int i=0; i>s1>>a>>s2>>b) {
		int pa ,pb ,ha ,hb ;
		find (a,pa,ha);
		find (b,pb,hb);
		if(pa==pb)
			continue;
		if(s2=="onto")
			clear (pb,hb);
		if(s1=="move")
			clear (pa,ha);
		pile_onto(pa,ha,pb);
	}
	print();
	return 0;
}