data.bin
추가코드 작성시 디버깅과 편의를 위해 로컬 컴퓨터의 개발 도구를 사용할 수 있습니다.
이 경우 로컬 컴퓨터에서의 개발 환경과 채점에서의 개발 환경이 달라 실행이나 채점이 되지 않는 불이익이 없도록 본 안내를 꼭 읽어보시기 바랍니다 (특히 Visual Studio / Visual C++ 사용시).
코드 제출 문제에 제출된 모든 코드의 실행과 채점은 다음 환경에서 이루어집니다.
해당 환경에서 동작하지 않는 코드는 채점이 되지 않습니다. 유념하여 개발 도구를 사용해주시기 바랍니다.
gcc -std=gnu2x -O2 -DONLINE_JUDGE -DNYPC -Wall -Wextra -march=native -mtune=native -o main main.c -lm
./main NYPC
g++ -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 NYPC
python3 -m py_compile main.py
python3 __pycache__/main.cpython-312.pyc NYPC
pypy3 -m py_compile main.py
pypy3 __pycache__/main.pypy39.pyc NYPC
javac --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 NYPC
cargo rustc -r -q --frozen -- -Copt-level=3 -Ctarget-cpu=native --cfg online_judge --cfg nypc
./target/release/main NYPC
tsc main.ts --target ESNext --moduleResolution node --module commonjs --noEmitOnError
node main.js NYPC
dotnet 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 NYPC
luajit -O3 -b Main.lua Main.out
luajit Main.out NYPC
kotlinc -include-runtime -d Main.jar Main.kt
java -Xms<memory> -XmX<memory> -DONLINE_JUDGE=1 -DNYPC=1 -jar Main.jar NYPC
konanc Main.kt -o Main -opt
./Main.kexe NYPC
g++-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 NYPC
cargo rustc -r -q --frozen -- -Copt-level=3 -Ctarget-cpu=native --cfg online_judge --cfg nypc
./target/release/main NYPC
아래의 예시처럼 특정 플랫폼(특히, Windows나 Visual C++)에서만 동작하는 코드를 작성하지 않도록 유의하시기 바랍니다.
사용금지 예시 | 비고 |
---|---|
void main() | 표준에 따라 int main 이어야 함 |
getch() | 대신 getchar() 를 사용 |
fflush(stdin) | 비표준 함수 사용 |
GetTickCount() | Windows API 는 사용할 수 없음 |
CString | CString 은 표준이 아니며 사용할 수 없음. 대신 std::string 을 사용 |
#include <stdafx.h> | stdafx.h 는 Visual C++ 전용 precompiled header임 |
클래스 이름은 반드시 Main
이어야 합니다.
모든 코드 제출 문제에서는 주어진 입력 형식에 따라 표준 입력 (standard input)으로 입력을 받고 주어진 출력 형식에 따라 표준 출력(standard output)으로 출력해야 합니다.
아래 예시와 같이 두 개의 정수를 받아 곱하여 출력해야 하는 문제가 있다면, 언어별로 표준 입력과 표준 출력을 처리하는 방법은 아래와 같습니다.
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)
}
NYPC <CODE BATTLE/> 채점 환경에서는 소스코드 이외에 바이너리 파일을 추가로 제출할 수 있습니다. 바이너리 파일은 소스코드를 실행하는 디렉토리에 data.bin
라는 이름의 파일로 제공됩니다.
해당 파일은 코드 실행 시에만 제공되며, 컴파일 시에는 제공되지 않습니다.
data.bin
의 모든 바이트를 표준 출력으로 출력하는 코드는 다음과 같습니다.
#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();
}
작성된 프로그램은 프로그램의 종료 코드가 항상 0 (정상종료)이 되어야합니다. 0으로 종료되지 않는 경우 맞는 답을 출력하는 프로그램을 제출하였더라도 채점이 되지 않을 수 있습니다.
특히 종료 코드를 0으로 하는 코드를 제출하였더라도 작성한 프로그램의 런타임 에러 여부에 따라 0이 아닌 코드로 종료될 수 있습니다.