Codeforces Round #818 (Div. 2)
A
#include <iostream>
#include <cstring>
#include <algorithm>
#include <unordered_map>
using namespace std;
int n;
int main()
{
int t;
cin>>t;
while(t--){
cin>>n;
long long res=0;
res=n+n/2*2+n/3*2;
cout<<res<<endl;
}
}
B
#include <iostream>
#include <cstring>
#include <algorithm>
#include <unordered_map>
using namespace std;
const int N = 510;
bool st[N][N];
int n;
int main()
{
int t;
cin>>t;
while(t--){
memset(st,false,sizeof(st));
int n,k,x,y;
cin>>n>>k>>x>>y;
for(int i=x,j=y;;){
st[x][y]=true;
x--;
y++;
if(x==0) x=n;
if(y==n+1) y=1;
if(st[x][y]){
y=(y+k-1)%n+1;
if(st[x][y]) break;
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++)
if(st[i][j])cout<<"X";
else cout<<".";
puts("");
}
}
}