結果

問題 No.3006 A winter wonderland
ユーザー 👑 hos.lyrichos.lyric
提出日時 2019-04-01 00:54:48
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 6,931 bytes
コンパイル時間 753 ms
コンパイル使用メモリ 106,788 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-04 00:01:55
合計ジャッジ時間 2,027 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/*
  find the first
  substring equal
  to the
  given x
  from
  sqrt(2)
*/

import std.conv, std.functional, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.container, std.math, std.numeric, std.range, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }


int[] ans;

void main() {
  debug {
    auto file = new File("sqrt2.txt", "r");
    const sqrt2 = file.byLine.join;
    ans = new int[1000];
    foreach (i; 0 .. sqrt2.length - 2) {
      const x = sqrt2[i .. i + 3].to!int;
      if (ans[x] == 0) {
        ans[x] = i + 1;
      }
    }
    writeln(ans);
  } else {
    ans = [1879, 1151, 617, 654, 415, 678, 1194, 2079, 1441, 2087, 201, 185, 1813, 103, 229, 484, 20, 949, 794, 1769, 618, 1325, 580, 3486, 118, 2321, 1104, 216, 348, 2185, 421, 432, 853, 369, 389, 3524, 284, 1557, 79, 5263, 687, 6257, 531, 2061, 885, 716, 3594, 835, 16, 778, 183, 1120, 878, 3028, 340, 127, 1475, 195, 921, 212, 193, 327, 324, 3855, 712, 1195, 1595, 2098, 445, 411, 77, 3333, 719, 52, 3244, 601, 823, 550, 34, 296, 2476, 2160, 671, 276, 392, 620, 1395, 266, 243, 786, 1473, 111, 506, 3634, 3044, 13, 29, 3011, 1227, 148, 677, 948, 2184, 1752, 715, 920, 3057, 76, 785, 202, 1929, 469, 766, 380, 1244, 186, 954, 740, 1344, 2398, 899, 142, 113, 2027, 513, 2672, 137, 767, 986, 1054, 479, 727, 158, 2041, 907, 5, 2126, 729, 104, 1585, 294, 156, 2, 269, 3060, 273, 542, 198, 1384, 144, 419, 2552, 187, 2990, 521, 563, 485, 96, 459, 471, 210, 2521, 598, 1145, 434, 960, 3661, 1350, 21, 1755, 1293, 950, 357, 741, 236, 1050, 55, 1572, 1542, 2046, 315, 881, 938, 525, 993, 375, 239, 42, 1128, 2347, 3976, 2677, 1503, 1770, 701, 2591, 1747, 972, 247, 1635, 4309, 228, 579, 368, 530, 1791, 192, 549, 619, 28, 75, 1343, 136, 4, 143, 458, 1678, 1326, 524, 700, 367, 1840, 160, 1456, 2274, 2790, 161, 755, 1177, 114, 109, 1242, 255, 1270, 4919, 499, 2802, 9, 1376, 336, 1060, 2588, 26, 1282, 3039, 749, 662, 69, 122, 119, 2567, 292, 1418, 304, 1970, 1367, 737, 810, 331, 2791, 282, 1382, 1353, 673, 138, 610, 162, 1037, 855, 762, 6311, 2980, 774, 99, 217, 167, 92, 428, 189, 287, 776, 2999, 987, 2258, 1657, 233, 940, 349, 502, 846, 710, 1055, 257, 450, 1287, 990, 320, 115, 359, 826, 1118, 480, 4715, 2944, 260, 422, 444, 2440, 265, 12, 2211, 468, 1590, 728, 155, 3149, 433, 54, 314, 1875, 1276, 271, 159, 1042, 68, 2043, 854, 91, 2305, 256, 1761, 313, 1965, 1481, 527, 2893, 1284, 370, 1008, 306, 390, 908, 528, 89, 1661, 221, 1371, 1147, 1436, 2220, 101, 1029, 334, 3280, 382, 362, 6, 3776, 152, 2164, 125, 1540, 285, 1538, 815, 2055, 1517, 2127, 723, 452, 644, 929, 134, 10, 385, 371, 46, 1558, 1169, 62, 833, 783, 1850, 4592, 105, 1139, 403, 85, 80, 1187, 3304, 958, 3953, 1653, 640, 337, 307, 278, 635, 1511, 688, 793, 426, 1116, 3712, 1032, 323, 295, 242, 1428, 714, 765, 141, 157, 1, 95, 2520, 909, 238, 971, 27, 3, 1035, 2621, 438, 2198, 1389, 2489, 532, 1267, 264, 1874, 90, 1283, 4144, 554, 1487, 384, 1246, 3066, 425, 140, 862, 642, 2002, 886, 625, 587, 2579, 1737, 274, 2225, 1705, 219, 436, 1076, 2827, 344, 632, 222, 387, 1048, 73, 311, 663, 2093, 626, 1868, 543, 4132, 199, 398, 231, 1663, 342, 836, 3644, 2253, 70, 1669, 50, 417, 841, 123, 262, 584, 510, 559, 17, 703, 1910, 2004, 120, 2137, 515, 779, 1629, 145, 394, 1296, 2078, 102, 347, 83, 15, 169, 2155, 131, 275, 505, 1067, 1052, 2026, 1584, 293, 1072, 1977, 235, 992, 1502, 1336, 629, 366, 254, 1281, 291, 1026, 188, 501, 2285, 3141, 373, 1041, 305, 88, 3666, 1516, 45, 1078, 1107, 1427, 3625, 437, 383, 424, 4264, 310, 341, 558, 1310, 1216, 1066, 253, 1077, 2018, 1215, 564, 176, 128, 171, 1085, 486, 7, 1135, 1340, 565, 2828, 1953, 490, 37, 377, 196, 97, 770, 1735, 345, 1253, 1300, 463, 177, 460, 962, 980, 153, 603, 129, 1198, 684, 594, 3104, 876, 650, 165, 1369, 680, 1024, 223, 213, 888, 206, 616, 540, 1058, 283, 2577, 126, 538, 822, 1940, 250, 2085, 739, 512, 2125, 1383, 328, 2380, 356, 487, 1648, 227, 74, 1306, 8, 1329, 1354, 281, 286, 1011, 825, 674, 467, 1379, 312, 1146, 1028, 722, 1373, 1744, 4278, 241, 94, 1341, 2170, 139, 435, 664, 816, 509, 2924, 1471, 1256, 628, 575, 309, 1196, 1339, 566, 961, 164, 2965, 1519, 1631, 2245, 4118, 163, 474, 57, 475, 1920, 1811, 40, 1351, 1954, 1908, 789, 1038, 572, 1869, 58, 856, 666, 544, 801, 446, 1205, 225, 301, 22, 405, 2119, 453, 1921, 942, 48, 1200, 38, 1625, 31, 412, 758, 200, 117, 78, 686, 3063, 410, 7176, 670, 147, 930, 951, 1099, 478, 197, 520, 209, 1302, 41, 2129, 548, 135, 613, 495, 25, 303, 720, 98, 232, 358, 11, 53, 67, 2767, 1891, 100, 771, 61, 782, 731, 1102, 237, 1388, 1873, 861, 218, 386, 2252, 8323, 606, 168, 1051, 365, 44, 1426, 175, 837, 769, 602, 352, 2081, 1647, 280, 2734, 93, 574, 56, 2115, 1161, 47, 757, 519, 2167, 933, 1627, 351, 573, 1559, 6982, 429, 1149, 918, 190, 1180, 71, 35, 1170, 2959, 1530, 3115, 430, 2074, 2436, 1773, 1670, 2842, 1496, 59, 297, 63, 653, 19, 857, 696, 777, 461, 1795, 33, 316, 2455, 784, 1273, 1080, 726, 1452, 418, 1144, 963, 1164, 1746, 191, 981, 988, 442, 545, 1527, 672, 1020, 939, 319, 2472, 154, 1600, 526, 1443, 333, 124, 1181, 2291, 277, 1173, 3198, 890, 263, 624, 805, 72, 397, 994, 393, 82, 234, 1166, 913, 557, 621, 36, 376, 593, 875, 249, 511, 226, 1378, 240, 1493, 1948, 1396, 404, 941, 685, 267, 24, 1239, 560, 43, 1857, 350, 1179, 1576, 18, 725, 318, 1262, 396, 81, 1129, 23, 1887, 244, 1693, 245, 1188, 638, 969, 1607, 299, 704, 492, 406, 414, 3435, 2287, 431, 1694, 877, 711, 65, 2340, 2722, 2152, 897, 112, 2240, 1265, 1014, 959, 1159, 454, 246, 1924, 1189, 608, 258, 121, 1133, 507, 166, 4037, 449, 2439, 943, 1654, 1943, 1370, 151, 451, 1771, 1186, 639, 1555, 764, 1551, 3600, 641, 1581, 1005, 1111, 49, 516, 14, 991, 290, 1125, 3250, 204, 1201, 780, 2655, 1360, 1233, 355, 1673, 1932, 321, 308, 473, 39, 224, 30, 116, 208, 705, 60, 1312, 973, 279, 518, 2958, 1757, 32, 2973, 1526, 360, 889, 733, 248, 493, 395, 298, 64, 1297, 1408, 150, 1550, 180, 354, 207, 1512, 149];
  }
  
  try {
    for (; ; ) {
      const X = readInt();
      writeln(ans[X]);
    }
  } catch (EOFException e) {
  }
}
0