#include<iostream>
#include<vector>
#include<string>
using namespace std;
class bitmap
{
public:
bitmap(size_t n):_size(0)
{
_a.resize((n>>5)+1);
}
void set(size_t x)
{
size_t index=x>>5;
size_t num=x%32;
_a[index] |=(1<<num);
}
void reset (size_t x)
{
size_t index=x>>5;
size_t num=x%32;
_a[index] &=~(1<<num);
}
bool test(size_t x)
{
size_t index=x>>5;
size_t num=x%32;
return _a[index&(1<<num)];
}
protected:
vector<size_t>_a;
size_t _size;
};
/***********
//size size++
//
// bitset
size_t -1
pow2(32)
********/
void test(int n)
{
bitmap bp(100);
cout<<"begin:"<<bp.test(n)<<endl;
bp.set(n);
cout<<"then:"<<bp.test(n)<<endl;
bp.reset(n);
cout<<"then:"<<bp.test(n)<<endl;
cout<<"--------"<<endl;
}
int test2(int len)
{
//int a[]={1,3,5,2,4,6,6,7,7,9,1,2,3};//
//int a[]={1,3,5,2,4,6};
int tmp,i,j; int ct=0;
int a[10]={0};
for(i=0;i<10;i++)
{
a[i]=len-i;
}
//int len=sizeof(a)/sizeof(a[0]);
for(i=1;i<len;i++)
{
tmp=a[i];
j=i-1;
while(a[j]>tmp)
{
a[j+1]=a[j];
j--;
ct++;
}
a[j+1]=tmp;
}
for(i=0;i<len;i++)
{
cout<<a[i]<<" " ;
}
cout<<endl<<"n="<<len<<" ct"<<ct<<endl;
return 0;
}
/****
int main()
{
int n=10;
test2(4);
test2(5);
test2(6);
test2(7);
cin>>n;
return 0;
}
****/
int main()
{
}
/*********
O(n^2)
n(n-1)/2
n ct
***********/