Skip to content

Commit

Permalink
Merge pull request yosupo06#1236 from NyaanNyaan/master
Browse files Browse the repository at this point in the history
問題追加 Sum of Multiplicative Function
  • Loading branch information
maspypy authored Sep 14, 2024
2 parents 96c1e6e + 412db09 commit 3ed5e25
Show file tree
Hide file tree
Showing 32 changed files with 2,886 additions and 0 deletions.
62 changes: 62 additions & 0 deletions number_theory/sum_of_multiplicative_function/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");
}
}
29 changes: 29 additions & 0 deletions number_theory/sum_of_multiplicative_function/gen/boundaryA.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include <cassert>
#include <iostream>
#include <vector>

#include "../params.h"
#include "random.h"

using namespace std;
using ll = long long;

ll f(ll n) {
ll ret = 1;
while ((ret + 1) * (ret + 1) <= n) ++ret;
return ret * ret;
}

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

ll N = gen.uniform<ll>(1000LL, N_MAX - 10L);
ll d = seed % 5 - 2;
int a = gen.uniform<int>(2, MOD - 1);
int b = gen.uniform<int>(2, MOD - 1);

printf("1\n");
printf("%lld %d %d\n", f(N) + d, a, b);
return 0;
}
29 changes: 29 additions & 0 deletions number_theory/sum_of_multiplicative_function/gen/boundaryB.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include <cassert>
#include <iostream>
#include <vector>

#include "../params.h"
#include "random.h"

using namespace std;
using ll = long long;

ll f(ll n) {
ll ret = 1;
while ((ret + 1) * (ret + 2) <= n) ++ret;
return ret * (ret + 1);
}

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

ll N = gen.uniform<ll>(1000LL, N_MAX - 10L);
ll d = seed % 5 - 2;
int a = gen.uniform<int>(2, MOD - 1);
int b = gen.uniform<int>(2, MOD - 1);

printf("1\n");
printf("%lld %d %d\n", f(N) + d, a, b);
return 0;
}
11 changes: 11 additions & 0 deletions number_theory/sum_of_multiplicative_function/gen/example_00.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
10
1 2 3
2 2 3
3 2 3
4 2 3
5 2 3
6 2 3
7 2 3
8 2 3
9 2 3
10 2 3
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1
100 4 5
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1
100000000000 6 7
Loading

0 comments on commit 3ed5e25

Please sign in to comment.