data.binYou may use development tools on your local computer for debugging and convenience when writing code.
In this case, please make sure to read this guide to avoid any disadvantages where the code does not execute or get graded due to differences between your local development environment and the grading environment (especially when using Visual Studio / Visual C++).
The execution and grading of all code submitted for code submission problems take place in the following environment:
Code that does not operate in this environment will not be graded. Please keep this in mind when using development tools.
gcc -std=gnu2x -O2 -DONLINE_JUDGE -DNYPC -Wall -Wextra -march=native -mtune=native -o main main.c -lm./main NYPCg++ -std=gnu++20 -O2 -DONLINE_JUDGE -DNYPC -Wall -Wextra -march=native -mtune=native -o main main.cpp -I/opt/boost/gcc/include -L/opt/boost/gcc/lib./main NYPCpython3 -m py_compile main.pypython3 __pycache__/main.cpython-312.pyc NYPCpypy3 -m py_compile main.pypypy3 __pycache__/main.pypy39.pyc NYPCjavac --release 21 -encoding UTF-8 Main.java -d out && jar cfe Main.jar Main -C out .java -Xms<memory> -XmX<memory> -DONLINE_JUDGE=1 -DNYPC=1 -jar Main.jar NYPCcargo rustc -r -q --frozen -- -Copt-level=3 -Ctarget-cpu=native --cfg online_judge --cfg nypc./target/release/main NYPCtsc main.ts --target ESNext --moduleResolution node --module commonjs --noEmitOnErrornode main.js NYPCdotnet publish -r linux-x64 -p:PublishSingleFile=true -p:DefineConstants="ONLINE_JUDGE;NYPC" --no-restore -c Release --sc true./bin/Release/net9.0/linux-x64/publish/Main NYPCluajit -O3 -b Main.lua Main.outluajit Main.out NYPCkotlinc -include-runtime -d Main.jar Main.ktjava -Xms<memory> -XmX<memory> -DONLINE_JUDGE=1 -DNYPC=1 -jar Main.jar NYPCkonanc Main.kt -o Main -opt./Main.kexe NYPCg++-15 -std=gnu++26 -O2 -DONLINE_JUDGE -DNYPC -Wall -Wextra -march=native -mtune=native -o main main.cpp -I/opt/boost/gcc/include -L/opt/boost/gcc/lib./main NYPCcargo rustc -r -q --frozen -- -Copt-level=3 -Ctarget-cpu=native --cfg online_judge --cfg nypc./target/release/main NYPCPlease be careful not to write code that only works on specific platforms (especially Windows or Visual C++), as shown in the examples below.
| Prohibited Example | Remarks |
|---|---|
void main() | Must be int main according to the standard |
getch() | Use getchar() instead |
fflush(stdin) | Use of non-standard function |
GetTickCount() | Windows API cannot be used |
CString | CString is not standard and cannot be used. Use std::string instead |
#include <stdafx.h> | stdafx.h is a Visual C++ exclusive precompiled header |
The class name must be Main.
In all code submission problems, you must receive input via standard input according to the given input format and produce output via standard output according to the given output format.
If there is a problem that requires receiving two integers and outputting their product as in the example below, the methods for handling standard input and standard output by language are as follows.
8 4
32
#include <stdio.h>
int main()
{
int a, b;
scanf("%d %d", &a, &b);
printf("%d\n", a * b);
return 0;
}#include <iostream>
using namespace std;
int main()
{
int a, b;
cin >> a >> b;
cout << a * b << endl;
return 0;
}a, b = map(int, input().split())
print(a * b)a, b = map(int, input().split())
print(a * b)import java.util.Scanner;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
System.out.println(a * b);
}
}use std::io;
fn main() {
let mut input = String::new();
io::stdin().read_line(&mut input).unwrap();
let nums: Vec<i32> = input.trim().split_whitespace()
.map(|x| x.parse().unwrap())
.collect();
println!("{}", nums[0] * nums[1]);
}const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const [a, b] = input.split(' ').map(Number);
console.log(a * b);const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const [a, b] = input.split(' ').map(Number);
console.log(a * b);using System;
class Program {
static void Main() {
string[] input = Console.ReadLine().Split(' ');
int a = int.Parse(input[0]);
int b = int.Parse(input[1]);
Console.WriteLine(a * b);
}
}package main
import (
"fmt"
)
func main() {
var a, b int
fmt.Scanf("%d %d", &a, &b)
fmt.Println(a * b)
}a, b = io.read("*n", "*n")
print(a * b)a, b = io.read("*n", "*n")
print(a * b)fun main() {
val (a, b) = readLine()!!.split(" ").map { it.toInt() }
println(a * b)
}fun main() {
val (a, b) = readLine()!!.split(" ").map { it.toInt() }
println(a * b)
}In the NYPC <CODE BATTLE/> grading environment, you can submit binary files in addition to source code. The binary file is provided under the name data.bin in the directory where the source code is executed.
This file is provided only during code execution and is not provided during compilation.
The following is code that outputs all bytes of data.bin to standard output.
#include <stdio.h>
int main()
{
FILE *f = fopen("data.bin", "rb");
int byte;
while ((byte = fgetc(f)) != EOF)
{
printf("%d ", byte);
}
fclose(f);
printf("\n");
}#include <fstream>
#include <iostream>
using namespace std;
int main()
{
ifstream file("data.bin", ios::binary);
unsigned char byte;
while (file.read((char *)&byte, 1))
{
cout << (int)byte << " ";
}
cout << endl;
file.close();
return 0;
}with open("data.bin", "rb") as f:
bytes_read = f.read()
for byte in bytes_read:
print(byte, end=" ")
print()with open("data.bin", "rb") as f:
bytes_read = f.read()
for byte in bytes_read:
print(byte, end=" ")
print()import java.io.FileInputStream;
import java.io.IOException;
public class Main {
public static void main(String[] args) {
try (FileInputStream fis = new FileInputStream("data.bin")) {
int byteRead;
while ((byteRead = fis.read()) != -1) {
System.out.print(byteRead + " ");
}
System.out.println();
} catch (IOException e) {
e.printStackTrace();
}
}
}use std::{fs::File, io::Read};
fn main() {
let mut file = File::open("data.bin").unwrap();
let mut buffer = [0u8; 1];
while let Ok(n) = file.read(&mut buffer) {
if n == 0 {
break;
}
print!("{} ", buffer[0]);
}
println!();
}const fs = require("fs");
fs.readFile("data.bin", (_, data) => {
data.forEach(byte => process.stdout.write(byte + " "));
console.log();
});const fs = require("fs");
fs.readFile("data.bin", (_, data) => {
data.forEach(byte => process.stdout.write(byte + " "));
console.log();
});using System;
using System.IO;
class Program {
static void Main() {
using (FileStream fs = new FileStream("data.bin", FileMode.Open, FileAccess.Read)) {
int byteRead;
while ((byteRead = fs.ReadByte()) != -1) {
Console.Write(byteRead + " ");
}
Console.WriteLine();
}
}
}package main
import (
"fmt"
"os"
)
func main() {
file, _ := os.Open("data.bin")
defer file.Close()
buf := make([]byte, 1)
for {
n, _ := file.Read(buf)
if n == 0 {
break
}
fmt.Printf("%d ", buf[0])
}
fmt.Println()
}local file = assert(io.open("data.bin", "rb"))
while true do
local byte = file:read(1)
if not byte then break end
io.write(string.byte(byte), " ")
end
file:close()
print()local file = assert(io.open("data.bin", "rb"))
while true do
local byte = file:read(1)
if not byte then break end
io.write(string.byte(byte), " ")
end
file:close()
print()import java.io.File
fun main() {
val bytes = File("data.bin").readBytes()
for (b in bytes) {
print("${b.toInt() and 0xFF} ")
}
println()
}import kotlinx.cinterop.*
import platform.posix.*
@OptIn(ExperimentalForeignApi::class)
fun main() {
fopen("data.bin", "rb")?.let { file ->
while (true) {
val b = fgetc(file)
if (b == EOF) break
print("$b ")
}
fclose(file)
}
println();
}The exit code of the written program must always be 0 (normal termination). If it does not terminate with 0, the program may not be graded even if it outputs the correct answer.
In particular, even if you submit code that sets the exit code to 0, it may terminate with a non-zero code depending on whether a runtime error occurs in the written program.