AtCoder Grand Contest 018

Submission #5904615

Source codeソースコード

unittest
{
	assert( [ "3 7", "9 3 4" ].parse.expand.solve == "POSSIBLE" );
	assert( [ "3 5", "6 9 3" ].parse.expand.solve == "IMPOSSIBLE" );
	assert( [ "4 11", "11 3 7 15" ].parse.expand.solve == "POSSIBLE" );
	assert( [ "5 12", "10 2 8 6 4" ].parse.expand.solve == "IMPOSSIBLE" );
}



import std.algorithm;
import std.conv;
import std.numeric : gcd;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nk = input.front.split.to!( long[] );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( nk[ 1 ], as );
}

auto solve( long k, long[] as )
{
	// 最大値と最大公約数を取得
	auto r = as.reduce!( max, gcd );
	if( k <= r[ 0 ] && k % r[ 1 ] == 0 ) return "POSSIBLE";
	else                                 return "IMPOSSIBLE";
}

Submission

Task問題 A - Getting Difference
User nameユーザ名 KouMikage
Created time投稿日時
Language言語 D (DMD64 v2.070.1)
Status状態 AC
Score得点 300
Source lengthソースコード長 975 Byte
File nameファイル名
Exec time実行時間 28 ms
Memory usageメモリ使用量 4664 KB

Test case

Set

Set name Score得点 / Max score Cases
Sample - sample_01.txt,sample_02.txt,sample_03.txt,sample_04.txt
All 300 / 300 sample_01.txt,sample_02.txt,sample_03.txt,sample_04.txt,sample_01.txt,sample_02.txt,sample_03.txt,sample_04.txt,subtask_1_01.txt,subtask_1_02.txt,subtask_1_03.txt,subtask_1_04.txt,subtask_1_05.txt,subtask_1_06.txt,subtask_1_07.txt,subtask_1_08.txt,subtask_1_09.txt,subtask_1_10.txt,subtask_1_11.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
sample_01.txt AC 1 ms 256 KB
sample_02.txt AC 1 ms 256 KB
sample_03.txt AC 1 ms 256 KB
sample_04.txt AC 1 ms 256 KB
subtask_1_01.txt AC 1 ms 256 KB
subtask_1_02.txt AC 1 ms 256 KB
subtask_1_03.txt AC 28 ms 4660 KB
subtask_1_04.txt AC 27 ms 4664 KB
subtask_1_05.txt AC 15 ms 3452 KB
subtask_1_06.txt AC 5 ms 2556 KB
subtask_1_07.txt AC 17 ms 3324 KB
subtask_1_08.txt AC 25 ms 4164 KB
subtask_1_09.txt AC 12 ms 4088 KB
subtask_1_10.txt AC 20 ms 4428 KB
subtask_1_11.txt AC 22 ms 3844 KB