Submission #12130748


Source Code Expand

Copy
void main() {
	auto ip = readAs!(int[]), N = ip[0], K = ip[1];

	long su(ulong n) {
		return n * (n + 1) / 2;
	}

	long res;
	const long MOD = 1000000007;
	foreach(k; K..N+1) {
		debug writefln("k: %d", k);
		auto m = su(N) - su(N-k) - su(k-1);
		debug writefln("m: %d", m);
		res += m+1;
		res %= MOD;
	}
	(res+1).writeln;
}


// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Submission Info

Submission Time
Task D - Sum of Large Numbers
User private_yusuke
Language D (DMD 2.091.0)
Score 400
Code Size 1368 Byte
Status AC
Exec Time 4 ms
Memory 2740 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 19
Set Name Test Cases
Sample sample_01, sample_02, sample_03
All hand_01, hand_02, max_01, max_02, random_01, random_02, random_03, random_04, random_05, random_06, random_07, random_08, random_09, random_10, random_11, random_12, sample_01, sample_02, sample_03
Case Name Status Exec Time Memory
hand_01 AC 2 ms 2524 KB
hand_02 AC 2 ms 2640 KB
max_01 AC 2 ms 2692 KB
max_02 AC 3 ms 2740 KB
random_01 AC 4 ms 2652 KB
random_02 AC 2 ms 2720 KB
random_03 AC 2 ms 2656 KB
random_04 AC 2 ms 2708 KB
random_05 AC 2 ms 2740 KB
random_06 AC 2 ms 2540 KB
random_07 AC 2 ms 2716 KB
random_08 AC 2 ms 2672 KB
random_09 AC 2 ms 2656 KB
random_10 AC 2 ms 2636 KB
random_11 AC 2 ms 2644 KB
random_12 AC 2 ms 2736 KB
sample_01 AC 2 ms 2676 KB
sample_02 AC 2 ms 2644 KB
sample_03 AC 2 ms 2660 KB