Skip to content

Commit

Permalink
new problem
Browse files Browse the repository at this point in the history
  • Loading branch information
maspypy committed Nov 2, 2023
1 parent 76083b3 commit 62a42fa
Show file tree
Hide file tree
Showing 13 changed files with 873 additions and 0 deletions.
62 changes: 62 additions & 0 deletions math/factorial/checker.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// https://github.com/MikeMirzayanov/testlib/blob/master/checkers/wcmp.cpp

// The MIT License (MIT)

// Copyright (c) 2015 Mike Mirzayanov

// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:

// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

#include "testlib.h"

using namespace std;

int main(int argc, char * argv[])
{
setName("compare sequences of tokens");
registerTestlibCmd(argc, argv);

int n = 0;
string j, p;

while (!ans.seekEof() && !ouf.seekEof())
{
n++;

ans.readWordTo(j);
ouf.readWordTo(p);

if (j != p)
quitf(_wa, "%d%s words differ - expected: '%s', found: '%s'", n, englishEnding(n).c_str(), compress(j).c_str(), compress(p).c_str());
}

if (ans.seekEof() && ouf.seekEof())
{
if (n == 1)
quitf(_ok, "\"%s\"", compress(j).c_str());
else
quitf(_ok, "%d tokens", n);
}
else
{
if (ans.seekEof())
quitf(_wa, "Participant output contains extra tokens");
else
quitf(_wa, "Unexpected EOF in the participants output");
}
}
1 change: 1 addition & 0 deletions math/factorial/gen/example_00.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0
1 change: 1 addition & 0 deletions math/factorial/gen/example_01.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
100
1 change: 1 addition & 0 deletions math/factorial/gen/example_02.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
998244352
12 changes: 12 additions & 0 deletions math/factorial/gen/near_half.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <cstdio>
#include "../params.h"
#include "random.h"

int main(int, char* argv[]) {
long long seed = atoll(argv[1]);
auto gen = Random(seed);

int N = gen.uniform<int>(0.45 * MOD, 0.55 * MOD);
printf("%d\n", N);
return 0;
}
12 changes: 12 additions & 0 deletions math/factorial/gen/near_max.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <cstdio>
#include "../params.h"
#include "random.h"

int main(int, char* argv[]) {
long long seed = atoll(argv[1]);
auto gen = Random(seed);

int N = gen.uniform<int>(0.95 * MOD, MOD - 1);
printf("%d\n", N);
return 0;
}
12 changes: 12 additions & 0 deletions math/factorial/gen/random.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <cstdio>
#include "../params.h"
#include "random.h"

