Skip to content

Commit

Permalink
Merge pull request #1051 from maspypy/factorial
Browse files Browse the repository at this point in the history
[問題追加] factorial
  • Loading branch information
maspypy authored Nov 8, 2023
2 parents e74ee99 + 37449de commit 2f96c0a
Show file tree
Hide file tree
Showing 11 changed files with 896 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");
}
}
6 changes: 6 additions & 0 deletions math/factorial/gen/example_00.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
5
0
5
100
1234567
998244352
16 changes: 16 additions & 0 deletions math/factorial/gen/near_half.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <cstdio>
#include "../params.h"
#include "random.h"

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

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

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

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

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

int T = T_MAX;
printf("%d\n", T);
for (int t = 0; t < T; ++t) {
int N = gen.uniform<int>(0, MOD - 1);
printf("%d\n", N);
}
return 0;
}
16 changes: 16 additions & 0 deletions math/factorial/hash.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"example_00.in": "180d1bbdde5539dd3a77d325f8940297325665f9f1be249c051dad6aa177200a",
"example_00.out": "c73d2af1573bc3649136764834711acaf148eb3588cc639d8bf5a57da9bdd867",
"near_half_00.in": "b9b509e96007f2595f9a1845c56544b107a20794261c0a3913056ebc1c472d48",
"near_half_00.out": "09c498ab37ca56ec5d94ca104802a0a8fbc78539941f994880463e874cb5e266",
"near_half_01.in": "78c59f15afe18136e693628e08aa54d462218ac825d29667c75f5d0e6044babc",
"near_half_01.out": "0d58b0459853ec01a08a006ee4f2288c2304264e5551b3a0d65b93dfe111620b",
"near_max_00.in": "da530850d58cc2e3e79f6104dc0af91b76a0ec7d61fc5120b4487f2a94312d6f",
"near_max_00.out": "06f27a007c8c14ad2cb868844bd5a5e94346dc144ee51b6446a1b684a104902f",
"near_max_01.in": "2d4f31d5ddec6a701ed69d204aaa8c49439066f4d675fd99774795757358dc3c",
"near_max_01.out": "3655b1fb1215b40a9c762042096ef89af95e7aa94da5ca63b7daf72263c023a1",
"random_00.in": "ef2dc732889096480a438e542b5dc79018083e8771651ef8ffa37b0fd1f6c246",
"random_00.out": "65ac0924d4ca6ff146997bc802a42aec719d48cc8556127fc2f5d514efaef047",
"random_01.in": "0842027f68881d70d3376224a68b92f9e19f13840ef9d573acdba3c85d1fc1d0",
"random_01.out": "bd08bbc7d8dd2d279da20ce0ba42d99198728e7b3faccc03ab24c4d5576066f1"
}
26 changes: 26 additions & 0 deletions math/factorial/info.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
title = 'Factorial'
timelimit = 10.0
forum = "https://github.com/yosupo06/library-checker-problems/issues/128"

[[tests]]
name = "example.in"
number = 1
[[tests]]
name = "random.cpp"
number = 2
[[tests]]
name = "near_max.cpp"
number = 2
[[tests]]
name = "near_half.cpp"
number = 2

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


[params]
T_MAX = 5
MOD = 998244353
Loading

0 comments on commit 2f96c0a

Please sign in to comment.