-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path1557.cpp
More file actions
43 lines (39 loc) · 881 Bytes
/
1557.cpp
File metadata and controls
43 lines (39 loc) · 881 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
while(cin >> n && n!=0)
{
long long int v[n][n];
if(n==1)printf("1\n");
else
{
int c=1;
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
v[i][j]=c;
c*=2;
}
c=v[i][1];
}
stringstream ss;
ss << v[n-1][n-1];
string str = ss.str();
int q=str.size();
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
if(j==0)printf("%*lld",q,v[i][j]);
else printf(" %*lld",q,v[i][j]);
}
printf("\n");
}
}
printf("\n");
}
return 0;
}