Description A well known algorithm called heapsort is a deterministic sorting algorithm taking O(n log n) time and O(1) additional memory. Let us describe ascending sorting of an array of different integer numbers. The algorithm consists of two phas…
Tiling Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7965 Accepted: 3866 Description In how many ways can you tile a 2xn rectangle by 2x1 or 2x2 tiles? Here is a sample tiling of a 2x17 rectangle. Input Input is a sequence of lines,…
#include<stdio.h> #include<string.h> #define N 510000 int dp[N]; int f[10000000]; int main() { int k,n,m,i,j; dp[0]=0; memset(f,0,sizeof(f)); for(i=1;i<=500000;i++) { if(dp[i-1]-i>0&&f[dp[i-1]-i]==0) { dp[i]=dp[i-1]-i; f[dp[i]]=1…
Computer Transformation Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 4561 Accepted: 1738 Description A sequence consisting of one digit, the number 1 is initially written into a computer. At each successive time step, the computer simul…