結果
| 問題 |
No.176 2種類の切手
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-02-07 18:46:43 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,149 bytes |
| コンパイル時間 | 1,131 ms |
| コンパイル使用メモリ | 117,888 KB |
| 実行使用メモリ | 8,992 KB |
| 最終ジャッジ日時 | 2024-06-12 06:58:17 |
| 合計ジャッジ時間 | 3,664 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | AC * 3 TLE * 1 -- * 25 |
ソースコード
import std.algorithm, std.conv, std.range, std.stdio, std.string;
import std.container; // SList, DList, BinaryHeap
import std.typecons; // Tuple, Nullable, BigFlags
import std.math; // math functions
import std.numeric; // gcd
import std.bigint; // BigInt
import std.random; // random
import std.bitmanip; // BitArray
import core.bitop; // bit operation
import std.regex; // RegEx
import std.uni; // unicode
void main()
{
auto rd = readln.split.to!(long[]), a = rd[0], b = rd[1], t = rd[2];
long x, y;
auto g = exEuclid(a, b, x, y);
a /= g; b /= g; t = (t + g - 1) / g;
auto calc() {
auto miAB = min(a, b);
auto miT = (t + miAB - 1) / miAB * miAB;
if (x < 0) {
foreach (k; max(t, miAB)..miT) {
if (((k * -x) + b - 1) / b <= (k * y) / a) return k;
}
} else {
foreach (k; max(t, miAB)..miT)
if (((k * -y) + a - 1) / a <= (k * x) / b) return k;
}
return miT;
}
writeln(calc * g);
}
T exEuclid(T)(T a, T b, ref T x, ref T y)
{
auto g = a;
x = 1;
y = 0;
if (b != 0) {
g = exEuclid(b, a % b, y, x);
y -= a / b * x;
}
return g;
}