int main(int, char* argv[]) {
long long seed = atoll(argv[1]);
auto gen = Random(seed);

int N = gen.uniform<int>(0, MOD - 1);
printf("%d\n", N);
return 0;
}
36 changes: 36 additions & 0 deletions math/factorial/hash.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"example_00.in": "9a271f2a916b0b6ee6cecb2426f0b3206ef074578be55d9bc94f6f3fe3ab86aa",
"example_00.out": "6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b",
"example_01.in": "eea8254c7500ba3de996aa8ad6af399183f04e17d4a8102fde539dbc93a90012",
"example_01.out": "54a9294060a94f5166e0902704b34c0ddf9e913148e80e2224213ff4c6665a99",
"example_02.in": "d94b5d5e2010ceb1f753093c4b1111b0c411837daf56c8415056eb92346a0bcd",
"example_02.out": "0b274a87936f26e505c159427061edb5d54cc742f78ed7cf8c5e8c58c08639f8",
"near_half_00.in": "4d20fea3b1b8f1331ca5c417cc2fe9829dad91921dd6783810b1d2f1ad97db6a",
"near_half_00.out": "db0a34160e386d1388ad3c24a46a2ca0be698e4b3754a88dff16b691f92bf35a",
"near_half_01.in": "5936077669c4ed43c2b811b52586d429b2423f75476729a676770a51cc9bb961",
"near_half_01.out": "7179dadb7caea3c1461a9bcc5ba46e0533273bd1467b0b7589c5b6a510912689",
"near_half_02.in": "db21c9ce914ed36e55404989c0b918c43745f23bac2ac17fd756c74a8807b68c",
"near_half_02.out": "a85975397f8ac5d98d0bf1c7dfd17a8d37bfa039eb7642ec36ec319a347da5b8",
"near_max_00.in": "ca42e336242d5cdee76c8cf0213094783658996772d25f0859d100dbd33e302f",
"near_max_00.out": "963161328cf7fc7937e5e8830bffff9cfb68ba5ed8c4deb3e180c1488e17910c",
"near_max_01.in": "9d9d4a87eef24902715b2518acdafb773c3096eb6a26bfbc4229d16165f9ffc3",
"near_max_01.out": "c859d0646c408f6dfebcced73cc962f1545ebd049faa4182ef2bb41832b5e287",
"near_max_02.in": "ab0c9e20428c77ee2fe37ba96bce43e9d10cfcece467626d4aae3de35c4b80bf",
"near_max_02.out": "9baf06b85dafe7a017d412e554b2fdad3def30ba119c78f862bb1363b7f8a23c",
"random_00.in": "3cfdf017bf8e88510a8d2d670a5736b66267d2e4af13d68a60871013426e0a01",
"random_00.out": "5e22b5482b97861082f608ae4937af5aeaade883e71e7b8e15f237e73a4fd86c",
"random_01.in": "7e6d42e3a77c2d80f2a05fd9e601e1c1a15271717eb454400e510b5ec92ca4fe",
"random_01.out": "81000415cae1b568ce2d3203dc1e68eccd3ce601af791f9eb12b86fcf66c4233",
"random_02.in": "751ae5dea0048ddcce5248cf2334982830420a40ff5cba50790018073d65ebc5",
"random_02.out": "c03fee4d693dba8cb8dd66baf974e5d3c8975dbca7ce2567c048f9642c2e057b",
"random_03.in": "af3f76179322d5f9409d5fc655ae7f5e6ec6a572a0df43e580f552cbea13a9f2",
"random_03.out": "9b4a83229a0593fa3febf4943ebff8e89304a7b9e05385e404a35a4e91752c38",
"random_04.in": "2581a6e5ce00ad8fc8de99c4e6bec594642a729e4668f306e7047b4f29b2cab7",
"random_04.out": "8692bc2cf1ca11b2db337f4077f642e5cdcc44042b1b1899b850c038178b2220",
"random_05.in": "48d53f8ced4a76f9e8a5256816877a715aee9e3c8b75e2ca09789477f129983e",
"random_05.out": "c7730e9c08817d489536d442d3a344405f09c9b63562479241d90485ecb04f01",
"random_06.in": "da95bcd27b9626ef0cda5fd78625b1706e1927f5530f3e138210effcd8a9975b",
"random_06.out": "1315fc99f118eba7116dc7ff4c13515d76859c49438b0f834d2a3767dc4e5411",
"random_07.in": "bcb2ae24fafc8c1c714cb98c83df708cade5c68b3a40919da635ef1f4139560e",
"random_07.out": "045b1dd57d704ccc139564afe0467f6f0335d22214a2585124e8c2e6379dcdc4"
}
24 changes: 24 additions & 0 deletions math/factorial/info.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
title = 'Factorial'
timelimit = 5.0
forum = "https://github.com/yosupo06/library-checker-problems/issues/128"

[[tests]]
name = "example.in"
number = 3
[[tests]]
name = "random.cpp"
number = 8
[[tests]]
name = "near_max.cpp"
number = 3
[[tests]]
name = "near_half.cpp"
number = 3

[[solutions]]
name = "naive.cpp"
wrong = false


[params]
MOD = 998244353
Loading

0 comments on commit 62a42fa

Please sign in to comment.