Skip to content

Instantly share code, notes, and snippets.

@swapnil-warke
Last active December 24, 2015 03:39
Show Gist options
  • Save swapnil-warke/6738982 to your computer and use it in GitHub Desktop.
Save swapnil-warke/6738982 to your computer and use it in GitHub Desktop.
M4TILE related to spoj 3883 try M5TILE on spoj(11719) after this
//spoj2530.cpp
#include <cstdio>
using namespace std;
//my code
int main(){
unsigned int x[1001],a[1001],b[1001];
x[0]=1;a[0]=b[0]=0;
x[1]=a[1]=b[1]=1;
for(int i = 2;i <= 1000;++i)
{
x[i]=x[i-1]+x[i-2]+2*a[i-1]+b[i-1];
a[i]=x[i-1]+a[i-1];
b[i]=x[i-1]+b[i-2];
}
int T,n;
scanf("%d",&T);
for(int tc = 1;tc <= T;++tc){
scanf("%d",&n);
printf("%d %u\n",tc,x[n]);
}
return 0;
}
//someone else from internet (mariyoc) github
// i dont understood the following in first pass
//#include <cstdio>
//
//using namespace std;
//
//int main(){
// unsigned int dp[1001];
// dp[0] = dp[1] = 1; dp[2] = 5; dp[3] = 11;
//
// for(int i = 4;i <= 1000;++i)
// dp[i] = dp[i-1]+5*dp[i-2]+dp[i-3]-dp[i-4];
//
// int T,n;
//
// scanf("%d",&T);
//
// for(int tc = 1;tc <= T;++tc){
// scanf("%d",&n);
// printf("%d %u\n",tc,dp[n]);
// }
//
// return 0;
//}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment