Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
#include <iostream>
#define ll long long int
using namespace std;
int main()
{ ll t; cin >> t;
// seive();
while (t--) {
ll n; cin >> n;
cout<<n<<endl;
for (ll j = 0; j <n; j++)
{
cout<<n<<endl;
for (ll i = 0; i < n; i++)
{
cout<<i+1<<" "<<((i+j)%n)+1<<" "<<((i+j+1)%n)+1<<endl;
}
}
}
return 0;}
def soln(n):
arr = [(i, i+1) for i in range(1, n)]
arr.append((1, n))
print(n)
for i in range(n):
print(n)
for j in range(n):
print(j+1, *arr[(i+j)%n])
for _ in range(int(input())):
n = int(input())
soln(n)
#include <stdio.h>
int main(void) {
// your code goes here
int i,t;
scanf("%d",&t);
while(t--){
int n;
scanf("%d",&n);
printf("%d\n",n);
for(i=1;i<=n;i++){
printf("%d\n",n);
for(int j=1;j<=n;j++){
int x=j+i-1 , y=j+i;
if(x>n && x%n!=0)
{
x=x%n;
}
else if(x%n==0){
x=n;
}
if(y>n && y%n!=0){
y=y%n;
}
else if(y%n==0){
y=n;
}
printf("%d %d %d\n",j,x,y);
}
}
}
return 0;
}
/* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{ static class FastReader{
BufferedReader br;
StringTokenizer st;
public FastReader(){
br=new BufferedReader(new InputStreamReader(System.in));
}
String next(){
while(st==null || !st.hasMoreTokens()){
try {
st=new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt(){
return Integer.parseInt(next());
}
long nextLong(){
return Long.parseLong(next());
}
double nextDouble(){
return Double.parseDouble(next());
}
String nextLine(){
String str="";
try {
str=br.readLine().trim();
} catch (Exception e) {
e.printStackTrace();
}
return str;
}
}
static class FastWriter {
private final BufferedWriter bw;
public FastWriter() {
this.bw = new BufferedWriter(new OutputStreamWriter(System.out));
}
public void print(Object object) throws IOException {
bw.append("" + object);
}
public void println(Object object) throws IOException {
print(object);
bw.append("\n");
}
public void close() throws IOException {
bw.close();
}
}
public static void main (String[] args) throws java.lang.Exception
{
FastReader in=new FastReader();
FastWriter out = new FastWriter();
int T=in.nextInt();
while(T--!=0){
int N=in.nextInt();
out.println(N);
int c=0;
for(int i=1;i<=N;i++){
out.println(N);
int initial=1+c;
for(int j=1;j<=N;j++){
int next=initial+1;
if(next==N+1)
next=1;
out.println(j+" "+initial+" "+next);
initial=next;
}
c++;
}
}
out.close();
}
}
import collections
def solve():
n=int(input())
q=collections.deque()
for i in range(n):
q.append((i+1,(i+1)%n +1))
print(n)
for _ in range(n):
print(n)
for i, (x,y) in enumerate(q,start=1):
print(i,x,y)
q.append(q.popleft())
for _ in range(int(input())):
solve()
t = int(raw_input())
for i in range(t):
N = int(raw_input())
print N
for k in range(N):
print N
for j in range(N):
p = (j+k)%N
q = (p+1)%N
print j+1, p+1, q+1
# endfor j
# endfor k
# endfor i
using System;
using System.Text;
public class Test
{
private interface IInputReader
{
string ReadInput();
}
private class ConsoleReader : IInputReader
{
public string ReadInput() => Console.ReadLine().Trim();
}
public static void Main()
{
checked
{
var reader = new ConsoleReader();
var testsCount = int.Parse(reader.ReadInput());
StringBuilder sb = new StringBuilder();
for (int test = 0; test < testsCount; test++)
{
var str = reader.ReadInput();
var n = int.Parse(str);
if (n % 2 == 0)
{
sb.AppendLine((n * n / 2).ToString());
for (int i = 0; i < n; i+=2)
{
for (int j = 0; j < n; j+=2)
{
for (int k = 0; k < 2; k++)
{
sb.AppendLine(2.ToString());
sb.AppendLine($"{j + 1} {i + 1} {i + 2}");
sb.AppendLine($"{j + 2} {i + 1} {i + 2}");
}
}
}
}
else
{
sb.AppendLine((1 + (n * n - n) / 2).ToString());
int[][] row = new int[n][];
for (int i = 0; i < n; i++)
{
row[i] = new[] {i, (i + 1) % n};
}
int[][][] pairs = new int[n][][];
for (int i = 0; i < n; i++)
{
pairs[i] = row;
}
sb.AppendLine(n.ToString());
for (int i = 0; i < n; i++)
{
sb.AppendLine($"{i + 1} {pairs[i][i][0] + 1} {pairs[i][i][1] + 1}");
}
for (int c = 0; c < n; c++)
{
int r0 = 0;
int r1 = 1;
while (r1 < n && r0 < n)
{
if (r1 == c)
{
r1++;
continue;
}
if (r0 == c)
{
r0++;
r1 = r0 + 1;
continue;
}
sb.AppendLine(2.ToString());
sb.AppendLine($"{r0 + 1} {pairs[r0][c][0] + 1} {pairs[r0][c][1] + 1}");
sb.AppendLine($"{r1 + 1} {pairs[r0][c][0] + 1} {pairs[r0][c][1] + 1}");
r0 = r1 + 1;
r1 = r0 + 1;
}
}
}
}
Console.WriteLine(sb.ToString());
}
}
}
package main
import (
"bufio"
"fmt"
"os"
)
var out = bufio.NewWriter(os.Stdout)
func main() {
defer out.Flush()
var t int
for fmt.Scan(&t); t > 0; t-- {
solve()
}
}
func solve() {
var n int
fmt.Scan(&n)
fmt.Fprintln(out, n)
for i := 0; i < n; i++ {
fmt.Fprintln(out, n)
for j := 0; j < n; j++ {
fmt.Fprintln(out, j+1, (j+i)%n+1, (j+i+1)%n+1)
}
}
}
In our experience, we suggest you solve this SnackUp CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.
If you are stuck anywhere between any coding problem, just visit Queslers to get the SnackUp CodeChef Solution.
I hope this SnackUp CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.
This Problem is intended for audiences of all experiences who are interested in learning about Programming Language in a business context; there are no prerequisites.
Keep Learning!