Submission #117028


Source Code Expand

import std.stdio, std.string, std.conv;
import std.algorithm, std.array, std.bigint, std.math, std.range;
import core.thread;

//	Input
string[] tokens;
int tokenId = 0;
string readToken() { for (; tokenId == tokens.length; ) tokens = readln.split, tokenId = 0; return tokens[tokenId++]; }
int readInt() { return to!int(readToken); }
long readLong() { return to!long(readToken); }

//	chmin/chmax
void chmin(T)(ref T t, T f) { if (t > f) t = f; }
void chmax(T)(ref T t, T f) { if (t < f) t = f; }

//	Pair
struct Pair(S, T) {
	S x; T y;
	int opCmp(ref const Pair p) const { return (x < p.x) ? -1 : (x > p.x) ? +1 : (y < p.y) ? -1 : (y > p.y) ? +1 : 0; }
	string toString() const { return "(" ~ to!string(x) ~ ", " ~ to!string(y) ~ ")"; }
}
auto pair(S, T)(S x, T y) { return Pair!(S, T)(x, y); }

//	Array
int binarySearch(T)(T[] as, bool delegate(T) test) {
	int low = -1, upp = as.length; for (; low + 1 < upp; ) { int mid = (low + upp) >> 1; (test(as[mid]) ? low : upp) = mid; } return upp;
}
int lowerBound(T)(T[] as, T val) { return as.binarySearch((T a){ return (a <  val); }); }
int upperBound(T)(T[] as, T val) { return as.binarySearch((T a){ return (a <= val); }); }
T[] unique(T)(T[] as) { T[] bs; foreach (a; as) if (bs == null || bs[$ - 1] != a) bs ~= a; return bs; }



void main(string[] args) {
	for (; ; ) {
		int n = readInt;
		if (n == 0) {
			break;
		}
		int ans;
		for (int d = 2; d * d <= n; ++d) if (n % d == 0) {
			chmax(ans, d);
			for (; n % d == 0; n /= d) {}
		}
		chmax(ans, n);
		writeln(ans);
	}
}

Submission Info

Submission Time
Task B - Working for the World
User hos_lyric
Language D (DMD 2.060)
Score 100
Code Size 1578 Byte
Status AC
Exec Time 24 ms
Memory 936 KB

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 27
Set Name Test Cases
All 00-sample, 10-minimum, 11-maximum, 12-little, 13-large, 14-middle, 15-zero, 50-random00, 50-random01, 50-random02, 50-random03, 50-random04, 50-random05, 50-random06, 50-random07, 50-random08, 50-random09, 50-random10, 50-random11, 50-random12, 50-random13, 50-random14, 50-random15, 50-random16, 50-random17, 50-random18, 50-random19
Case Name Status Exec Time Memory
00-sample AC 20 ms 808 KB
10-minimum AC 20 ms 804 KB
11-maximum AC 20 ms 792 KB
12-little AC 20 ms 796 KB
13-large AC 20 ms 804 KB
14-middle AC 20 ms 932 KB
15-zero AC 20 ms 808 KB
50-random00 AC 20 ms 932 KB
50-random01 AC 20 ms 932 KB
50-random02 AC 20 ms 804 KB
50-random03 AC 21 ms 808 KB
50-random04 AC 21 ms 932 KB
50-random05 AC 21 ms 804 KB
50-random06 AC 21 ms 928 KB
50-random07 AC 20 ms 936 KB
50-random08 AC 20 ms 804 KB
50-random09 AC 20 ms 804 KB
50-random10 AC 24 ms 756 KB
50-random11 AC 22 ms 740 KB
50-random12 AC 21 ms 936 KB
50-random13 AC 21 ms 796 KB
50-random14 AC 22 ms 932 KB
50-random15 AC 20 ms 928 KB
50-random16 AC 20 ms 800 KB
50-random17 AC 20 ms 812 KB
50-random18 AC 20 ms 804 KB
50-random19 AC 20 ms 804 KB