Skip to content

Instantly share code, notes, and snippets.

@haridutt12
Created December 30, 2016 11:02
Show Gist options
  • Save haridutt12/ea84e058c9c94e9b136a3e22b2755ce6 to your computer and use it in GitHub Desktop.
Save haridutt12/ea84e058c9c94e9b136a3e22b2755ce6 to your computer and use it in GitHub Desktop.
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <unordered_map>
using namespace std;
int main()
{
long long int n,q,i,j,k,t,c,d,s;
cin>>n;
cin>>q;
c = pow(n,4);
long long int a[2001][2001],b[2001][2001],h[c],p[q];
h[1]=1;
h[2]=2;
h[3]=3;
for(i=4;i<=c;i++)
{
h[i] = h[i-1] + (2 * h[i-2]) + (3 * h[i-3]);
}
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
d = pow((i*j),2);
t = h[d];
if(t %2 == 0)
{
a[i][j] =2;
}
else
{
a[i][j] =1;
}
}
}
/*for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
printf("%lld",a[i][j]);
}
printf("\n");
}*/
for(i=1;i<=q;i++)
{
cin>>p[i];
}
for(k=1;k<=q;k++)
{
s = 0;
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
b[i][j] = 0;
}
}
if(p[k] <= 360)
{
if(p[k] == 90)
{
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
b[j][n-i+1] = a[i][j];
}
}
}
if(p[k] == 180)
{
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
b[n-i+1][n-j+1] = a[i][j];
}
}
}
if(p[k] == 270)
{
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
b[n-j+1][i] = a[i][j];
}
}
}
else
{
s = 0;
}
}
else if(p[k] > 360)
{
if((p[k] %180) == 0)
{
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
b[n-i+1][n-j+1] = a[i][j];
}
}
}
else if((p[k] % 270) == 0)
{
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
b[n-j+1][i] = a[i][j];
}
}
}
else if((p[k] % 360) == 0)
{
s = 0;
}
else
{
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
b[j][n-i+1] = a[i][j];
}
}
}
}
/*if(p[k]%360 != 0)
{
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
if(a[i][j] != b[i][j])
{
sum[k] = sum[k] + 1;
}
}
}
}
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
printf("%lld",b[i][j]);
}
printf("\n");
}
printf("end\n");*/
s=0;
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
if((b[i][j]) != (a[i][j]))
{
s = s + 1;
}
}
}
cout<<s<<endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment