結果

問題 No.821 Making Integers
ユーザー GrenacheGrenache
提出日時 2019-04-26 22:38:56
言語 Java21
(openjdk 21)
結果
AC  
実行時間 126 ms / 2,000 ms
コード長 666 bytes
コンパイル時間 3,189 ms
コンパイル使用メモリ 71,332 KB
実行使用メモリ 56,208 KB
最終ジャッジ日時 2023-08-16 15:26:07
合計ジャッジ時間 5,203 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
55,704 KB
testcase_01 AC 126 ms
55,952 KB
testcase_02 AC 124 ms
55,724 KB
testcase_03 AC 124 ms
56,080 KB
testcase_04 AC 124 ms
56,168 KB
testcase_05 AC 125 ms
56,208 KB
testcase_06 AC 125 ms
55,652 KB
testcase_07 AC 125 ms
54,176 KB
testcase_08 AC 124 ms
55,724 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.Scanner;


public class Main_yukicoder821 {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		long n = sc.nextInt();
		long k = sc.nextInt();

		long max = n * (n + 1) / 2;
		long min = n * (n + 1) / 2 - (n - k) * (n - k + 1) / 2 * 2;

		pr.println((max + min + 1 + 1) / 2) ;
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}
0