Guest User

Untitled

a guest
Dec 2nd, 2014
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. #include <iostream>
  2. #include <map>
  3. #include <algorithm>
  4. #include <cstring>
  5. #include <string.h>
  6. #include <time.h>
  7. #include <stdio.h>
  8. #include <vector>
  9. #include <cmath>
  10. using namespace std;
  11. typedef long long ll;
  12. typedef double db;
  13. int b,max1,rez,k,m,k1,k2,k3,k4,k5,k6,i,n,j;
  14. int a[1001][1001],dp[1001][1001];
  15. ll gcd(ll a, ll b)
  16. {
  17. if (a<b) swap(a,b);
  18. if (b==0) return a; else
  19. return gcd(b,a%b);
  20. }
  21. int main()
  22. {
  23. char c;
  24. freopen("INPUT.TXT","r",stdin);
  25. freopen("OUTPUT.TXT","w",stdout);
  26. cin>>n;
  27. for (i=0;i<n;i++)
  28. for (j=0;j<n;j++)
  29. {
  30. cin>>c;
  31. a[i][j]=(int)c-48;
  32. if (a[i][j]==1) dp[i][j]=1; else dp[i][j]=0;
  33. }
  34. int max1=1;
  35. for (i=1;i<n;i++)
  36. for (j=1;j<n;j++)
  37. if (dp[i][j]>0&&dp[i-1][j-1]>0&&dp[i-1][j]>0&&dp[i][j-1]>0)
  38. {
  39. k1=min(min(dp[i-1][j-1],dp[i][j-1]),dp[i-1][j]);
  40. dp[i][j]=(sqrt((db)k1)+1)*(sqrt((db)k1)+1);
  41. if (dp[i][j]>max1) max1=dp[i][j];
  42. }
  43. cout<<max1<<endl;
  44. return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment