A - ABC400 Party
Source: atcoder
Difficulty: 100

Problem Statement
In the ceremony commemorating ABC400, we want to arrange
400
people in a rectangular formation of
A
rows and
B
columns without any gaps.
You are given a positive integer
A
. Print the value of a positive integer
B
for which such an arrangement is possible. If there is no such positive integer
B
, print
-1
.
Constraints
A
is an integer between
1
and
400
, inclusive.
Input
The input is given from Standard Input in the following format:
A
Output
Print the value of
B
or
-1
as specified by the problem statement.
Sample Input 1
10
Sample Output 1
40
We can arrange
400
people in
10
rows and
40
columns.
Sample Input 2
11
Sample Output 2
-1
Sample Input 3
400
Sample Output 3
1

C++ solution:
#include <iostream>

int main() {
    int A;
    std::cin >> A;
    
    if (A > 0 && A <= 400 && 400 % A == 0) {
        std::cout << (400 / A) << std::endl;
    } else {
        std::cout << -1 << std::endl;
    }
    
    return 0;
}

Go solution:
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func main() {
	a := ScanI()
	ans := 0
	if 400%a != 0 {
		ans = -1
	} else {
		ans = 400 / a
	}
	fmt.Println(ans)
}

func ScanI() int {
	sc.Scan()
	str, _ := strconv.Atoi(sc.Text())
	return str
}

func ScanS() string {
	sc.Scan()
	return sc.Text()
}

func ScanIArrayNotBlank() []int {
	str := strings.Split(ScanS(), "")
	arrI := make([]int, len(str))
	for i := 0; i < len(str); i++ {
		num, _ := strconv.Atoi(str[i])
		arrI[i] = num
	}

	return arrI
}

func ScanIArrayWithBlank(n int) []int {
	arrI := make([]int, n)
	for i := 0; i < n; i++ {
		arrI[i] = ScanI()
	}

	return arrI
}

Java solution:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static int solve(int a){
        if(400 % a == 0){
            return 400/a;
        }
        return -1;
    }

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int a = Integer.parseInt(br.readLine());
        System.out.println(solve(a));
    }
}

JavaScript solution:
function main(A) {
    if (400%A===0){
        const B=400/A ;
        console.log(B);
    }else{
        console.log("-1");
    }
}

//   //本番用
  main(require("fs").readFileSync("/dev/stdin", "utf8"));

Python solution:
num = int(input())
if 400%num == 0:
  print("{:.0f}".format(400/num))
else:
  print("-1")

Ruby solution:
# 20:44 -

a = gets.to_i

b = 400/a

puts a*b == 400 ? b : -1