"BOJ 15552 빠른 A+B"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-</source> +</syntaxhighlight>, -<source +<syntaxhighlight ))
7번째 줄: 7번째 줄:


==Bash==
==Bash==
<source lang='bash'>
<syntaxhighlight lang='bash'>
read n
read n
for sth in `seq 1 $n`
for sth in `seq 1 $n`
14번째 줄: 14번째 줄:
     echo $b | awk '{print $1+$2}'
     echo $b | awk '{print $1+$2}'
done
done
</source>
</syntaxhighlight>


==C++==
==C++==
<source lang='cpp'>
<syntaxhighlight lang='cpp'>
#include <iostream>
#include <iostream>
using namespace std;
using namespace std;
29번째 줄: 29번째 줄:
}
}
}
}
</source>
</syntaxhighlight>


==Java==
==Java==
<source lang='Java'>
<syntaxhighlight lang='Java'>
import java.util.*;
import java.util.*;
import java.io.*;
import java.io.*;
52번째 줄: 52번째 줄:
     }
     }
}
}
</source>
</syntaxhighlight>
<source lang='java'>
<syntaxhighlight lang='java'>
import java.io.*;
import java.io.*;
public class Main {
public class Main {
72번째 줄: 72번째 줄:
     }
     }
}
}
</source>
</syntaxhighlight>


==Perl==
==Perl==
<source lang='perl'>
<syntaxhighlight lang='perl'>
for (1 .. <>) {
for (1 .. <>) {
     ($a, $b) = (split / /, <>);
     ($a, $b) = (split / /, <>);
     printf("%d\n", $a + $b);
     printf("%d\n", $a + $b);
}
}
</source>
</syntaxhighlight>


==PHP==
==PHP==
<source lang='php'>
<syntaxhighlight lang='php'>
<?php
<?php
fscanf(STDIN,"%d",$N);
fscanf(STDIN,"%d",$N);
92번째 줄: 92번째 줄:
}
}
ob_flush();
ob_flush();
</source>
</syntaxhighlight>


==Python==
==Python==
<source lang='python'>
<syntaxhighlight lang='python'>
import sys
import sys
n = int(sys.stdin.readline())
n = int(sys.stdin.readline())
101번째 줄: 101번째 줄:
     a,b = map(int,sys.stdin.readline().split())
     a,b = map(int,sys.stdin.readline().split())
     print( a+b )
     print( a+b )
</source>
</syntaxhighlight>
<source lang='python'>
<syntaxhighlight lang='python'>
import sys
import sys
n = int(sys.stdin.readline())
n = int(sys.stdin.readline())
108번째 줄: 108번째 줄:
     arr = sys.stdin.readline().split()
     arr = sys.stdin.readline().split()
     print( int(arr[0])+int(arr[1]) )
     print( int(arr[0])+int(arr[1]) )
</source>
</syntaxhighlight>
<source lang='python'>
<syntaxhighlight lang='python'>
import sys
import sys
n = int(input())
n = int(input())
115번째 줄: 115번째 줄:
     a, b = map(int,sys.stdin.readline().split())
     a, b = map(int,sys.stdin.readline().split())
     print( a+b )
     print( a+b )
</source>
</syntaxhighlight>


==참고==
==참고==
* https://www.acmicpc.net/board/view/22716
* https://www.acmicpc.net/board/view/22716

2021년 7월 18일 (일) 05:45 판

1 개요

BOJ 15552 빠른 A+B

[[분류:BOJ {{{단계}}}단계]]


BOJ 단계별로 풀어보기
순번 문제 풀이

틀:BOJ 3단계 틀:BOJ 단계 푸터

2 Bash

read n
for sth in `seq 1 $n`
do
    read b
    echo $b | awk '{print $1+$2}'
done

3 C++

#include <iostream>
using namespace std;
int main() {
	int T;
	scanf("%d", &T);
	int A, B;
	for(int tc=1; tc<=T; tc++) {
		scanf("%d %d", &A, &B);
		printf("%d\n", A+B);
	}
}

4 Java

import java.util.*;
import java.io.*;
public class Main {
    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader( new InputStreamReader( System.in ) );
        BufferedWriter bw = new BufferedWriter( new OutputStreamWriter( System.out ) );
        int n = Integer.parseInt(br.readLine());
        String line;
        int a, b;
        for(int i=0; i<n; i++) {
            line = br.readLine();
            String[] nums = line.split(" ");
            a = Integer.parseInt(nums[0]);
            b = Integer.parseInt(nums[1]);
            bw.write( String.valueOf(a+b) + "\n" );
        }
        bw.flush();
    }
}
import java.io.*;
public class Main {
    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader( new InputStreamReader( System.in ) );
        StringBuilder sb = new StringBuilder();
        int n = Integer.parseInt(br.readLine());
        String line;
        int a, b;
        for(int i=0; i<n; i++) {
            line = br.readLine();
            String[] nums = line.split(" ");
            a = Integer.parseInt(nums[0]);
            b = Integer.parseInt(nums[1]);
            sb.append( String.valueOf(a+b) + "\n" );
        }
        System.out.print( sb );
    }
}

5 Perl

for (1 .. <>) {
    ($a, $b) = (split / /, <>);
    printf("%d\n", $a + $b);
}

6 PHP

<?php
fscanf(STDIN,"%d",$N);
ob_start();
for( $i=0; $i<$N; $i++ ) {
    fscanf(STDIN,"%d %d",$a,$b);
    echo ($a+$b) . "\n";
}
ob_flush();

7 Python

import sys
n = int(sys.stdin.readline())
for i in range(n):
    a,b = map(int,sys.stdin.readline().split())
    print( a+b )
import sys
n = int(sys.stdin.readline())
for i in range(n):
    arr = sys.stdin.readline().split()
    print( int(arr[0])+int(arr[1]) )
import sys
n = int(input())
for i in range(n):
    a, b = map(int,sys.stdin.readline().split())
    print( a+b )

8 참고

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}