submission_id stringlengths 10 10 | problem_id stringlengths 6 6 | language stringclasses 3 values | code stringlengths 1 522k | compiler_output stringlengths 43 10.2k |
|---|---|---|---|---|
s147580166 | p03831 | C++ | #include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;
using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;
namespace output {
void pr(int x) { cout << x; }
void pr(long x) { cout << x; }
void pr(ll x) { cout << x; }
void pr(unsigned x) { cout << x; }
void pr(unsigned long x) { cout << x; }
void pr(unsigned long long x) { cout << x; }
void pr(float x) { cout << x; }
void pr(double x) { cout << x; }
void pr(ld x) { cout << x; }
void pr(char x) { cout << x; }
void pr(const char* x) { cout << x; }
void pr(const string& x) { cout << x; }
void pr(bool x) { pr(x ? "true" : "false"); }
template<class T> void pr(const complex<T>& x) { cout << x; }
template<class T1, class T2> void pr(const pair<T1,T2>& x);
template<class T> void pr(const T& x);
template<class T, class... Ts> void pr(const T& t, const Ts&... ts) {
pr(t); pr(ts...);
}
template<class T1, class T2> void pr(const pair<T1,T2>& x) {
pr("{",x.f,", ",x.s,"}");
}
template<class T> void pr(const T& x) {
pr("{"); // const iterator needed for vector<bool>
bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0;
pr("}");
}
void print() { pr("\n"); } // print w/ spaces
template<class T, class... Ts> void print(const T& t, const Ts&... ts) {
pr(t); if (sizeof...(ts)) pr(" "); print(ts...);
}
}
using namespace output;
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int N, A, B; cin >> N >> A >> B;
vi arr (N);
F0R(i, N) cin >> arr[i];
ll ans = 0;
F0R(i, N-1) {
ans += min(B, 1LL * A * (arr[i+1] - arr[i]));
}
print(ans);
} | a.cc: In function 'int main()':
a.cc:65:27: error: no matching function for call to 'min(int&, long long int)'
65 | ans += min(B, 1LL * A * (arr[i+1] - arr[i]));
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:65:27: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
65 | ans += min(B, 1LL * A * (arr[i+1] - arr[i]));
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:65:27: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
65 | ans += min(B, 1LL * A * (arr[i+1] - arr[i]));
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
s783085446 | p03831 | Java | //
import java.math.*;
import java.util.*;
import java.io.*;
public class Main {
static BufferedReader in;
static PrintWriter out = new PrintWriter(System.out);
static String file = "../in";
static int test = 1; // 0 for local testing, 1 for std input
static int inf = 1_000_000;
void swap(int[]ary, int i, int j)
{
int t = ary[i];
ary[i] = ary[j];
ary[j] = t;
}
String[] split() throws Exception
{
return in.readLine().split(" ");
}
int readInt() throws Exception
{
return Integer.valueOf(in.readLine());
}
int[] toIntArray() throws Exception
{
String[] sp = split();
int n = sp.length;
int[] ary = new int[n];
for(int i = 0; i < n; i++) ary[i] = Integer.valueOf(sp[i]);
return ary;
}
String reverse(String str)
{
return new StringBuilder(str).reverse().toString();
}
public static void main(String[] args) throws Exception
{
int _k = Integer.valueOf("1");
if(test > 0) in = new BufferedReader(new InputStreamReader(System.in));
else in = new BufferedReader(new FileReader(file));
if(test < 0) {String[] str = in.readLine().split(" ");}
/***********************************************************************/
/***********************************************************************/
/***********************************************************************/
/***********************************************************************/
// System.out.println((-100 + 0) / 2);
new Main().b();
out.flush();
}
void b() throws Exception
{
int[] ary = toIntArray();
int n = ary[0], a = ary[1], b = ary[2];
ary = toIntArray();
long sum = 0;
f[0] = 0;
for(int i = 1; i < n; i++)
{
long costa = (0L + ary[i] - ary[i - 1]) * a,
costb = 0L + b;
sum += Math.min(costa, costb);
}
out.println(sum);
}
}
| Main.java:67: error: cannot find symbol
f[0] = 0;
^
symbol: variable f
location: class Main
1 error
|
s882980639 | p03831 | C++ | #include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define chmax(a, b) a = (((a)<(b))?(b):(a))
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
std::fill( (T*)array, (T*)(array+N), val );
}
__attribute__((constructor))
void initial(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
cout << fixed << setprecision(15);
}
signed main(){
ll n,a,b; cin>>n>>a>>b;
VL x(n); rep(i,n) cin>>x[i];
ll ans = 0;
rep(i,n-1){
int d = x[i+1]-x[i];
ans += min(a*d,b);
}
cout << ans << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:54:3: error: 'VL' was not declared in this scope; did you mean 'VI'?
54 | VL x(n); rep(i,n) cin>>x[i];
| ^~
| VI
a.cc:54:26: error: 'x' was not declared in this scope
54 | VL x(n); rep(i,n) cin>>x[i];
| ^
a.cc:57:13: error: 'x' was not declared in this scope
57 | int d = x[i+1]-x[i];
| ^
|
s347697223 | p03831 | C++ | import java.util.*;
import java.lang.Math;
public class D{
static Scanner sc = new Scanner(System.in);
public static void main(String[] args){
int n = sc.nextInt();
int a = sc.nextInt();
int b = sc.nextInt();
long[] x = new long[n];
long ans = 0L;
for(int i = 0; i < n; ++i){
x[i] = sc.nextLong();
if(i == 0) continue;
ans += Math.min(a * (x[i] - x[i - 1]), b);
}
System.out.println(ans);
}
} | a.cc:1:1: error: 'import' does not name a type
1 | import java.util.*;
| ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
2 | import java.lang.Math;
| ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: expected unqualified-id before 'public'
4 | public class D{
| ^~~~~~
|
s860836026 | p03831 | C++ | // IOI 2021
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
#define debug(x) cerr << #x << ": " << x << endl
#define debugP(p) cerr << #p << ": {" << p.first << ", " << p.second << '}' << endl
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1e9, MOD = 1e9 + 7;
/////////////////////////////////////////////////////////////////////
const int N = 1e5 + 5;
int X[N];
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int n, a, b; cin >> n >> a >> b;
for (int i = 0; i < n; i++) cin >> X[i];
ll ans = 0;
for (int i = 1; i < n; i++) ans += min(b, 1LL * a * (X[i] - X[i - 1]));
cout << ans << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:31:47: error: no matching function for call to 'min(int&, long long int)'
31 | for (int i = 1; i < n; i++) ans += min(b, 1LL * a * (X[i] - X[i - 1]));
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:3:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:31:47: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
31 | for (int i = 1; i < n; i++) ans += min(b, 1LL * a * (X[i] - X[i - 1]));
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:31:47: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
31 | for (int i = 1; i < n; i++) ans += min(b, 1LL * a * (X[i] - X[i - 1]));
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
s210144112 | p03831 | C++ | using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define out(a) cout<<a<<" "
#define all(a) (a).begin(), (a).end()
#define upper_index(v, a) (int)distance(v.begin(), upper_bound((v).begin(), (v).end(), a))
#define lower_index(v, a) (int)distance(v.begin(), lower_bound((v).begin(), (v).end(), a))
typedef long long ll;
const long long INF = 1e17;
int main() {
ll n,a,b;
vector<ll> x(n);
cin>>n>>a>>b;
rep(i,n) cin>>x[i];
ll cnt=0;
rep(i,n-1){
cnt+=min(a*(x[i+1]-x[i]),b);
}
cout<<cnt<<endl;
} | a.cc: In function 'int main()':
a.cc:12:9: error: 'vector' was not declared in this scope
12 | vector<ll> x(n);
| ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
+++ |+#include <vector>
1 | using namespace std;
a.cc:12:18: error: expected primary-expression before '>' token
12 | vector<ll> x(n);
| ^
a.cc:12:20: error: 'x' was not declared in this scope
12 | vector<ll> x(n);
| ^
a.cc:13:9: error: 'cin' was not declared in this scope
13 | cin>>n>>a>>b;
| ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
+++ |+#include <iostream>
1 | using namespace std;
a.cc:17:18: error: 'min' was not declared in this scope; did you mean 'main'?
17 | cnt+=min(a*(x[i+1]-x[i]),b);
| ^~~
| main
a.cc:19:9: error: 'cout' was not declared in this scope
19 | cout<<cnt<<endl;
| ^~~~
a.cc:19:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:19:20: error: 'endl' was not declared in this scope
19 | cout<<cnt<<endl;
| ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
+++ |+#include <ostream>
1 | using namespace std;
|
s664373991 | p03831 | C++ | // https://atcoder.jp/contests/arc067/tasks/arc067_b
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
#define int int64_t
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, a, b;
cin >> n >> a >> b;
vector<int> v(n);
REP(i, n) cin >> v[i];
int sum = 0;
REP(i, n - 1) sum += min((v[i + 1] - v[i]) * a, b);
cout << sum << endl;
return 0;
}
| a.cc:5:13: error: '::main' must return 'int'
5 | #define int int64_t
| ^~~~~~~
a.cc:11:1: note: in expansion of macro 'int'
11 | int main() {
| ^~~
|
s250632676 | p03831 | C++ | #include <bits/stdc++.h>
using namespace std;
vector<long long> input(long long N) {
vector<long long> res(N);
for (int i = 0; i < N; i++) {
cin >> res.at(i);
}
return res;
}
int main(){
long long N, A, B;
long long sum = 0;
cin >> N >> A >> B;
vector<long long> X(N);
X = input(N);
for(int i = 1; i < N; i++)sum += min(A * (X[i - 1] - X[i], B);
cout << sum << endl;
} | a.cc: In function 'int main()':
a.cc:18:66: error: expected ')' before ';' token
18 | for(int i = 1; i < N; i++)sum += min(A * (X[i - 1] - X[i], B);
| ~ ^
| )
|
s931467242 | p03831 | C++ | コンテスト時間: 2017-01-15(日) 21:00 ~ 2017-01-15(日) 22:40 AtCoderホームへ戻る
トップ
問題
質問
提出
提出結果
順位表
コードテスト
解説
コードテスト
言語
C++14 (GCC 5.4.1)
ソースコード
1
#include<bits/stdc++.h>
2
using namespace std;
3
int main(){
4
int N,A,B;
5
cin >> N >> A >> B;
6
vector<int> vec(N);
7
for(int i=0; i<N; i++){
8
cin >> vec.at(i);
9
}
10
int64_t ans = 0;
11
for(int i=0; i<N-1; i++){
12
if((vec.at(i+1) - vec.at(i))*A < B){
13
ans += (vec.at(i+1) - vec.at(i))*A;
14
}
15
else{
16
ans += B;
17
}
18
}
19
cout << ans << endl;
20
} | a.cc:12:12: error: too many decimal points in number
12 | C++14 (GCC 5.4.1)
| ^~~~~
a.cc:1:1: error: '\U000030b3\U000030f3\U000030c6\U000030b9\U000030c8\U00006642\U00009593' does not name a type
1 | コンテスト時間: 2017-01-15(日) 21:00 ~ 2017-01-15(日) 22:40 AtCoderホームへ戻る
| ^~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:62,
from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:16:
/usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity
164 | __is_null_pointer(std::nullptr_t)
| ^
/usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)'
159 | __is_null_pointer(_Type)
| ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std'; did you mean 'nullptr_t'?
164 | __is_null_pointer(std::nullptr_t)
| ^~~~~~~~~
In file included from /usr/include/c++/14/cstddef:50,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:41:
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:443:29: note: 'nullptr_t' declared here
443 | typedef decltype(nullptr) nullptr_t;
| ^~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
from /usr/include/c++/14/bits/stl_algobase.h:64:
/usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std'; did you mean 'nullptr_t'?
666 | struct is_null_pointer<std::nullptr_t>
| ^~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:443:29: note: 'nullptr_t' declared here
443 | typedef decltype(nullptr) nullptr_t;
| ^~~~~~~~~
/usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid
666 | struct is_null_pointer<std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid
670 | struct is_null_pointer<const std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid
674 | struct is_null_pointer<volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid
678 | struct is_null_pointer<const volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^
/usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1438 | : public integral_constant<std::size_t, 0> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid
1438 | : public integral_constant<std::size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared
1440 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope
1441 | struct rank<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid
1441 | struct rank<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:2086:26: error: 'std::size_t' has not been declared
2086 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:2087:30: error: '_Size' was not declared in this scope
2087 | struct remove_extent<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:2087:36: error: template argument 1 is invalid
2087 | struct remove_extent<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:2099:26: error: 'std::size_t' has not been declared
2099 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:2100:35: error: '_Size' was not declared in this scope
2100 | struct remove_all_extents<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:2100:41: error: template argument 1 is invalid
2100 | struct remove_all_extents<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:2171:12: error: 'std::size_t' has not been declared
2171 | template<std::size_t _Len>
| ^~~
/usr/include/c++/14/type_traits:2176:30: error: '_Len' was not declared in this scope
2176 | unsigned char __data[_Len];
| ^~~~
/usr/include/c++/14/type_traits:2194:12: error: 'std::size_t' has not been declared
2194 | template<std::size_t _Len, std::size_t _Align =
| ^~~
/usr/include/c++/14/type_traits:2194:30: error: 'std::size_t' has not been declared
2194 | template<std::size_t _Len, std::size_t _Align =
| ^~~
/usr/include/c++/14/type_traits:2195:55: error: '_Len' was not declared in this scope
2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)>
| ^~~~
/usr/include/c++/14/type_traits:2195:59: error: template argument 1 is invalid
2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)>
| ^
/usr/include/c++/14/type_traits:2202:30: error: '_Len' was not declared in this scope
2202 | unsigned char __data[_Len];
| ^~~~
/usr/include/c++/14/type_traits:2203:44: error: '_Align' was not declared in this scope
2203 | struct __attribute__((__aligned__((_Align)))) { } __align;
| ^~~~~~
In file included from /usr/include/c++/14/bits/stl_tempbuf.h:59,
from /usr/include/c++/14/bits/stl_algo.h:69,
from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/new:131:26: error: declaration of 'operator new' as non-function
131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~~~
/usr/include/c++/14/new:131:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:132:41: error: attributes after parenthesized initializer ignored [-fpermissive]
132 | __attribute__((__externally_visible__));
| ^
/usr/include/c++/14/new:133:26: error: declaration of 'operator new []' as non-function
133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~~~
/usr/include/c++/14/new:133:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __S |
s216941034 | p03831 | C++ | #include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
#include <math.h>
using namespace std;
#define INF 210000000
#define int long long
static long long gcd(long long a, long long b) {
int amari = a % b;
int c = b;
if (amari == 0) {
return b;
} else {
return gcd(b, amari);
}
}
static long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
int main() {
int n;
cin >> n;
int tele,walk;
cin >> walk >> tele;
vector<int> town;
for (int i=0;i<n;i++){
int tmp;
cin >> tmp;
town.push_back(tmp);
}
int ans = 0;
for (int i=1;i<n;i++){
if((town[i] - town[i-1]) * walk < tele){
ans += (town[i] - town[i-1]) * walk;
}else{
ans += tele;
}
}
cout << ans;
}
| cc1plus: error: '::main' must return 'int'
|
s554385435 | p03831 | C++ | #include<bits/stdc++.h>
using namespace std;
#define int long long
int $(int a,int b) {
if(a%b==0)
return a/b;
else
return a/b+1;
}
signed main(){
int a,b,c,e=0,f,g,h;
cin>>a>>b>>c;
vector<int> d(a);
for(int i=0;i<a;i++)
cin>>d.at(i);
for(int i=0;i<a-1;i++){
f=a.at(i);
g=a.at(i+1);
h=g-f;
if(b*h<=c)
e+=b*h;
else
e+=c;
}
cout<<e<<endl;
} | a.cc: In function 'int main()':
a.cc:18:9: error: request for member 'at' in 'a', which is of non-class type 'long long int'
18 | f=a.at(i);
| ^~
a.cc:19:9: error: request for member 'at' in 'a', which is of non-class type 'long long int'
19 | g=a.at(i+1);
| ^~
|
s862206309 | p03831 | C | #include<iostream>
using namespace std;
int main()
{ long n,a,b,i,x[100],sum=0;
cin>>n>>a>>b;
for(i=1;i<=n;i++)
cin>>x[i];
for(i=1;i<n;i++)
{
if((x[i+1]-x[i])*a>=b) sum+=b;
else sum+=(x[i+1]-x[i])*a;
}
cout<<sum;
getchar();
getchar();
return 0;
} | main.c:1:9: fatal error: iostream: No such file or directory
1 | #include<iostream>
| ^~~~~~~~~~
compilation terminated.
|
s232282767 | p03831 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N,B;
long A;
cin >> N >> A >> B;
int X[N];
cin >> X[0];
long sum=0;
for(int i=1;i<N;i++){
cin >> X[i];
sum+=min(B,A*(X[i]-X[i-1]));
}
cout << sum;
}
| a.cc: In function 'int main()':
a.cc:13:13: error: no matching function for call to 'min(int&, long int)'
13 | sum+=min(B,A*(X[i]-X[i-1]));
| ~~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:13:13: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long int')
13 | sum+=min(B,A*(X[i]-X[i-1]));
| ~~~^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:13:13: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
13 | sum+=min(B,A*(X[i]-X[i-1]));
| ~~~^~~~~~~~~~~~~~~~~~~
|
s824905142 | p03831 | C++ | #include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
ll n,a,b,A[200000],ans=0;
cin>>n>>a>>b;
rep(i,n) cin>>A[i];
rep(i,n-1){
if((A[i+1]-A[i])*a<=b) ans+=(A[i+1]-A[i])*a;
else ans+=b;
}
cout<ans;
} | a.cc: In function 'int main()':
a.cc:13:9: error: no match for 'operator<' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and 'll' {aka 'long long int'})
13 | cout<ans;
| ~~~~^~~~
| | |
| | ll {aka long long int}
| std::ostream {aka std::basic_ostream<char>}
a.cc:13:9: note: candidate: 'operator<(int, ll {aka long long int})' (built-in)
13 | cout<ans;
| ~~~~^~~~
a.cc:13:9: note: no known conversion for argument 1 from 'std::ostream' {aka 'std::basic_ostream<char>'} to 'int'
In file included from /usr/include/c++/14/regex:68,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181,
from a.cc:1:
/usr/include/c++/14/bits/regex.h:1143:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const sub_match<_BiIter>&)'
1143 | operator<(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1143:5: note: template argument deduction/substitution failed:
a.cc:13:10: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
13 | cout<ans;
| ^~~
/usr/include/c++/14/bits/regex.h:1224:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)'
1224 | operator<(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1224:5: note: template argument deduction/substitution failed:
a.cc:13:10: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>'
13 | cout<ans;
| ^~~
/usr/include/c++/14/bits/regex.h:1317:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)'
1317 | operator<(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1317:5: note: template argument deduction/substitution failed:
a.cc:13:10: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
13 | cout<ans;
| ^~~
/usr/include/c++/14/bits/regex.h:1391:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)'
1391 | operator<(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1391:5: note: template argument deduction/substitution failed:
a.cc:13:10: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'll' {aka 'long long int'}
13 | cout<ans;
| ^~~
/usr/include/c++/14/bits/regex.h:1485:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)'
1485 | operator<(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1485:5: note: template argument deduction/substitution failed:
a.cc:13:10: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
13 | cout<ans;
| ^~~
/usr/include/c++/14/bits/regex.h:1560:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)'
1560 | operator<(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1560:5: note: template argument deduction/substitution failed:
a.cc:13:10: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'll' {aka 'long long int'}
13 | cout<ans;
| ^~~
/usr/include/c++/14/bits/regex.h:1660:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)'
1660 | operator<(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1660:5: note: template argument deduction/substitution failed:
a.cc:13:10: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
13 | cout<ans;
| ^~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed:
a.cc:13:10: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::pair<_T1, _T2>'
13 | cout<ans;
| ^~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:67:
/usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
448 | operator<(const reverse_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed:
a.cc:13:10: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
13 | cout<ans;
| ^~~
/usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
493 | operator<(const reverse_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed:
a.cc:13:10: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
13 | cout<ans;
| ^~~
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
1694 | operator<(const move_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note: template argument deduction/substitution failed:
a.cc:13:10: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
13 | cout<ans;
| ^~~
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
1760 | operator<(const move_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note: template argument deduction/substitution failed:
a.cc:13:10: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
13 | cout<ans;
| ^~~
In file included from /usr/include/c++/14/bits/basic_string.h:47,
from /usr/include/c++/14/string:54,
from /usr/include/c++/14/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/string_view:673:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)'
673 | operator< (basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:673:5: note: template argument deduction/substitution failed:
a.cc:13:10: note: 'std::basic_ostream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
13 | cout<ans;
| ^~~
/usr/include/c++/14/string_view:680:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)'
680 | operator< (basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:680:5: note: template argument deduction/substitution failed:
a.cc:13:10: note: 'std::basic_ostream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
13 | cout<ans;
| ^~~
/usr/include/c++/14/string_view:688:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)'
688 | operator< (__type_identity_t<basic_string_view<_CharT, _Traits>> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:688:5: note: template argument deduction/substitution failed:
a.cc:13:10: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'long long int'
13 | cout<ans;
| ^~~
/usr/include/c++/14/bits/basic_string.h:3874:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3874 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3874:5: note: template argument deduction/substitution failed:
a.cc:13:10: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
13 | cout<ans;
| |
s420807622 | p03831 | C++ | #include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
using namespace std;
typedef long long int ll
int main()
{
ll n,a,b;
ll x[100000] = {0};
cin >> n >> a >> b;
ll d[100000] = {0};
for(int i = 0; i < n; i++)
{
cin >> x[i];
//cout << "x == " << x[i] << endl;
}
for(int i = 0; i < n-1; i++)
{
d[i] = (x[i+1] - x[i]) * a;
if (d[i] > b)
{
d[i] = b;
}
}
ll sum = 0;
for(int i = 0; i < n-1; i++)
{
//printf("d[%d] = %d\n", i, d[i]);
sum += d[i];
}
cout << sum << endl;
return 0;
}
| a.cc:10:1: error: expected initializer before 'int'
10 | int main()
| ^~~
|
s729590521 | p03831 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int N, A, B, curr, next, int ret = 0;
cin >> N >> A >> B >> curr;
for (int i = 1; i < N; i++) {
cin >> next;
ret += min((next - curr) * A, B);
curr = next;
}
cout << ret << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:4:38: error: expected unqualified-id before 'int'
4 | long long int N, A, B, curr, next, int ret = 0;
| ^~~
a.cc:8:5: error: 'ret' was not declared in this scope
8 | ret += min((next - curr) * A, B);
| ^~~
a.cc:11:11: error: 'ret' was not declared in this scope
11 | cout << ret << endl;
| ^~~
|
s602119076 | p03831 | C++ | #include <iostream>
#include <vector>
using namespace std;
using ll = long long;
#define int ll
int main() {
int N, A, B;
cin >> N >> A >> B;
vector<int> X(N);
for (int i = 0; i < N; i++) cin >> X[i];
int ret = 0;
for (int i = 0; i < N - 1; i++) {
ret += min(B, A * abs(X[i] - X[i+1]));
}
cout << ret << endl;
} | a.cc:6:13: error: '::main' must return 'int'
6 | #define int ll
| ^~
a.cc:8:1: note: in expansion of macro 'int'
8 | int main() {
| ^~~
|
s194140661 | p03831 | C++ | #include <iostream>
#include <vector>
using namespace std;
using ll = long long;
#define int ll;
int main() {
int N, A, B;
cin >> N >> A >> B;
vector<int> X(N);
for (int i = 0; i < N; i++) cin >> X[i];
int ret = 0;
for (int i = 0; i < N - 1; i++) {
ret += min(B, A * abs(X[i] - X[i+1]));
}
cout << ret << endl;
}
| a.cc:6:13: error: declaration does not declare anything [-fpermissive]
6 | #define int ll;
| ^~
a.cc:8:1: note: in expansion of macro 'int'
8 | int main() {
| ^~~
a.cc:8:5: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
8 | int main() {
| ^~~~
a.cc: In function 'int main()':
a.cc:6:13: error: declaration does not declare anything [-fpermissive]
6 | #define int ll;
| ^~
a.cc:9:3: note: in expansion of macro 'int'
9 | int N, A, B;
| ^~~
a.cc:9:7: error: 'N' was not declared in this scope
9 | int N, A, B;
| ^
a.cc:9:10: error: 'A' was not declared in this scope
9 | int N, A, B;
| ^
a.cc:9:13: error: 'B' was not declared in this scope
9 | int N, A, B;
| ^
a.cc:6:13: error: template argument 1 is invalid
6 | #define int ll;
| ^~
a.cc:11:10: note: in expansion of macro 'int'
11 | vector<int> X(N);
| ^~~
a.cc:6:13: error: template argument 2 is invalid
6 | #define int ll;
| ^~
a.cc:11:10: note: in expansion of macro 'int'
11 | vector<int> X(N);
| ^~~
a.cc:11:13: error: expected primary-expression before '>' token
11 | vector<int> X(N);
| ^
a.cc:11:15: error: 'X' was not declared in this scope
11 | vector<int> X(N);
| ^
a.cc:6:13: error: declaration does not declare anything [-fpermissive]
6 | #define int ll;
| ^~
a.cc:12:8: note: in expansion of macro 'int'
12 | for (int i = 0; i < N; i++) cin >> X[i];
| ^~~
a.cc:12:12: error: 'i' was not declared in this scope
12 | for (int i = 0; i < N; i++) cin >> X[i];
| ^
a.cc:12:24: error: expected ')' before ';' token
12 | for (int i = 0; i < N; i++) cin >> X[i];
| ~ ^
| )
a.cc:12:26: error: 'i' was not declared in this scope
12 | for (int i = 0; i < N; i++) cin >> X[i];
| ^
a.cc:6:13: error: declaration does not declare anything [-fpermissive]
6 | #define int ll;
| ^~
a.cc:14:3: note: in expansion of macro 'int'
14 | int ret = 0;
| ^~~
a.cc:14:7: error: 'ret' was not declared in this scope
14 | int ret = 0;
| ^~~
a.cc:6:13: error: declaration does not declare anything [-fpermissive]
6 | #define int ll;
| ^~
a.cc:15:8: note: in expansion of macro 'int'
15 | for (int i = 0; i < N - 1; i++) {
| ^~~
a.cc:15:28: error: expected ')' before ';' token
15 | for (int i = 0; i < N - 1; i++) {
| ~ ^
| )
|
s195639303 | p03831 | C++ | #include <bits/stdc++.h>
using namespace std;
// clang-format off
#define range(i, l, r) for (int i = (int)l; i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = ((int)(r) - 1); i >= (int)l; --(i))
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define rwhole(f,x,...) ([&](decltype((x)) whole) { return (f)(rbegin(whole), rend(whole), ## __VA_ARGS__); })(x)
#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl
inline void br(ostream &os = cerr) { os << endl; }
using int32 = int;
using int64 = long long;
const int mod = 1e9 + 7;
const int32 inf = 1001001001;
const int64 infll = 1001001001001001001ll;
const int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const string YES = "YES", NO = "NO", Yes = "Yes", No = "No", yes = "yes", no = "no";
struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;
template <typename T = int64> T input() { T x; cin >> x; return x; }
template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }
template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on
void solver() {
int64 N = input(), A = input(), B = input();
vector<int64> X(N);
cin >> X;
int64 ans = 0;
range(i, 1, N) {
ans += min((X[i] - X[i - 1]) * A, B);
}
cout << ans <<
}
signed main(int argc, char *argv[]) {
solver();
} | a.cc: In function 'void solver()':
a.cc:53:1: error: expected primary-expression before '}' token
53 | }
| ^
|
s437386625 | p03831 | C++ | #include<cstdio>
#include<algorithm>
using namespace std;
int arr[100005];
int main(){
int N, A, B;
scanf("%d%d%d",&N,&A,&B);
long long ans = 0;
for(int i=0;i<N;i++){
scanf("%d",&arr[i]);
}
for(int i=1;i<N;i++){
ans += min(1ll*abs(arr[i]-arr[i-1])*A,B);
}
printf("%lld\n",ans);
return 0;
}
| a.cc: In function 'int main()':
a.cc:15:19: error: no matching function for call to 'min(long long int, int&)'
15 | ans += min(1ll*abs(arr[i]-arr[i-1])*A,B);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from a.cc:2:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:15:19: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
15 | ans += min(1ll*abs(arr[i]-arr[i-1])*A,B);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:15:19: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
15 | ans += min(1ll*abs(arr[i]-arr[i-1])*A,B);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
s638291032 | p03831 | C++ | /*g++ file.cpp -o file.out*/
/*./file.out*/
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define LL long long
#define Mod 1000000007
#define L_Mod 17100000013
int sov[100005],tmp[100005];
int main()
{
int N,A,B;
scanf("%d%d%d",&N,&A,&B);
for(int i=1;i<=n;i++)
{
scanf("%d",&tmp[i]);
}
tmp[0]=0;
sov[1]=0;
for(int i=2;i<=n;i++)
{
sov[i]=min(sov[i-1]+(tmp[i]-tmp[i-1])*A,sov[i-1]+B);
}
printf("%d\n",sov[n]);
return 0;
} | a.cc: In function 'int main()':
a.cc:24:20: error: 'n' was not declared in this scope
24 | for(int i=1;i<=n;i++)
| ^
a.cc:30:20: error: 'n' was not declared in this scope
30 | for(int i=2;i<=n;i++)
| ^
a.cc:34:23: error: 'n' was not declared in this scope
34 | printf("%d\n",sov[n]);
| ^
|
s424793540 | p03831 | C++ | #include<cstdio>
#include<algorithm>
using namespace std;
using ll = long long;
int main(){
int N, A, B, prev;
scanf("%d %d %d\n%d", &N, &A, &B, &prev);
ll answer = 0;
for (int i = 1; i < N; ++i){
int tmp;
scanf("%d", &tmp);
answer += min((ll)(tmp - prev)*A, B);
prev = tmp;
}
printf("%lld\n", answer);
return 0;
} | a.cc: In function 'int main()':
a.cc:13:30: error: no matching function for call to 'min(ll, int&)'
13 | answer += min((ll)(tmp - prev)*A, B);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from a.cc:2:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:13:30: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
13 | answer += min((ll)(tmp - prev)*A, B);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:13:30: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
13 | answer += min((ll)(tmp - prev)*A, B);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~
|
s439148249 | p03831 | C++ | #include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define repn(i,n) rep(i,0,n)
const double EPS = 1e-5;
const int MOD = 1e9+7;
const int N = 1e5;
const int A = 1e9;
const int B = 1e9;
int x[N];
ll res
int main(){
ll n,a,b;
cin >> n >> a >> b;
repn(i,n){
cin << x[i];
}
ll res = 0;
repn(i,n-1){
res = res + min(b, (x[i + 1] - x[i]) * a);
}
cout << res << endl;
return 0;
}
| a.cc:20:1: error: expected initializer before 'int'
20 | int main(){
| ^~~
|
s088496798 | p03831 | C++ | #include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
long long counter = 0;
long long n, a, b;
cin >> n >> a >> b;
vector<int> towns(n);
for (int i = 0; i < n; i++) {
cin >> towns[i];
}
for (int i = 1; i < n; i++) {
int distance = (towns[i] - towns[i - 1]) * a;
counter += min(distance, b);
}
cout << counter;
return 0;
}
| a.cc: In function 'int main()':
a.cc:19:19: error: no matching function for call to 'min(int&, long long int&)'
19 | counter += min(distance, b);
| ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:19:19: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
19 | counter += min(distance, b);
| ~~~^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
from a.cc:2:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:19:19: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
19 | counter += min(distance, b);
| ~~~^~~~~~~~~~~~~
|
s235060891 | p03831 | C++ | #include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <limits.h>
#include <cinttypes>
#include <string.h>
#include <bits/stdc++.h>
using namespace std;
#define countof(a) (sizeof(a)/sizeof(*a))
#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pi >
#define pi pair<int,int>
#define fi first
#define se second
#define all(n) n.begin(), n.end()
#define FOR(var, to) for (register s64 var = 0; var < (s64)to; var++)
#define FROMTO(var, from, to) for (register s64 var = from; var <= (s64)to; var++)
#define INIT(var) FOR(i,countof(var)) var[i] = 0
#define INPUT(var) FOR(i,countof(var)) var[i] = ri()
#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)
#define QSORT(v,b) qsort(v,countof(v),sizeof(*v),b)
#define MOD 1000000007
#define INF (1 << 30)
typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;
template<int mod>
struct ModInt{
int x;
ModInt():x(0){}
ModInt(long long y):x(y>=0?y%mod:(mod-(-y)%mod)%mod){}
ModInt &operator+=(const ModInt &p){
if((x+=p.x)>=mod)x-=mod;
return *this;
}
ModInt &operator-=(const ModInt &p){
if((x+=mod-p.x)>=mod)x-=mod;
return *this;
}
ModInt &operator*=(const ModInt &p){
x=(int)(1LL*x*p.x%mod);
return *this;
}
ModInt &operator/=(const ModInt &p){
*this*=p.inverse();
return *this;
}
ModInt operator-()const{return ModInt(-x);}
ModInt operator+(const ModInt &p)const{return ModInt(*this)+=p;}
ModInt operator-(const ModInt &p)const{return ModInt(*this)-=p;}
ModInt operator*(const ModInt &p)const{return ModInt(*this)*=p;}
ModInt operator/(const ModInt &p)const{return ModInt(*this)/=p;}
bool operator==(const ModInt &p)const{return x==p.x;}
bool operator!=(const ModInt &p)const{return x!=p.x;}
ModInt inverse()const{
int a=x,b=mod,u=1,v=0,t;
while(b>0){
t=a/b;
a-=t*b;
swap(a,b);
u-=t*v;
swap(u,v);
}
return ModInt(u);
}
friend ostream &operator<<(ostream &os,const ModInt<mod> &p){
return os<<p.x;
}
friend istream &operator>>(istream &is,ModInt<mod> &a){
long long x;
is>>x;
a=ModInt<mod>(x);
return (is);
}
};
typedef ModInt<MOD> mint;
struct UnionFind{
vi data;
UnionFind(int size):data(size,-1){}
bool unite(int x,int y) {
x=root(x);y=root(y);
if(x!=y){
if(data[y]<data[x])swap(x,y);
data[x]+=data[y];data[y]=x;
}
return x!=y;
}
bool find(int x,int y) {
return root(x)==root(y);
}
int root(int x) {
return data[x]<0?x:data[x]=root(data[x]);
}
int size(int x) {
return -data[root(x)];
}
bool united() {
int comroot = -1;
FOR(i,data.size()) {
if (comroot != -1 && root(i) != comroot) return false;
comroot = root(i);
}
return true;
}
};
static inline int ri() {
int a;
scanf("%d", &a);
return a;
}
static inline s64 rs64() {
s64 a;
scanf("%" SCNd64, &a);
return a;
}
static inline void wi(int a) {
printf("%d", a);
}
static inline void wu64(u64 a) {
printf("%" PRIu64, a);
}
static inline void ws64(s64 a) {
printf("%" PRId64, a);
}
int int_less(const void *a, const void *b) {
return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
return (*((const int*)b) - *((const int*)a));
}
int main() {
int n = ri();
int a = ri();
int b = ri();
int x[n];
INPUT(x);
s64 res = 0;
FROMTO(i,1,n-1) res += min(a*((s64)x[i]-x[i-1]),b);
cout << res << endl;
return 0;
}
| a.cc: In member function 'bool UnionFind::united()':
a.cc:117:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
117 | FOR(i,data.size()) {
| ^
a.cc:22:49: note: in definition of macro 'FOR'
22 | #define FOR(var, to) for (register s64 var = 0; var < (s64)to; var++)
| ^~~
a.cc: In function 'int main()':
a.cc:26:24: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
26 | #define INPUT(var) FOR(i,countof(var)) var[i] = ri()
| ^
a.cc:22:49: note: in definition of macro 'FOR'
22 | #define FOR(var, to) for (register s64 var = 0; var < (s64)to; var++)
| ^~~
a.cc:161:3: note: in expansion of macro 'INPUT'
161 | INPUT(x);
| ^~~~~
a.cc:163:10: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
163 | FROMTO(i,1,n-1) res += min(a*((s64)x[i]-x[i-1]),b);
| ^
a.cc:23:49: note: in definition of macro 'FROMTO'
23 | #define FROMTO(var, from, to) for (register s64 var = from; var <= (s64)to; var++)
| ^~~
a.cc:163:29: error: no matching function for call to 'min(s64, int&)'
163 | FROMTO(i,1,n-1) res += min(a*((s64)x[i]-x[i-1]),b);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:8:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:163:29: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'int')
163 | FROMTO(i,1,n-1) res += min(a*((s64)x[i]-x[i-1]),b);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:163:29: note: mismatched types 'std::initializer_list<_Tp>' and 'long int'
163 | FROMTO(i,1,n-1) res += min(a*((s64)x[i]-x[i-1]),b);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~
|
s167821484 | p03831 | C++ | #include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <limits.h>
#include <cinttypes>
#include <string.h>
#include <bits/stdc++.h>
using namespace std;
#define countof(a) (sizeof(a)/sizeof(*a))
#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pi >
#define pi pair<int,int>
#define fi first
#define se second
#define all(n) n.begin(), n.end()
#define FOR(var, to) for (register s64 var = 0; var < (s64)to; var++)
#define FROMTO(var, from, to) for (register s64 var = from; var <= (s64)to; var++)
#define INIT(var) FOR(i,countof(var)) var[i] = 0
#define INPUT(var) FOR(i,countof(var)) var[i] = ri()
#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)
#define QSORT(v,b) qsort(v,countof(v),sizeof(*v),b)
#define MOD 1000000007
#define INF (1 << 30)
typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;
template<int mod>
struct ModInt{
int x;
ModInt():x(0){}
ModInt(long long y):x(y>=0?y%mod:(mod-(-y)%mod)%mod){}
ModInt &operator+=(const ModInt &p){
if((x+=p.x)>=mod)x-=mod;
return *this;
}
ModInt &operator-=(const ModInt &p){
if((x+=mod-p.x)>=mod)x-=mod;
return *this;
}
ModInt &operator*=(const ModInt &p){
x=(int)(1LL*x*p.x%mod);
return *this;
}
ModInt &operator/=(const ModInt &p){
*this*=p.inverse();
return *this;
}
ModInt operator-()const{return ModInt(-x);}
ModInt operator+(const ModInt &p)const{return ModInt(*this)+=p;}
ModInt operator-(const ModInt &p)const{return ModInt(*this)-=p;}
ModInt operator*(const ModInt &p)const{return ModInt(*this)*=p;}
ModInt operator/(const ModInt &p)const{return ModInt(*this)/=p;}
bool operator==(const ModInt &p)const{return x==p.x;}
bool operator!=(const ModInt &p)const{return x!=p.x;}
ModInt inverse()const{
int a=x,b=mod,u=1,v=0,t;
while(b>0){
t=a/b;
a-=t*b;
swap(a,b);
u-=t*v;
swap(u,v);
}
return ModInt(u);
}
friend ostream &operator<<(ostream &os,const ModInt<mod> &p){
return os<<p.x;
}
friend istream &operator>>(istream &is,ModInt<mod> &a){
long long x;
is>>x;
a=ModInt<mod>(x);
return (is);
}
};
typedef ModInt<MOD> mint;
struct UnionFind{
vi data;
UnionFind(int size):data(size,-1){}
bool unite(int x,int y) {
x=root(x);y=root(y);
if(x!=y){
if(data[y]<data[x])swap(x,y);
data[x]+=data[y];data[y]=x;
}
return x!=y;
}
bool find(int x,int y) {
return root(x)==root(y);
}
int root(int x) {
return data[x]<0?x:data[x]=root(data[x]);
}
int size(int x) {
return -data[root(x)];
}
bool united() {
int comroot = -1;
FOR(i,data.size()) {
if (comroot != -1 && root(i) != comroot) return false;
comroot = root(i);
}
return true;
}
};
static inline int ri() {
int a;
scanf("%d", &a);
return a;
}
static inline s64 rs64() {
s64 a;
scanf("%" SCNd64, &a);
return a;
}
static inline void wi(int a) {
printf("%d", a);
}
static inline void wu64(u64 a) {
printf("%" PRIu64, a);
}
static inline void ws64(s64 a) {
printf("%" PRId64, a);
}
int int_less(const void *a, const void *b) {
return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
return (*((const int*)b) - *((const int*)a));
}
int main() {
int n = ri();
int a = ri();
int b = ri();
int x[n];
INPUT(x);
s64 res = 0;
UPTO(i,1,n-1) res += min(a*((s64)x[i]-x[i-1]),b);
cout << res << endl;
return 0;
}
| a.cc: In member function 'bool UnionFind::united()':
a.cc:117:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
117 | FOR(i,data.size()) {
| ^
a.cc:22:49: note: in definition of macro 'FOR'
22 | #define FOR(var, to) for (register s64 var = 0; var < (s64)to; var++)
| ^~~
a.cc: In function 'int main()':
a.cc:26:24: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
26 | #define INPUT(var) FOR(i,countof(var)) var[i] = ri()
| ^
a.cc:22:49: note: in definition of macro 'FOR'
22 | #define FOR(var, to) for (register s64 var = 0; var < (s64)to; var++)
| ^~~
a.cc:161:3: note: in expansion of macro 'INPUT'
161 | INPUT(x);
| ^~~~~
a.cc:163:8: error: 'i' was not declared in this scope
163 | UPTO(i,1,n-1) res += min(a*((s64)x[i]-x[i-1]),b);
| ^
a.cc:163:3: error: 'UPTO' was not declared in this scope
163 | UPTO(i,1,n-1) res += min(a*((s64)x[i]-x[i-1]),b);
| ^~~~
|
s591474799 | p03831 | C++ | #include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <limits.h>
#include <cinttypes>
#include <string.h>
#include <bits/stdc++.h>
#define countof(a) (sizeof(a)/sizeof(*a))
#define vi vector<int>
#define vvi vector<vector<int> >
#define pi pair<int,int>
#define fi first
#define se second
#define FOR(var, to) for (register s64 var = 0; var < (s64)to; var++)
#define FROMTO(var, from, to) for (register s64 var = from; var <= (s64)to; var++)
#define INIT(var) FOR(i,countof(var)) var[i] = 0
#define INPUT(var) FOR(i,countof(var)) var[i] = ri()
#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)
#define MOD 1000000007
#define INF (1 << 30)
typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;
using namespace std;
static inline int ri() {
int a;
scanf("%d", &a);
return a;
}
static inline s64 rs64() {
s64 a;
scanf("%" SCNd64, &a);
return a;
}
static inline void wi(int a) {
printf("%d", a);
}
static inline void wu64(u64 a) {
printf("%" PRIu64, a);
}
static inline void ws64(s64 a) {
printf("%" PRId64, a);
}
int int_less(const void *a, const void *b) {
return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
return (*((const int*)b) - *((const int*)a));
}
int main() {
int n = ri();
int a = ri();
int b = ri();
int x[n];
INPUT(x);
s64 res = 0;
UPTO(i,1,n-1) res += min(a*((s64)x[i]-x[i-1]),b);
cout << res << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:22:24: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
22 | #define INPUT(var) FOR(i,countof(var)) var[i] = ri()
| ^
a.cc:18:49: note: in definition of macro 'FOR'
18 | #define FOR(var, to) for (register s64 var = 0; var < (s64)to; var++)
| ^~~
a.cc:77:3: note: in expansion of macro 'INPUT'
77 | INPUT(x);
| ^~~~~
a.cc:79:8: error: 'i' was not declared in this scope
79 | UPTO(i,1,n-1) res += min(a*((s64)x[i]-x[i-1]),b);
| ^
a.cc:79:3: error: 'UPTO' was not declared in this scope
79 | UPTO(i,1,n-1) res += min(a*((s64)x[i]-x[i-1]),b);
| ^~~~
|
s648315896 | p03831 | C++ | #include <bits/stdc++.h>
using namespace std;
inline long long read(){
char ch=getchar();
long long r=0,s=1;
while(!isdigit(ch)){
if(ch=='-')s=-1;
ch=getchar();
}
while(isdigit(ch)){
r=r*10+ch-'0';
ch=getchar();
}
return r*s;
}
long long n,m,a,s,c[1000000005],b,i,k;
int main()
{
n=read();
a=read();
b=read();
for(i=1;i<=n;i++)
c[i]=read();
for(i=2;i<=n;i++)
{
if((c[i]-c[i-1])*a>=b)
s=s+b;
else
s=s+(c[i]-c[i-1])*a;
}
cout<<s<<endl;
return 0;
} | /tmp/cclw7bKS.o: in function `main':
a.cc:(.text+0x29): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/cclw7bKS.o
a.cc:(.text+0x30): relocation truncated to fit: R_X86_64_PC32 against symbol `i' defined in .bss section in /tmp/cclw7bKS.o
a.cc:(.text+0x3d): relocation truncated to fit: R_X86_64_PC32 against symbol `i' defined in .bss section in /tmp/cclw7bKS.o
a.cc:(.text+0x5c): relocation truncated to fit: R_X86_64_PC32 against symbol `i' defined in .bss section in /tmp/cclw7bKS.o
a.cc:(.text+0x67): relocation truncated to fit: R_X86_64_PC32 against symbol `i' defined in .bss section in /tmp/cclw7bKS.o
a.cc:(.text+0x6e): relocation truncated to fit: R_X86_64_PC32 against symbol `i' defined in .bss section in /tmp/cclw7bKS.o
a.cc:(.text+0x81): relocation truncated to fit: R_X86_64_PC32 against symbol `i' defined in .bss section in /tmp/cclw7bKS.o
a.cc:(.text+0x91): relocation truncated to fit: R_X86_64_PC32 against symbol `i' defined in .bss section in /tmp/cclw7bKS.o
a.cc:(.text+0xab): relocation truncated to fit: R_X86_64_PC32 against symbol `i' defined in .bss section in /tmp/cclw7bKS.o
a.cc:(.text+0xd7): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/cclw7bKS.o
a.cc:(.text+0xea): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
|
s028568039 | p03831 | C++ | #include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int ans = 0;
int n, a, b
int x[100005];
int now = 1;
cin >> n;
cin >> a >> b;
for (int i = 0; i < n; i++) {
cin >> x[i];
}
now = x[0];
for (int i = 1; i < n; i++) {
ans += min(a * (x[i] - now), b);
now = x[i];
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:9:5: error: expected initializer before 'int'
9 | int x[100005];
| ^~~
a.cc:13:17: error: 'b' was not declared in this scope
13 | cin >> a >> b;
| ^
a.cc:15:12: error: 'x' was not declared in this scope
15 | cin >> x[i];
| ^
a.cc:17:12: error: 'x' was not declared in this scope
17 | now = x[0];
| ^
|
s168867321 | p03831 | C++ | #include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int ans = 0;
int n, a, b
int x[100005];
int now = 1;
cin >> n;
cin >> a >> b;
for (int i = 0; i < n; i++) {
cin >> x[i];
}
for (int i = 0; i < n; i++) {
ans += min(a * (x[i] - now), b);
now = x[i];
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:9:3: error: expected initializer before 'int'
9 | int x[100005];
| ^~~
a.cc:13:15: error: 'b' was not declared in this scope
13 | cin >> a >> b;
| ^
a.cc:15:12: error: 'x' was not declared in this scope
15 | cin >> x[i];
| ^
a.cc:19:21: error: 'x' was not declared in this scope
19 | ans += min(a * (x[i] - now), b);
| ^
|
s080954650 | p03831 | C++ | a = list(map(int,input().split()))
b = list(map(int,input().split()))
su = 0
c = [0]
for i in range(len(b)-1):
c.append(0)
for i in range(a[0] - 1):
c[i] = b[i+1] - b[i]
for i in range(a[0]-2):
if a[2] >= c[i]*a[1]:
su += a[2]
else:
su += c[i]*a[1]
print(su) | a.cc:1:1: error: 'a' does not name a type
1 | a = list(map(int,input().split()))
| ^
|
s383070630 | p03831 | C++ | #include<iostream>
#include<string>
#include<cstdlib>
#include<vector>
#include<algorithm>
#include<functional>
#define ll long long int
using namespace std;
int to_int(string s) {
return atoi(s.c_str());
}
int x[10001];
ll dp[10001];
int main() {
int n,a,b;
cin >> n >> a >> b;
for(int i = 0; i < n; i++) {
cin >> x[i];
}
dp[0] = 0;
for(int i = 0; i < n; i++) {
dp[i+1] = dp[i] + min(a*(x[i+1] -x[i]), b);
}
cout << dp[n-1] << endl;
}
#include<iostream>
#include<string>
#include<cstdlib>
#include<vector>
#include<algorithm>
#include<functional>
#define ll long long int
using namespace std;
int to_int(string s) {
return atoi(s.c_str());
}
int x[10001];
ll dp[10001];
int main() {
int n,a,b;
cin >> n >> a >> b;
for(int i = 0; i < n; i++) {
cin >> x[i];
}
dp[0] = 0;
for(int i = 0; i < n; i++) {
dp[i+1] = dp[i] + min(a*(x[i+1] -x[i]), b);
}
cout << dp[n-1] << endl;
}
| a.cc:46:5: error: redefinition of 'int to_int(std::string)'
46 | int to_int(string s) {
| ^~~~~~
a.cc:13:5: note: 'int to_int(std::string)' previously defined here
13 | int to_int(string s) {
| ^~~~~~
a.cc:50:5: error: redefinition of 'int x [10001]'
50 | int x[10001];
| ^
a.cc:17:5: note: 'int x [10001]' previously declared here
17 | int x[10001];
| ^
a.cc:51:4: error: redefinition of 'long long int dp [10001]'
51 | ll dp[10001];
| ^~
a.cc:18:4: note: 'long long int dp [10001]' previously declared here
18 | ll dp[10001];
| ^~
a.cc:53:5: error: redefinition of 'int main()'
53 | int main() {
| ^~~~
a.cc:20:5: note: 'int main()' previously defined here
20 | int main() {
| ^~~~
|
s684715461 | p03831 | C++ | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define debug(x) cerr << fixed << #x << " is " << x << endl;
const int MAX = 100005;
ll town[MAX];
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
int n, a, b;
cin >> n >> a >> b;
for(int i = 0; i < n; i++)
cin >> town[i];
ll ans = 0;
for(int i = 1; i < n; i++)
ans += min((town[i]-town[i-1])*a, b);
cout << ans << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:22:27: error: no matching function for call to 'min(long long int, int&)'
22 | ans += min((town[i]-town[i-1])*a, b);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:22:27: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
22 | ans += min((town[i]-town[i-1])*a, b);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:22:27: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
22 | ans += min((town[i]-town[i-1])*a, b);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
|
s119558293 | p03831 | C++ | #include<bits/stdc++.h>
using namespace std;
int main(){
long long l a,b,n;
cin>>n>>a>>b;
long long ans=0;
long long now;cin>>now;
for(int i=1;i<n;i++){
long long va;cin>>va;
ans+=min(a*(va-now),b);
now=va;
}
cout<<ans<<endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:4:15: error: expected initializer before 'a'
4 | long long l a,b,n;
| ^
a.cc:5:8: error: 'n' was not declared in this scope; did you mean 'yn'?
5 | cin>>n>>a>>b;
| ^
| yn
a.cc:5:11: error: 'a' was not declared in this scope
5 | cin>>n>>a>>b;
| ^
a.cc:5:14: error: 'b' was not declared in this scope
5 | cin>>n>>a>>b;
| ^
|
s628139164 | p03831 | C++ | #iuclude<bits/stdc++.h>
using namespace std;
int main(){
int a,b,n;
cin>>n>>a>>b;
long long ans=0;
int now;cin>>now;
for(int i=1;i<n;i++){
int va;cin>>va;
ans+=min(a*(va-now),b);
now=va;
}
cout<<ans<<endl;
return 0;
} | a.cc:1:2: error: invalid preprocessing directive #iuclude; did you mean #include?
1 | #iuclude<bits/stdc++.h>
| ^~~~~~~
| include
a.cc: In function 'int main()':
a.cc:5:3: error: 'cin' was not declared in this scope
5 | cin>>n>>a>>b;
| ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
+++ |+#include <iostream>
1 | #iuclude<bits/stdc++.h>
a.cc:10:10: error: 'min' was not declared in this scope; did you mean 'main'?
10 | ans+=min(a*(va-now),b);
| ^~~
| main
a.cc:13:3: error: 'cout' was not declared in this scope
13 | cout<<ans<<endl;
| ^~~~
a.cc:13:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:13:14: error: 'endl' was not declared in this scope
13 | cout<<ans<<endl;
| ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
+++ |+#include <ostream>
1 | #iuclude<bits/stdc++.h>
|
s397001809 | p03831 | C++ | #include<map>
#include<ctime>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
long long n,a,b;
long long now,next,ans;
int main()
{
scanf("%lld%lld%lld",&n,&a,&b);
scanf("%lld",&now);
for(int i=2;i<=n;i++)
{
scanf("%lld",&next);
ans+=min(a*(next-now),b);
now=next;
}
printf("%lld\n",ans);
} | a.cc: In function 'int main()':
a.cc:18:31: error: reference to 'next' is ambiguous
18 | scanf("%lld",&next);
| ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
from /usr/include/c++/14/bits/stl_tree.h:63,
from /usr/include/c++/14/map:62,
from a.cc:1:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:10:15: note: 'long long int next'
10 | long long now,next,ans;
| ^~~~
a.cc:19:29: error: reference to 'next' is ambiguous
19 | ans+=min(a*(next-now),b);
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:10:15: note: 'long long int next'
10 | long long now,next,ans;
| ^~~~
a.cc:20:13: error: reference to 'next' is ambiguous
20 | now=next;
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:10:15: note: 'long long int next'
10 | long long now,next,ans;
| ^~~~
|
s523751318 | p03831 | C++ | #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <utility>
#include <bitset>
#include <queue>
#include <numeric>
using namespace std;
typedef long long ll;
ll N, A, B;
vector<ll> X;
vector<ll> D;
int main(void) {
cin >> N >> A >> B;
X = vector<ll>(N);
for (ll i = 0; i < N; i++) {
cin >> X[i];
}
if (A >= B) {
cout << B * (N - 1) << endl;
return 0;
}
D = vector<ll>(N);
D[0] = 0;
for (ll i = 1; i < N; i++) {
D[i] = min((X[i] - X[i - 1]) * A, B);
}
ll ans = 0;
for (auto d : D) {
ans += d;
}
cout << d << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:43:13: error: 'd' was not declared in this scope
43 | cout << d << endl;
| ^
|
s437232054 | p03831 | C++ | #include<iostream>
using namespace std;
#define REP(i, n) for(int i=0; i<n; i++)
#define ll long long
ll n, a, b;
ll x[100000];
ll f;
int main(){
cin >> n >> a >> b;
REP(i, n){
cin >> x[i];
}
REP(i, n-1){
f += min(a*(x[i+1]-x[i]), b);
}
cout << f << endl;
} | a.cc:2:1: error: extended character is not valid in an identifier
2 |
| ^
a.cc:4:1: error: extended character is not valid in an identifier
4 |
| ^
a.cc:7:1: error: extended character is not valid in an identifier
7 |
| ^
a.cc:11:1: error: extended character is not valid in an identifier
11 |
| ^
a.cc:17:1: error: extended character is not valid in an identifier
17 |
| ^
a.cc:2:1: error: '\U000000a0' does not name a type
2 |
| ^
a.cc:4:1: error: '\U000000a0' does not name a type
4 |
| ^
a.cc:11:1: error: '\U000000a0' does not name a type
11 |
| ^
|
s587619625 | p03831 | C++ | #include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<functional>
using namespace std;
const long long int mod = 1000000007;
const long long int big = 1152921504606846976;
int main(void) {
long long int N, i,A,B,zen,now,ans=0;
long long int X[100010];
scanf("%lld %lld %lld", &N,&A,&B);
scanf("%lld", &zen);
for (i = 1; i < N; i++) {
scanf("%lld", &now);
X[i] = now - zen;
zen = now;
}
for (i = 1; i < N ; i++) {
if (B < A*X[i]) { ans += B; }
else { ans += A*X[i]; }
}
printf("%lld", ans);
return 0;
} | a.cc:10:1: error: extended character is not valid in an identifier
10 |
| ^
a.cc:11:1: error: extended character is not valid in an identifier
11 |
| ^
a.cc:12:1: error: extended character is not valid in an identifier
12 |
| ^
a.cc:10:1: error: '\U000000a0' does not name a type
10 |
| ^
|
s674926393 | p03831 | C++ | #include<cstdio>
#include<vector>
#include<iostream>
#include<cstdio>
using namespace std;
const int big=(1<<30);
#define llint int
int gcd(int a,int b){if(a<b){swap(a,b);}if(b==0){return a;}return gcd(a%b,b);}
int main(void){
llint N,a,b,ans=0,bef,no;
scanf("%d %d %d",&N,&a,&b);
scanf("%d",&bef);
for(i=1;i<N;i++){
scanf("%d",&no);
ans+=min(a*no-bef,b);
bef=no;
}
printf("%d\n",ans);
return 0;
} | a.cc: In function 'int main()':
a.cc:13:13: error: 'i' was not declared in this scope
13 | for(i=1;i<N;i++){
| ^
|
s794793655 | p03831 | C++ | #include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
const int INF = 1e9;
const ld EPS = 1e-8;
int main(){
int N, A, B;
cin >> N >> A >> B;
vector<ll> X(N);
REP(i,N) cin >> X[i];
ll res = 0LL;
REP(i,N - 1) {
res += min((X[i + 1] - X[i]) * A, B);
}
cout << res << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:21:15: error: no matching function for call to 'min(__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type, int&)'
21 | res += min((X[i + 1] - X[i]) * A, B);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:21:15: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
21 | res += min((X[i + 1] - X[i]) * A, B);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:21:15: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
21 | res += min((X[i + 1] - X[i]) * A, B);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
|
s044428155 | p03831 | C++ | #include <bits/stdc++.h>
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
const int MAX_N = 100000;
int x[MAX_N];
int main()
{
int n,b;
ll a;
ll res=0;
cin >> n >> a >> b;
rep(i,n){
cin >> x[i];
}
rep(i,n-1){
res += min(a*(x[i+1]-x[i]),b);
}
cout << res;
}
| a.cc: In function 'int main()':
a.cc:25:27: error: no matching function for call to 'min(long long int, int&)'
25 | res += min(a*(x[i+1]-x[i]),b);
| ~~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:25:27: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
25 | res += min(a*(x[i+1]-x[i]),b);
| ~~~^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:25:27: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
25 | res += min(a*(x[i+1]-x[i]),b);
| ~~~^~~~~~~~~~~~~~~~~~~
|
s982562980 | p03831 | C++ | #include <bits/stdc++.h>
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
const int MAX_N = 100000;
int x[MAX_N];
int main()
{
int n,a,b;
ll res=0;
cin >> n >> a >> b;
rep(i,n){
cin >> x[i];
}
rep(i,n-1){
res += min((ll)a*(x[i+1]-x[i]),b);
}
cout << res;
}
| a.cc: In function 'int main()':
a.cc:24:27: error: no matching function for call to 'min(long long int, int&)'
24 | res += min((ll)a*(x[i+1]-x[i]),b);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:24:27: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
24 | res += min((ll)a*(x[i+1]-x[i]),b);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:24:27: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
24 | res += min((ll)a*(x[i+1]-x[i]),b);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~
|
s522987111 | p03831 | C++ | #include <iostream>
#include <algorithm>
using namespace std;
const int MAX_N = 100000;
int main() {
int N, A, B, X[MAX_N]
long long ans = 0;
int dist[MAX_N] = {0};
cin >> N >> A >> B >> X[0];
for (int i=1; i<N; i++) {
cin >> X[i];
dist[i] = (X[i] - X[i-1]) * A;
ans += min(dist[i], B);
}
cout << ans << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:9:3: error: expected initializer before 'long'
9 | long long ans = 0;
| ^~~~
a.cc:11:25: error: 'X' was not declared in this scope
11 | cin >> N >> A >> B >> X[0];
| ^
a.cc:15:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
15 | ans += min(dist[i], B);
| ^~~
| abs
a.cc:17:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
17 | cout << ans << endl;
| ^~~
| abs
|
s942697142 | p03831 | C++ | #include <bits/stdc++.h>
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define REP(i, n) FOR(i,0,n)
using namespace std;
typedef long long ll;
const int INF = 1e9;
int N,A,B;
int x[100001];
int gap[100000];
void solve(){
ll res = 0;
REP(i,N-1){
// res += (A*gap[i]<B) ? A*gap[i] : B;
// cout << gap[i] <<"\n";
ll tmp = A*gap[i];
res += min(tmp , B);
}
cout << res << "\n";
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cin >> N >> A >> B;
REP(i,N){
cin >> x[i];
if(i!=0) gap[i-1] = x[i] - x[i-1];
}
solve();
return 0;
} | a.cc: In function 'void solve()':
a.cc:19:19: error: no matching function for call to 'min(ll&, int&)'
19 | res += min(tmp , B);
| ~~~^~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:19:19: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
19 | res += min(tmp , B);
| ~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:19:19: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
19 | res += min(tmp , B);
| ~~~^~~~~~~~~
|
s995822852 | p03831 | Java | import java.util.*;
public class Main {
public static void main(String[] args) {
// test();
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int A = sc.nextInt();
int B = sc.nextInt();
long[] cities = new long[N];
for (int i = 0; i < N; i++) {
cities[i] = sc.nextLong();
}
System.out.println(calc(N, A, B, cities));
}
private static long calc(int n, int a, int b, long[] cities) {
long cost = 0;
// System.out.println(Arrays.toString(cities));
for (int i = 0; i < n-1; i++) {
cost += Math.min((cities[i+1] - cities[i])*a, b);
// System.out.println("Move distance: " + (cities[i+1] - cities[i]) + "cost sum: " + cost);
}
return cost;
}
private static void test() {
assert calc(4, 2, 5, new int[] {1,2,5,7}) == 11;
assert calc(7,1, 100, new int[] {40,43,45,105,108,115,124}) == 84;
assert calc(7,1,2, new int[] {24,35,40,68,72,99,103}) == 12;
}
}
| Main.java:32: error: incompatible types: int[] cannot be converted to long[]
assert calc(4, 2, 5, new int[] {1,2,5,7}) == 11;
^
Main.java:33: error: incompatible types: int[] cannot be converted to long[]
assert calc(7,1, 100, new int[] {40,43,45,105,108,115,124}) == 84;
^
Main.java:34: error: incompatible types: int[] cannot be converted to long[]
assert calc(7,1,2, new int[] {24,35,40,68,72,99,103}) == 12;
^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
3 errors
|
s191625771 | p03831 | C++ | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)
#define vint(v, n) vector<int> v(n); REP(i,n) cin >> v[i];
#define vvint(v, w, n) vector<int> v(n); vector<int> w(n); REP(i,n) cin >> v[i] >> w[i];
#define vlint(v, n) vector<ll int> v(n); REP(i,n) cin >> v[i];
#define vdouble(v, n) vector<double> v(n); REP(i,n) cin >> v[i];
#define vvdoube(v, n1, n2) vector<vector<double> > v(n1, vector<double>(n2, 0)); REP(i,n1) REP(j,n1) cin >> v[i][j];
#define string(x) string x; cin >> x;
#define vstring(v, n) vector<string> v(n); REP(i,n){string a; std::cin >> a; v.push_back(a); }
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).begin(), (v).end(), std::greater<int>()
#define len(v) (v).length()
#define FIND(s, n) (s.find(n) != s.end())
#define SORT(a) sort(all(a))
static const string abet("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
static const long long MOD = 1000000007;
static const double PI=3.1415926535897932;
static const int INF = 0x3f3f3f3f;
static const int INFTY = (1 << 29);
static const long long LINFTY = (1LL << 32);
static const int dy4[]={0, 0, 1, -1};
static const int dx4[]={1, -1, 0, 0};
static const int dx8[] = {1, 1, 1, 0, 0, -1, -1, -1};
static const int dy8[] = {-1, 0, 1, -1, 1, -1, 0, 1};
int N, M, res;
int G[100][100];
int c[100], m[100];
int dfs(int b, int n) {
c[n] = 1;
for (int i = 0; i < N; i++) {
if (b == i || n == i) continue;
if (G[n][i]) {
if (c[i] == 1) return 0;
if (!dfs(n, i)) return 0;
}
}
return 1;
}
int isPrime(int x){
int i;
if(x < 2) return 0;
else if(x == 2) return 1;
if( x%2 == 0) return 0;
for(i = 3; i*i <= x; i += 2){
if(x%i == 0) return 0;
}
return 1;
}
const int pmax = 1000000;
bool isPrime_table[pmax];
//const is necessary;
void eratos(void){
int i, j;
double sqrtmax=sqrt(pmax);
REP(k, pmax) isPrime_table[k] = true; /* Initialization */
/* Sieve process */
isPrime_table[0] = false;
isPrime_table[1] = false;
/* 0 and 1 are not prime. */
for (i=2; i <= sqrtmax; i++){
if (isPrime_table[i]==true){ /* i is prime. */
for (j=i; i*j<pmax; j++){
isPrime_table[i*j] = false; /* multiples of i are not prime. */
}
}
}
}
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
long long int N, A, B;
cin >> N >> A >> B;
vlint(X, N);
long long tot = 0;
REP(i, N-1) tot += min((X[i+1]-X[i])*A, B);
cout << tot << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:18:28: error: two or more data types in declaration of 'type name'
18 | #define vlint(v, n) vector<ll int> v(n); REP(i,n) cin >> v[i];
| ^~
a.cc:98:9: note: in expansion of macro 'vlint'
98 | vlint(X, N);
| ^~~~~
a.cc:18:34: error: template argument 1 is invalid
18 | #define vlint(v, n) vector<ll int> v(n); REP(i,n) cin >> v[i];
| ^
a.cc:98:9: note: in expansion of macro 'vlint'
98 | vlint(X, N);
| ^~~~~
a.cc:18:34: error: template argument 2 is invalid
18 | #define vlint(v, n) vector<ll int> v(n); REP(i,n) cin >> v[i];
| ^
a.cc:98:9: note: in expansion of macro 'vlint'
98 | vlint(X, N);
| ^~~~~
a.cc:18:59: error: invalid types 'int[int]' for array subscript
18 | #define vlint(v, n) vector<ll int> v(n); REP(i,n) cin >> v[i];
| ^
a.cc:98:9: note: in expansion of macro 'vlint'
98 | vlint(X, N);
| ^~~~~
a.cc:101:34: error: invalid types 'int[int]' for array subscript
101 | REP(i, N-1) tot += min((X[i+1]-X[i])*A, B);
| ^
a.cc:101:41: error: invalid types 'int[int]' for array subscript
101 | REP(i, N-1) tot += min((X[i+1]-X[i])*A, B);
| ^
|
s599185641 | p03831 | C++ | include <iostream>
#include <math.h>
using namespace std;
long long N, A, B;
long long * X;
long long res = 0;
int main()
{
cin >> N >> A >> B;
X = new long long [N];
for (int i = 0; i < N; i++)
cin >> X[i];
for (int i = 0; i < N - 1; i++)
{
int a = A * (X[i + 1] - X[i]);
res += (a >= B) ? B : a;
}
cout << res << endl;
return 0;
} | a.cc:1:1: error: 'include' does not name a type
1 | include <iostream>
| ^~~~~~~
In file included from /usr/include/c++/14/cmath:45,
from /usr/include/c++/14/math.h:36,
from a.cc:2:
/usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity
164 | __is_null_pointer(std::nullptr_t)
| ^
/usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)'
159 | __is_null_pointer(_Type)
| ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std'
164 | __is_null_pointer(std::nullptr_t)
| ^~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/bits/specfun.h:43,
from /usr/include/c++/14/cmath:3906:
/usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std'
666 | struct is_null_pointer<std::nullptr_t>
| ^~~~~~~~~
/usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid
666 | struct is_null_pointer<std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid
670 | struct is_null_pointer<const std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid
674 | struct is_null_pointer<volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid
678 | struct is_null_pointer<const volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^~~~~~
In file included from /usr/include/stdlib.h:32,
from /usr/include/c++/14/bits/std_abs.h:38,
from /usr/include/c++/14/cmath:49:
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^
/usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1438 | : public integral_constant<std::size_t, 0> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid
1438 | : public integral_constant<std::size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared
1440 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope
1441 | struct rank<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid
1441 | struct rank<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:2086:26: error: 'std::size_t' has not been declared
2086 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:2087:30: error: '_Size' was not declared in this scope
2087 | struct remove_extent<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:2087:36: error: template argument 1 is invalid
2087 | struct remove_extent<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:2099:26: error: 'std::size_t' has not been declared
2099 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:2100:35: error: '_Size' was not declared in this scope
2100 | struct remove_all_extents<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:2100:41: error: template argument 1 is invalid
2100 | struct remove_all_extents<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:2171:12: error: 'std::size_t' has not been declared
2171 | template<std::size_t _Len>
| ^~~
/usr/include/c++/14/type_traits:2176:30: error: '_Len' was not declared in this scope
2176 | unsigned char __data[_Len];
| ^~~~
/usr/include/c++/14/type_traits:2194:12: error: 'std::size_t' has not been declared
2194 | template<std::size_t _Len, std::size_t _Align =
| ^~~
/usr/include/c++/14/type_traits:2194:30: error: 'std::size_t' has not been declared
2194 | template<std::size_t _Len, std::size_t _Align =
| ^~~
/usr/include/c++/14/type_traits:2195:55: error: '_Len' was not declared in this scope
2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)>
| ^~~~
/usr/include/c++/14/type_traits:2195:59: error: template argument 1 is invalid
2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)>
| ^
/usr/include/c++/14/type_traits:2202:30: error: '_Len' was not declared in this scope
2202 | unsigned char __data[_Len];
| ^~~~
/usr/include/c++/14/type_traits:2203:44: error: '_Align' was not declared in this scope
2203 | struct __attribute__((__aligned__((_Align)))) { } __align;
| ^~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:65:
/usr/include/c++/14/bits/stl_iterator_base_types.h:125:67: error: 'ptrdiff_t' does not name a type
125 | template<typename _Category, typename _Tp, typename _Distance = ptrdiff_t,
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:1:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
+++ |+#include <cstddef>
1 | // Types used in iterator implementation -*- C++ -*-
/usr/include/c++/14/bits/stl_iterator_base_types.h:214:15: error: 'ptrdiff_t' does not name a type
214 | typedef ptrdiff_t difference_type;
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:214:15: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/c++/14/bits/stl_iterator_base_types.h:225:15: error: 'ptrdiff_t' does not name a type
225 | typedef ptrdiff_t difference_type;
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:225:15: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
In file included from /usr/include/c++/14/bits/stl_algobase.h:66:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:112:5: error: 'ptrdiff_t' does not name a type
112 | ptrdiff_t
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:66:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
65 | #include <debug/assertions.h>
+++ |+#include <cstddef>
66 | #include <bits/stl_iterator_base_types.h>
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:118:5: error: 'ptrdiff_t' does not name a type
118 | ptrdiff_t
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:118:5: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
In file included from /usr/include/c++/14/bits/stl_iterator.h:67,
from /usr/include/c |
s979030764 | p03831 | C++ |
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
int N;
int dp[100001][100001];
int mincost[100001];
bool used[100001];
long long prime() {
rep(i,N) {
mincost[i]=1e9+7;
used[i]=false;
}
mincost[0]=0;
long long res=0;
while (true) {
int v=-1;
for (int u=0;u<N;++u) {
if (!used[u] && (v==-1 || mincost[u] < mincost[v])) v=u;
}
if (v==-1) break;
used[v]=true;
res += mincost[v];
for (int u=0;u<N;++u) {
mincost[u] = min(mincost[u], dp[v][u]);
}
}
return res;
}
int main() {
int A,B; cin>>N>>A>>B;
vector<int> X(N);
rep(i,N) cin>>X[i];
rep(i,N) dp[i][i]=0;
for (int i=0;i<N;++i) {
for (int j=0;j<N;++j) {
if (i==j) continue;
dp[i][j]=dp[j][i]=min(abs(X[i]-X[j])*A, B);
}
}
cout << prime() << endl;
return 0;
}
| /tmp/ccdLVTkp.o: in function `prime()':
a.cc:(.text+0x21): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/ccdLVTkp.o
a.cc:(.text+0x34): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccdLVTkp.o
a.cc:(.text+0x4d): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/ccdLVTkp.o
a.cc:(.text+0x75): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccdLVTkp.o
a.cc:(.text+0x9a): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/ccdLVTkp.o
a.cc:(.text+0xb1): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/ccdLVTkp.o
a.cc:(.text+0xe3): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccdLVTkp.o
a.cc:(.text+0xfb): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/ccdLVTkp.o
a.cc:(.text+0x148): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/ccdLVTkp.o
a.cc:(.text+0x16d): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/ccdLVTkp.o
collect2: error: ld returned 1 exit status
|
s686156083 | p03831 | C++ |
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
int N;
long long dp[100001][100001];
long long mincost[100001];
bool used[100001];
long long prime() {
rep(i,N) {
mincost[i]=1e9+7;
used[i]=false;
}
mincost[0]=0;
long long res=0;
while (true) {
int v=-1;
for (int u=0;u<N;++u) {
if (!used[u] && (v==-1 || mincost[u] < mincost[v])) v=u;
}
if (v==-1) break;
used[v]=true;
res += mincost[v];
for (int u=0;u<N;++u) {
mincost[u] = min(mincost[u], dp[v][u]);
}
}
return res;
}
int main() {
int A,B; cin>>N>>A>>B;
vector<int> X(N);
rep(i,N) cin>>X[i];
rep(i,N) dp[i][i]=0;
for (int i=0;i<N;++i) {
for (int j=0;j<N;++j) {
if (i==j) continue;
dp[i][j]=dp[j][i]=min(abs(X[i]-X[j])*A, B);
}
}
cout << prime() << endl;
return 0;
}
| /tmp/cc02JcUB.o: in function `prime()':
a.cc:(.text+0x21): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/cc02JcUB.o
a.cc:(.text+0x35): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/cc02JcUB.o
a.cc:(.text+0x4f): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/cc02JcUB.o
a.cc:(.text+0x77): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/cc02JcUB.o
a.cc:(.text+0x9c): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/cc02JcUB.o
a.cc:(.text+0xb4): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/cc02JcUB.o
a.cc:(.text+0xe8): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/cc02JcUB.o
a.cc:(.text+0x100): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/cc02JcUB.o
a.cc:(.text+0x14c): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/cc02JcUB.o
a.cc:(.text+0x172): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/cc02JcUB.o
collect2: error: ld returned 1 exit status
|
s291162166 | p03831 | C++ |
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
int N;
long long dp[100001][100001];
long long mincost[100001];
bool used[100001];
long long prime() {
rep(i,N) {
mincost[i]=1e9+7;
used[i]=false;
}
mincost[0]=0;
int res=0;
while (true) {
int v=-1;
for (int u=0;u<N;++u) {
if (!used[u] && (v==-1 || mincost[u] < mincost[v])) v=u;
}
if (v==-1) break;
used[v]=true;
res += mincost[v];
for (int u=0;u<N;++u) {
mincost[u] = min(mincost[u], dp[v][u]);
}
}
return res;
}
int main() {
int A,B; cin>>N>>A>>B;
vector<int> X(N);
rep(i,N) cin>>X[i];
rep(i,N) dp[i][i]=0;
for (int i=0;i<N;++i) {
for (int j=0;j<N;++j) {
if (i==j) continue;
dp[i][j]=dp[j][i]=min(abs(X[i]-X[j])*A, B);
}
}
cout << prime() << endl;
return 0;
}
| /tmp/cc3mxhTi.o: in function `prime()':
a.cc:(.text+0x21): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/cc3mxhTi.o
a.cc:(.text+0x35): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/cc3mxhTi.o
a.cc:(.text+0x4f): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/cc3mxhTi.o
a.cc:(.text+0x76): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/cc3mxhTi.o
a.cc:(.text+0x9b): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/cc3mxhTi.o
a.cc:(.text+0xb3): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/cc3mxhTi.o
a.cc:(.text+0xe7): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/cc3mxhTi.o
a.cc:(.text+0xff): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/cc3mxhTi.o
a.cc:(.text+0x151): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/cc3mxhTi.o
a.cc:(.text+0x177): relocation truncated to fit: R_X86_64_PC32 against symbol `mincost' defined in .bss section in /tmp/cc3mxhTi.o
collect2: error: ld returned 1 exit status
|
s978791113 | p03831 | Java | import java.util.Scanner;
public class DMain {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int a = sc.nextInt();
int b = sc.nextInt();
int[] x = new int[n];
int[] d = new int[n];
for(int i=0; i<n; i++){
x[i] = sc.nextInt();
if(i==0){
d[i] = 0;
}else{
d[i] = x[i] - x[i-1];
}
}
sc.close();
long ans = 0;
for(int i=1; i<n; i++){
if(d[i] * a > b){
ans += b;
}else{
ans += a * d[i];
}
}
System.out.println(ans);
}
}
| Main.java:2: error: class DMain is public, should be declared in a file named DMain.java
public class DMain {
^
1 error
|
s533194861 | p03831 | Java | public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int a = sc.nextInt();
int b = sc.nextInt();
int[] x = new int[n];
int[] d = new int[n];
for(int i=0; i<n; i++){
x[i] = sc.nextInt();
if(i==0){
d[i] = 0;
}else{
d[i] = x[i] - x[i-1];
}
}
sc.close();
long ans = 0;
for(int i=1; i<n; i++){
if(d[i] * a > b){
ans += b;
}else{
ans += a * d[i];
}
}
System.out.println(ans);
}
}
| Main.java:4: error: cannot find symbol
Scanner sc = new Scanner(System.in);
^
symbol: class Scanner
location: class Main
Main.java:4: error: cannot find symbol
Scanner sc = new Scanner(System.in);
^
symbol: class Scanner
location: class Main
2 errors
|
s175707565 | p03832 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;
template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;
vector<ll> fac, inv_fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; inv_fac.resize(x); rep(i,x) inv_fac[i] = inv(fac[i]); }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }
ll pnk(ll n, ll k) {
ll result = 1, pn = n, now = 0;
while(k>=1<<now) {
if (k&1<<now) result = result * pn % MOD;
pn = pn * pn % MOD;
now++;
}
return result;
}
int main() {
ll N, A, B, C, D; cin >> N >> A >> B >> C >> D;
ll dp[B+1][N+1] = {}; dp[A-1][N] = 1;
c_fac();
repr(i,A,B+1) rep(j,N+1) {
dp[i][j] = (dp[i][j] + dp[i-1][j]) % MOD;
ll con;
for (ll k=C; j>=i*k&&k<=D; k++) {
if (k==C) con = fac[j] * inv(pnk(fac[i],k)) % MOD * inv_fac[j-i*k] % MOD * inv_fac[k] % MOD;
else con = con * nck(j-i*(k-1),i) % MOD * inv(k) % MOD;
dp[i][j-i*k] = (dp[i][j-i*k] + dp[i-1][j]*con) % MOD;
}
}
// rep(i,B+1) debug(dp[i],dp[i]+(N+1));
ll result = dp[B][0];
cout << result << endl;
return 0;
} | a.cc: In function 'void c_fac(int)':
a.cc:19:139: error: 'inv' was not declared in this scope; did you mean 'int'?
19 | void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; inv_fac.resize(x); rep(i,x) inv_fac[i] = inv(fac[i]); }
| ^~~
| int
|
s839843107 | p03832 | C++ | #include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>
using namespace std;
typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
const ll SIZE = 1e3 + 100, INF = 1e9 + 10, MOD = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll n, a, b, c, d, dp[SIZE][2];
vector<ll> fact;
void input() {
cin >> n >> a >> b >> c >> d;
}
ll pw(ll a, ll b, ll md) { ll res = 1; while (b) { if (b & 1) { res = (a*res) % md; }a = (a*a) % md; b >>= 1; }return(res); }
void sol() {
dp[0][0] = 1;
fact.push_back(1);
for (int i = 1; i <= n + 2; i++) fact.push_back((fact.back() * i) % MOD);
ll ind = 0;
for (int cur = a; cur <= b; cur++) {
ind = !ind;
for (int i = 0; i <= n; i++) dp[i][ind] = dp[i][!ind];
for (int j = c; j <= d; j++) {
for (int i = n; i >= 0; i--) {
ll amount = cur;
if (i - amount >= 0) {
dp[i][ind] += dp[i - amount][!ind]
}
else {
break;
}
}
}
}
cout << dp[n][ind];
}
int main()
{
fastInp;
ll t = 1;
while (t--) {
input();
sol();
}
return 0;
} | a.cc: In function 'void sol()':
a.cc:45:55: error: expected ';' before '}' token
45 | dp[i][ind] += dp[i - amount][!ind]
| ^
| ;
46 | }
| ~
|
s272398796 | p03832 | C++ | #include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
long long inf=(long long)1E17;
#define i_7 (long long)(1E9+7)
//#define i_7 998'244'353
long mod(long a){
long long c=a%i_7;
if(c>=0)return c;
return c+i_7;
}
//using namespace std;
//typedef long long ll;
long long po(long a, long b){
if(b==0){
return 1;
}
long long z = po(a,b/2);
z = mod(z*z);
if(b%2!=0){
z = mod(a*z);
}
return z;
}
//配列のSIZEは問題ごとに定義する必要がある。
const int SIZE=1010;
long long inv[SIZE+1];//各iの逆元を格納する配列。
long long kai[SIZE+1];//i!のmodを格納する配列。
long long invkai[SIZE+1];//各i!の逆元を格納する配列。
const int MOD=i_7;
void invinit(){//上の配列を初期化する関数。
inv[1]=1;
for(int i=2;i<=SIZE;i++){
inv[i] = MOD - ((MOD/i)*inv[MOD%i])%MOD;
}
kai[0]=invkai[0]=1;
for(int i=1;i<=SIZE;i++){
kai[i]=(kai[i-1]*i)%MOD;
invkai[i]=(invkai[i-1]*inv[i])%MOD;
}
}
long long comb(long long a, long long b){
if(b<0 || a<b){
return 0;
}
return mod(kai[a]*mod(invkai[b]*invkai[a-b]));
}
int main(){
invinit();
using namespace std;
long long n, a, b, c, d;
cin>>n>>a>>b>>c>>d;
long long f[n+1][n+1] = {};//k人のグループをx個作る
long long dp[n+1][n+1] = {};//y人をk人以下のグループに分ける
REP(k,n+1){
REP(x,n+1){
if(k == 0){
if(x == 0){
f[k][x] = 1;
}
continue;
}
if(n - k*x < 0)continue;
long long temp = 1;
for(int i = 0; i<x; i++){
temp *= comb(n-i*k, k);
temp = mod(temp);
}
}
}
REP(y,n+1){
REP(k,n+1){
if(k < a || b < k)continue;
if((0 < x && x < c) || d < k)continue;
if(y == 0){
dp[y][k] = 1;
continue;
}
long long x = y/k;
for(long long i = 0; i<=x; i++){
dp[y][k] += mod(f[k][i]*dp[y-k*i][k-1]);
dp[y][k] = mod(dp[y][k]);
}
}
}
long long ans = dp[n][n];
cout<<ans<<endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:80:15: error: 'x' was not declared in this scope
80 | if((0 < x && x < c) || d < k)continue;
| ^
|
s083600979 | p03832 | C++ | #include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
long long inf=(long long)1E17;
#define i_7 (long long)(1E9+7)
//#define i_7 998'244'353
long mod(long a){
long long c=a%i_7;
if(c>=0)return c;
return c+i_7;
}
//using namespace std;
//typedef long long ll;
long long po(long a, long b){
if(b==0){
return 1;
}
long long z = po(a,b/2);
z = mod(z*z);
if(b%2!=0){
z = mod(a*z);
}
return z;
}
//配列のSIZEは問題ごとに定義する必要がある。
const int SIZE=1010;
long long inv[SIZE+1];//各iの逆元を格納する配列。
long long kai[SIZE+1];//i!のmodを格納する配列。
long long invkai[SIZE+1];//各i!の逆元を格納する配列。
const int MOD=i_7;
void invinit(){//上の配列を初期化する関数。
inv[1]=1;
for(int i=2;i<=SIZE;i++){
inv[i] = MOD - ((MOD/i)*inv[MOD%i])%MOD;
}
kai[0]=invkai[0]=1;
for(int i=1;i<=SIZE;i++){
kai[i]=(kai[i-1]*i)%MOD;
invkai[i]=(invkai[i-1]*inv[i])%MOD;
}
}
long long comb(long long a, long long b){
if(b<0 || a<b){
return 0;
}
return mod(kai[a]*mod(invkai[b]*invkai[a-b]));
}
int main(){
invinit();
long long n, a, b, c, d;
cin>>n>>a>>b>>c>>d;
long long f[n+1][n+1] = {};//k人のグループをx個作る
long long dp[n+1][n+1] = {};//y人をk人以下のグループに分ける
REP(k,n+1){
REP(x,n+1){
if(k == 0){
if(x == 0){
f[k][x] = 1;
}
continue;
}
if(n - k*x < 0)continue;
long long temp = 1;
for(int i = 0; i<x; i++){
temp *= comb(n-i*k, k);
temp = mod(temp);
}
}
}
REP(y,n+1){
REP(k,n+1){
if(k < a || b < k)continue;
if((0 < x && x < c) || d < k)continue;
if(y == 0){
dp[y][k] = 1;
continue;
}
long long x = y/k;
for(long long i = 0; i<=x; i++){
dp[y][k] += mod(f[k][i]*dp[y-k*i][k-1]);
dp[y][k] = mod(dp[y][k]);
}
}
}
long long ans = dp[n][n];
cout<<ans<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:57:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
57 | cin>>n>>a>>b>>c>>d;
| ^~~
| std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
62 | extern istream cin; ///< Linked to standard input
| ^~~
a.cc:79:15: error: 'x' was not declared in this scope
79 | if((0 < x && x < c) || d < k)continue;
| ^
a.cc:92:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
92 | cout<<ans<<endl;
| ^~~~
| std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
63 | extern ostream cout; ///< Linked to standard output
| ^~~~
a.cc:92:14: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
92 | cout<<ans<<endl;
| ^~~~
| std::endl
In file included from /usr/include/c++/14/istream:41,
from /usr/include/c++/14/sstream:40,
from /usr/include/c++/14/complex:45,
from /usr/include/c++/14/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
744 | endl(basic_ostream<_CharT, _Traits>& __os)
| ^~~~
|
s806716753 | p03832 | C++ | #include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x) cout << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//#define int long long
// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct Fp {
long long val;
constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
if (val < 0) v += MOD;
}
constexpr int getmod() { return MOD; }
constexpr Fp operator - () const noexcept {
return val ? MOD - val : 0;
}
constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
constexpr Fp& operator += (const Fp& r) noexcept {
val += r.val;
if (val >= MOD) val -= MOD;
return *this;
}
constexpr Fp& operator -= (const Fp& r) noexcept {
val -= r.val;
if (val < 0) val += MOD;
return *this;
}
constexpr Fp& operator *= (const Fp& r) noexcept {
val = val * r.val % MOD;
return *this;
}
constexpr Fp& operator /= (const Fp& r) noexcept {
long long a = r.val, b = MOD, u = 1, v = 0;
while (b) {
long long t = a / b;
a -= t * b; swap(a, b);
u -= t * v; swap(u, v);
}
val = val * u % MOD;
if (val < 0) val += MOD;
return *this;
}
constexpr bool operator == (const Fp& r) const noexcept {
return this->val == r.val;
}
constexpr bool operator != (const Fp& r) const noexcept {
return this->val != r.val;
}
friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
return os << x.val;
}
friend constexpr istream& operator >> (istream &is, Fp<MOD>& x) noexcept {
return is >> x.val;
}
friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
if (n == 0) return 1;
auto t = modpow(a, n / 2);
t = t * t;
if (n & 1) t = t * a;
return t;
}
};
// 二項係数ライブラリ
template<class T> struct BiCoef {
vector<T> fact_, inv_, finv_;
constexpr BiCoef() {}
constexpr BiCoef(int n) noexcept : fact_(n, 1), inv_(n, 1), finv_(n, 1) {
init(n);
}
constexpr void init(int n) noexcept {
fact_.assign(n, 1), inv_.assign(n, 1), finv_.assign(n, 1);
int MOD = fact_[0].getmod();
for(int i = 2; i < n; i++){
fact_[i] = fact_[i-1] * i;
inv_[i] = -inv_[MOD%i] * (MOD/i);
finv_[i] = finv_[i-1] * inv_[i];
}
}
constexpr T com(int n, int k) const noexcept {
if (n < k || n < 0 || k < 0) return 0;
return fact_[n] * finv_[k] * finv_[n-k];
}
constexpr T fact(int n) const noexcept {
if (n < 0) return 0;
return fact_[n];
}
constexpr T inv(int n) const noexcept {
if (n < 0) return 0;
return inv_[n];
}
constexpr T finv(int n) const noexcept {
if (n < 0) return 0;
return finv_[n];
}
};
const int MOD = 1000000007;
using mint = Fp<MOD>;
BiCoef<mint> bc;
void solve() {
int n, a, b, c, d;
cin >> n >> a >> b >> c >> d;
bc.init(1010);
mint dp[1010][1010];
rep(i, 1010) rep(j, 1010) dp[i][j] = 0;
dp[0][0] = 1;
for(int k = 1; a * k <= n; ++k) {
dp[a * k][0] = bc.fact_[a * k] / (modpow(bc.fact_[a], k) * bc.fact_[k]);
}
rep(i, n + 1) {
rep(j, b - a) {
for(int k = 1; i - k * (a + j + 1) >= 0; ++k) {
mint num = bc.fact_[k * (a + j + 1)] / (modpow(a + j + 1, k) * bc.fact_[k]);
dp[i][j + 1] += dp[i - k * (a + j + 1)][j] * num;
}
}
}
cout << dp[n][b - a] << endl;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
//cout << fixed << setprecision(10);
//init();
solve();
//cout << "finish" << endl;
return 0;
} | a.cc: In function 'void solve()':
a.cc:163:57: error: 'modpow' was not declared in this scope
163 | mint num = bc.fact_[k * (a + j + 1)] / (modpow(a + j + 1, k) * bc.fact_[k]);
| ^~~~~~
|
s929265302 | p03832 | C++ | #include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
using ll = long long;
using namespace std;
#include <mutex>
#define MOD (long)(1e9 + 7)
#define MAX 1000000 // 階乗をいくつまで計算するか
class modlong {
long val;
static const long mod = MOD;
static long *invs, *facts, *finvs;
static once_flag flag;
// 階乗, 逆元, 階乗の逆元をMAXまで求める
static void initModlong() {
invs[1] =
facts[0] = facts[1] =
finvs[0] = finvs[1] = 1;
for (int i=2; i<=MAX; i++) {
invs[i] = -invs[MOD % i] * (MOD / i) % MOD;
facts[i] = facts[i - 1] * i % MOD;
finvs[i] = finvs[i - 1] * invs[i] % MOD;
}
}
public:
// 初期化 値を引数に与えなかった場合はval=0としておく
modlong(long init = 0) : val(init) {
call_once(flag, initModlong);
if (val < 0 || val >= mod) val %= mod;
if (val < 0) val += mod; // 0以上であることを保証
}
// longへのキャスト operator long()で定義すると modlong +
// longとかができなくなる
constexpr long tol() { return this->val; }
// 代入
void operator=(const modlong &r) { this->val = r.val; }
void operator=(const long &r) { *this = modlong(r); }
//比較
bool operator<(const modlong &r) { return this->val < r.val; }
bool operator>(const modlong &r) { return this->val > r.val; }
bool operator==(const modlong &r) { return this->val == r.val; }
bool operator!=(const modlong &r) { return !(*this == r); }
bool operator<=(const modlong &r) { return !(*this > r); }
bool operator>=(const modlong &r) { return !(*this < r); }
// 足し算; 符号反転; 引き算
modlong operator+(const modlong &r) {
long ans = this->val + r.val;
if (ans >= mod) ans -= mod;
return modlong(ans);
}
modlong operator-() {
long ans = mod - this->val;
return modlong(ans);
}
modlong operator-(const modlong &r) {
modlong rr = r;
return *this + (-rr);
}
//かけ算; 逆元; わり算
modlong operator*(const modlong &r) {
long ans = this->val * r.val;
return modlong(ans);
}
modlong inv() {
assert(*this != 0);
if (*this == 1) return modlong(1);
modlong p, q = *this, m(0), n(1), r, c;
p.val = mod; // p=modとかくとp.val=mod%mod=0となってしまう
while (q > MAX) {
r = p.val %
q.val; // r.val=p.val / q.val
// とかくよりもこのほうが代入時に%modされるので安全
c = m.val - n.val * (p.val / q.val);
p = q, q = r, m = n, n = c;
}
return n * invs[q.val];
}
modlong operator/(const modlong &r) {
modlong rr = r;
return *this * rr.inv();
}
// ++ -- 前付きと後ろ付き
void operator++() { ++this->val; }
void operator++(int a) {
a = 0;
this->val++;
} // a使ってなくねっていうwarningをsilenceするためにaをいじってる
void operator--() { --this->val; }
void operator--(int a) {
a = 0;
this->val--;
}
// 四則演算&代入
void operator+=(const modlong &r) { *this = *this + r; }
void operator-=(const modlong &r) { *this = *this - r; }
void operator*=(const modlong &r) { *this = *this * r; }
void operator/=(const modlong &r) { *this = *this / r; }
// べき乗
modlong pow(long n) {
if (n < 0)
return inv().pow(-n); // 逆元の-n乗
else if (n == 0)
return modlong(1);
modlong half = pow(n / 2);
if (n % 2)
return *this * half * half;
else
return half * half;
}
modlong pow(modlong n) { return pow(n.val); }
// コンビネーション
modlong comb(modlong _k) {
assert(this->val <= MAX);
const long n = this->val, k = _k.val;
if (k < 0 || k > n) return 0;
if (k == 0 || k == n) return 1;
return modlong(facts[n]) * finvs[k] * finvs[n - k];
}
// 階乗
modlong fact() {
assert(this->val <= MAX);
return modlong(facts[this->val]);
}
friend ostream &operator<<(ostream &os, const modlong &out);
friend istream &operator>>(istream &is, modlong &out);
};
// cout、cerr、cin用の演算子たち
ostream &operator<<(ostream &os, const modlong &out) {
os << out.val;
return os;
}
istream &operator>>(istream &is, modlong &in) {
long inl;
is >> inl;
in.val = inl % MOD;
return is;
}
// static変数たち
long *modlong::invs = new long[MAX+1],
*modlong::facts = new long[MAX+1],
*modlong::finvs = new long[MAX+1];
once_flag modlong::flag;
////// 階乗を全て求める -> 二項係数を求める
// コンビネーション
inline modlong modComb(long n, long k) {
return modlong(n).comb(k);
}
// 階乗
inline modlong modFact(long n) {
return modlong(n).fact();
}
modlong dp[1002][1001] = {{0}};
int main() {
int n, a, b, c, d;
cin >> n >> a >> b >> c >> d;
dp[a][n] = 1;
for (int i=a; i<=b; i++) {
for (int j=0; j<=n; j++) {
// cerr << i << ' ' << j << ' ' << dp[i][j] << '\n';
dp[i+1][j] += dp[i][j];
for (int k=c; k<=d && i*k <= j; k++) {
dp[i+1][j-i*k] += dp[i][j] * modFact(j) / (modFact(j - i*k) * modFact(i).pow(k) * modFact(k));
}
}
}
cout << dp[b+1][0] << '\n';
return 0;
}
| a.cc: In member function 'modlong modlong::inv()':
a.cc:79:9: error: 'assert' was not declared in this scope
79 | assert(*this != 0);
| ^~~~~~
a.cc:12:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
11 | #include <mutex>
+++ |+#include <cassert>
12 |
a.cc: In member function 'modlong modlong::comb(modlong)':
a.cc:133:9: error: 'assert' was not declared in this scope
133 | assert(this->val <= MAX);
| ^~~~~~
a.cc:133:9: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
a.cc: In member function 'modlong modlong::fact()':
a.cc:142:9: error: 'assert' was not declared in this scope
142 | assert(this->val <= MAX);
| ^~~~~~
a.cc:142:9: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
|
s397430763 | p03832 | C++ | #include <bits/stdc++.h>
using namespace std;
int b[100007],a,ant=1;
int main(){
cin >> a;
long long int ans =1,num =1;
for(int i=0;i<=a;i++)b[i] = 1;
for(int j=1;j<=a;j++){
num = j;
for (int i = 2; i <= j; i++) {
while(num%i == 0) {
b[i]++;
num /= i;
}
}
}
for(int i=1;i<=a;i++){
ans *= b[i];
ans %= 1E9+7;
}
cout<<ans<<endl;
return 0 ;
}
| a.cc: In function 'int main()':
a.cc:19:17: error: invalid operands of types 'long long int' and 'double' to binary 'operator%'
19 | ans %= 1E9+7;
| ~~~~^~~~~~~~
a.cc:19:17: note: in evaluation of 'operator%=(long long int, double)'
|
s083480960 | p03832 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;
ll a[5003], b[202][5003], d[5003][5003];
int main() {
ios::sync_with_stdio(false);
int n, m;
cin >> n >> m;
for (int i = 1; i < n; i++) cin >> a[i];
for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) cin >> b[j][i];
for (int i = 1; i <= m; i++) {
int l[5003] = {}, r[5003] = {};
vector<int> s = {0};
b[i][0] = b[i][n + 1] = mod;
for (int j = 1; j <= n; j++) {
while (b[i][s.back()] <= b[i][j]) s.pop_back();
l[j] = s.back();
s.push_back(j);
}
s = {n + 1};
for (int j = n; j; j--) {
while (b[i][s.back()] < b[i][j]) s.pop_back();
r[j] = s.back();
s.push_back(j);
}
for (int j = 1; j <= n; j++) cout << l[j] << ' ' << r[j] << '\n';
for (int j = 1; j <= n; j++) d[l[j] + 1][r[j] + 1] = 1;
}
return;
}
| a.cc: In function 'int main()':
a.cc:33:5: error: return-statement with no value, in function returning 'int' [-fpermissive]
33 | return;
| ^~~~~~
|
s357042766 | p03832 | C++ | #include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
if(a<b)return b;
else return a;
}
ll lmin(ll a,ll b){
if(a<b)return a;
else return b;
}
ll gcd(ll a,ll b){
if(a<b)swap(a,b);
if(a%b==0)return b;
return gcd(b,a%b);
}
ll beki(ll n,ll k){
ll ret=1;
ll now=n;
while(k>0){
if(k%2==1){
ret*=now;
ret%=mod;
}
now*=now;
now%=mod;
k/=2;
}
return ret;
}
ll gyaku(ll n){
return beki(n,mod-2);
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
ll n;cin>>n;
ll a,b,c,d;cin>>a>>b>>c>>d;
ll dp[n+1][n+1];
rep(i,0,n+1)rep(j,0,n+1)dp[i][j]=0;
dp[a-1][0]=1;
ll nck[1001][1001];
rep(i,0,1001)nck[i][0]=1;
rep(i,0,1001)nck[i][i]=1;
gya[1001];
rep(i,1,1001)gya[i]=gyaku(i);
rep(i,1,1001){
rep(j,1,i){
nck[i][j]=nck[i-1][j-1]+nck[i-1][j];
nck[i][j]%=mod;
}
}
rep(i,a-1,b){
int t=0;
rep(j,0,n+1){
dp[i+1][j]+=dp[i][j];
dp[i+1][j]%=mod;
if(t==1)continue;
ll sum=1;
ll now=n-j;
rep(k,0,c){
if(now<0){
sum=-1;
break;
}
sum*=nck[now][i+1];
sum%=mod;
sum*=gya[k+1];
sum%=mod;
now-=i+1;
}
if(sum==-1){
t=1;
continue;
}
rep(k,c,d+1){
if(j+(i+1)*k>n)break;
dp[i+1][j+(i+1)*k]+=dp[i][j]*sum;
dp[i+1][j+(i+1)*k]%=mod;
sum*=nck[n-(j+(i+1)*k)][i+1];
sum%=mod;
sum*=gya[k+1];
sum%=mod;
}
}
}
cout<<dp[b][n]<<endl;
}
| a.cc: In function 'int main()':
a.cc:66:3: error: 'gya' was not declared in this scope
66 | gya[1001];
| ^~~
|
s017321523 | p03832 | C++ |
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility>
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl;
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)
#define INF INT_MAX/2
ll mo = 1000000007;
struct mint {
ll x;
mint(ll x = 0) :x(x%mod) {}
mint& operator+=(const mint a) {
if ((x += a.x) >= mod) x -= mod;
return *this;
}
mint& operator-=(const mint a) {
if ((x += mod - a.x) >= mod) x -= mod;
return *this;
}
mint& operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res += a;
}
mint operator-(const mint a) const {
mint res(*this);
return res -= a;
}
mint operator*(const mint a) const {
mint res(*this);
return res *= a;
}
};
mint dp[1010][1010];
ll fac[1010];
ll modpow(ll a, ll n) {
ll res = 1;
while (n > 0) {
if (n & 1) res = res * a % mo;
a = a * a % mo;
n >>= 1;
}
return res;
}
int main() {
int n, a, b, c, d;
cin >> n >> a >> b >> c >> d;
fac[0] = 1;
rep(i, 1, 1010) {
fac[i] = i * fac[i - 1];
fac[i] %= mo;
}
dp[a - 1][n] = 1;
for (int i = a; i <= b; i++) {
for (int j = 0; j <= n; j++) {
dp[i][j] += dp[i - 1][j];
for (int k = c; k <= d; k++) {
if (j + k * i > n)break;
mint tmp = 0;
mint st = fac[j + k * i];
tmp += st * dp[i - 1][j + k * i];
tmp *= modpow(fac[k], mo - 2);
tmp *= modpow(fac[j], mo - 2);
tmp *= modpow(modpow(fac[i], mo - 2), k);
dp[i][j] += tmp;
}
}
}
puts(dp[b][0].x)
return 0;
}
| a.cc: In constructor 'mint::mint(ll)':
a.cc:39:29: error: 'mod' was not declared in this scope; did you mean 'modf'?
39 | mint(ll x = 0) :x(x%mod) {}
| ^~~
| modf
a.cc: In member function 'mint& mint::operator+=(mint)':
a.cc:41:35: error: 'mod' was not declared in this scope; did you mean 'modf'?
41 | if ((x += a.x) >= mod) x -= mod;
| ^~~
| modf
a.cc: In member function 'mint& mint::operator-=(mint)':
a.cc:45:27: error: 'mod' was not declared in this scope; did you mean 'modf'?
45 | if ((x += mod - a.x) >= mod) x -= mod;
| ^~~
| modf
a.cc: In member function 'mint& mint::operator*=(mint)':
a.cc:49:31: error: 'mod' was not declared in this scope; did you mean 'modf'?
49 | (x *= a.x) %= mod;
| ^~~
| modf
|
s366799801 | p03832 | C++ | }
| a.cc:1:1: error: expected declaration before '}' token
1 | }
| ^
|
s201356263 | p03832 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
ll fc[200010];
ll ifc[200010];
ll add(ll x, ll y){return (x+y)%MOD;}
ll mlt(ll x, ll y){return (x*y)%MOD;}
ll power(ll x, ll n){
ll ans=1;
while(n>0){
if(n%2!=0)ans=mlt(ans, x);
x=mlt(x,x);n/=2;
}
return ans;
}
ll inv(ll x){return power(x, MOD-2);}
void fct(){
fc[0]=1;
for (int i=0;i<200009;++i){fc[i+1]=mlt(fc[i], i+1);}
}
void ifct(){
ifc[200009]=inv(fct[200009]);
for (i=200009;i>=1;--i){ifc[i-1]=mlt(ifc[i], i);}
}
ll comb(int n, int k){return mlt(fc[n], mlt(ifc[k], ifc[n-k]));}
int main(){
int N, A, B, C, D;cin>>N>>A>>B>>C>>D;
fct();ifct();
dp[1010][1010]={};dp[N][A-1]=1;
for (int j=A;j<=B;++j){
for (int i=N;i>=0;--i){
dp[i][j]=dp[i][j-1];
ll factor=1;
for (int k=0;k++<C-1;){
factor=mlt(factor, comb(i+j*k, j));
}
for (int k=C;k<=D;++k){
if(i+j*k>N) break;
factor=mlt(factor, comb(i+j*k,j));
dp[i][j]=add(dp[i][j], mlt(dp[i+j*k][j-1],mlt(factor, ifc[k])));
}
}
}
cout << dp[0][B] << endl;
return 0;
} | a.cc: In function 'void ifct()':
a.cc:27:29: warning: pointer to a function used in arithmetic [-Wpointer-arith]
27 | ifc[200009]=inv(fct[200009]);
| ^
a.cc:27:29: error: invalid conversion from 'void (*)()' to 'll' {aka 'long long int'} [-fpermissive]
27 | ifc[200009]=inv(fct[200009]);
| ~~~~~~~~~~^
| |
| void (*)()
a.cc:19:11: note: initializing argument 1 of 'll inv(ll)'
19 | ll inv(ll x){return power(x, MOD-2);}
| ~~~^
a.cc:28:8: error: 'i' was not declared in this scope
28 | for (i=200009;i>=1;--i){ifc[i-1]=mlt(ifc[i], i);}
| ^
a.cc: In function 'int main()':
a.cc:37:3: error: 'dp' was not declared in this scope; did you mean 'dup'?
37 | dp[1010][1010]={};dp[N][A-1]=1;
| ^~
| dup
|
s506638525 | p03832 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
//factorial&inverse factorial
ll fc[200010];
ll ifc[200010];
ll add(ll x, ll y){return (x+y)%MOD;}
ll mlt(ll x, ll y){return (x*y)%MOD;}
ll power(int x, int n){
ll ans=1;
while(n>0){
if(n%2!=0){ans=mlt(ans, x);}
x=mlt(x,x);
n/=2;
}
return ans;
}
ll inv(ll x){
return power(x, MOD-2);
}
void fct(){
fc[0]=0;
for (int i=0;i<200009;++i){
fc[i+1]=mlt(fc[i], i+1);
}
}
void ifct(){
ifc[200009]=inv(fc[200009]);
for (int i=200009;i>=1;--i){
ifc[i-1]=mlt(ifc[i], i);
}
}
ll comb(int n, int k){
if(n<0||k<0|| k>n)return 0;
return mlt(fct[n], mlt(ifc[k], ifc[n-k]));
}
int main(){
int N, A, B, C, D;cin>>N>>A>>B>>C>>D;
ll dp[1010][1010]={};
dp[N][A-1]=1;
fct();ifct();
for (int i=0;i<=N;++i){
for (int j=A;j<=B;++j){
dp[i][j]=dp[i][j-1];
ll factor=1;
for (int k=0;k++<C;){
factor=mlt(factor, comb(i+k*j, j));
}
for (int k=C;k<=D;++k){
if(i+k*j>N) break;
factor=mlt(factor, comb(i+k*j, j));
dp[i][j]=ad(dp[i][j], mlt(dp[i+k*j][j-1], comb(i+k*j, j)));
}
}
}
cout << dp[0][B]<< endl;
return 0;
}
| a.cc: In function 'll comb(int, int)':
a.cc:44:19: warning: pointer to a function used in arithmetic [-Wpointer-arith]
44 | return mlt(fct[n], mlt(ifc[k], ifc[n-k]));
| ^
a.cc:44:19: error: invalid conversion from 'void (*)()' to 'll' {aka 'long long int'} [-fpermissive]
44 | return mlt(fct[n], mlt(ifc[k], ifc[n-k]));
| ~~~~~^
| |
| void (*)()
a.cc:12:11: note: initializing argument 1 of 'll mlt(ll, ll)'
12 | ll mlt(ll x, ll y){return (x*y)%MOD;}
| ~~~^
a.cc: In function 'int main()':
a.cc:65:18: error: 'ad' was not declared in this scope; did you mean 'add'?
65 | dp[i][j]=ad(dp[i][j], mlt(dp[i+k*j][j-1], comb(i+k*j, j)));
| ^~
| add
|
s849526138 | p03832 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
//factorial&inverse factorial
ll fc[200010];
ll ifc[200010];
ll add(ll x, ll y){return (x+y)%MOD;}
ll mlt(ll x, ll y){return (x*y)%MOD;}
ll power(int x, int n){
ll ans=1;
while(n>0){
if(n%2!=0){ans=mlt(ans, x);}
x=mlt(x,x);
n/=2;
}
return ans;
}
ll inv(ll x){
return power(x, MOD-2);
}
void fct(){
fc[0]=0;
for (int i=0;i<200009;++i){
fc[i+1]=mlt(fc[i], i+1);
}
}
void ifct(){
ifc[200009]=inv(fc[200009]);
for (int i=200009;i>=1;--i){
ifc[i-1]=mlt(ifc[i], i);
}
}
ll comb(int n, int k){
if(n<0||k<0|| k>n)return 0;
return mlt(fct[n], mlt(ifct[k], ifct[n-k]));
}
int main(){
int N, A, B, C, D;cin>>N>>A>>B>>C>>D;
ll dp[1010][1010]={};
dp[N][A-1]=1;
fct();ifct();
for (int i=0;i<=N;++i){
for (int j=A;j<=B;++j){
dp[i][j]=dp[i][j-1];
ll factor=1;
for (int k=0;k++<C;){
factor=mlt(factor, comb(i+k*j, j));
}
for (int k=C;k<=D;++k){
if(i+k*j>N) break;
factor=mlt(factor, comb(i+k*j, j));
dp[i][j]=ad(dp[i][j], mlt(dp[i+k*j][j-1], comb(i+k*j, j)));
}
}
}
cout << dp[0][B]<< endl;
return 0;
}
| a.cc: In function 'll comb(int, int)':
a.cc:44:19: warning: pointer to a function used in arithmetic [-Wpointer-arith]
44 | return mlt(fct[n], mlt(ifct[k], ifct[n-k]));
| ^
a.cc:44:32: warning: pointer to a function used in arithmetic [-Wpointer-arith]
44 | return mlt(fct[n], mlt(ifct[k], ifct[n-k]));
| ^
a.cc:44:43: warning: pointer to a function used in arithmetic [-Wpointer-arith]
44 | return mlt(fct[n], mlt(ifct[k], ifct[n-k]));
| ^
a.cc:44:32: error: invalid conversion from 'void (*)()' to 'll' {aka 'long long int'} [-fpermissive]
44 | return mlt(fct[n], mlt(ifct[k], ifct[n-k]));
| ~~~~~~^
| |
| void (*)()
a.cc:12:11: note: initializing argument 1 of 'll mlt(ll, ll)'
12 | ll mlt(ll x, ll y){return (x*y)%MOD;}
| ~~~^
a.cc:44:43: error: invalid conversion from 'void (*)()' to 'll' {aka 'long long int'} [-fpermissive]
44 | return mlt(fct[n], mlt(ifct[k], ifct[n-k]));
| ~~~~~~~~^
| |
| void (*)()
a.cc:12:17: note: initializing argument 2 of 'll mlt(ll, ll)'
12 | ll mlt(ll x, ll y){return (x*y)%MOD;}
| ~~~^
a.cc:44:19: error: invalid conversion from 'void (*)()' to 'll' {aka 'long long int'} [-fpermissive]
44 | return mlt(fct[n], mlt(ifct[k], ifct[n-k]));
| ~~~~~^
| |
| void (*)()
a.cc:12:11: note: initializing argument 1 of 'll mlt(ll, ll)'
12 | ll mlt(ll x, ll y){return (x*y)%MOD;}
| ~~~^
a.cc: In function 'int main()':
a.cc:65:18: error: 'ad' was not declared in this scope; did you mean 'add'?
65 | dp[i][j]=ad(dp[i][j], mlt(dp[i+k*j][j-1], comb(i+k*j, j)));
| ^~
| add
|
s604618189 | p03832 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
//factorial&inverse factorial
ll fc[200010];
ll ifc[200010];
ll add(ll x, ll y){return (x+y)%MOD;}
ll mlt(ll x, ll y){return (x*y)%MOD;}
ll power(int x, int n){
ll ans=1;
while(n>0){
if(n%2!=0){ans=mlt(ans, x);}
x=mlt(x,x);
n/=2;
}
return ans;
}
ll inv(ll x){
return power(x, MOD-2);
}
void fct(){
fc[0]=0;
for (int i=0;i<200009){
fc[i+1]=mlt(fc[i], i+1);
}
}
void ifct(){
ifc[200009]=inv(fc[200009]);
for (int i=200009;i>=1;--i){
ifct[i-1]=mlt(ifct[i], i);
}
}
ll comb(int n, int k){
if(n<0||k<0|| k>n)return 0;
return mlt(fct[n], mlt(ifct[k], ifct[n-k]));
}
int main(){
int N, A, B, C, D;cin>>N>>A>>B>>C>>D;
ll dp[1010][1010]={};
dp[N][A-1]=1;
fct();ifct();
for (int i=0;i<=N;++i){
for (int j=A;j<=B;++j){
dp[i][j]=dp[i][j-1];
ll factor=1;
for (int k=0;k++<C;){
factor=mlt(factor, comb(i+k*j, j));
}
for (int k=C;k<=D;++k){
if(i+k*j>N) break;
factor=mlt(factor, comb(i+k*j, j));
dp[i][j]=ad(dp[i][j], mlt(dp[i+k*j][j-1], comb(i+k*j, j)));
}
}
}
cout << dp[0][B]<< endl;
return 0;
}
| a.cc: In function 'void fct()':
a.cc:30:24: error: expected ';' before ')' token
30 | for (int i=0;i<200009){
| ^
| ;
a.cc: In function 'void ifct()':
a.cc:38:13: warning: pointer to a function used in arithmetic [-Wpointer-arith]
38 | ifct[i-1]=mlt(ifct[i], i);
| ^
cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith]
a.cc:38:25: warning: pointer to a function used in arithmetic [-Wpointer-arith]
38 | ifct[i-1]=mlt(ifct[i], i);
| ^
a.cc:38:25: error: invalid conversion from 'void (*)()' to 'll' {aka 'long long int'} [-fpermissive]
38 | ifct[i-1]=mlt(ifct[i], i);
| ~~~~~~^
| |
| void (*)()
a.cc:12:11: note: initializing argument 1 of 'll mlt(ll, ll)'
12 | ll mlt(ll x, ll y){return (x*y)%MOD;}
| ~~~^
a.cc:38:14: error: assignment of read-only location '*(ifct + (((sizetype)i) + 18446744073709551615))'
38 | ifct[i-1]=mlt(ifct[i], i);
| ~~~~~~~~~^~~~~~~~~~~~~~~~
a.cc: In function 'll comb(int, int)':
a.cc:44:19: warning: pointer to a function used in arithmetic [-Wpointer-arith]
44 | return mlt(fct[n], mlt(ifct[k], ifct[n-k]));
| ^
a.cc:44:32: warning: pointer to a function used in arithmetic [-Wpointer-arith]
44 | return mlt(fct[n], mlt(ifct[k], ifct[n-k]));
| ^
a.cc:44:43: warning: pointer to a function used in arithmetic [-Wpointer-arith]
44 | return mlt(fct[n], mlt(ifct[k], ifct[n-k]));
| ^
a.cc:44:32: error: invalid conversion from 'void (*)()' to 'll' {aka 'long long int'} [-fpermissive]
44 | return mlt(fct[n], mlt(ifct[k], ifct[n-k]));
| ~~~~~~^
| |
| void (*)()
a.cc:12:11: note: initializing argument 1 of 'll mlt(ll, ll)'
12 | ll mlt(ll x, ll y){return (x*y)%MOD;}
| ~~~^
a.cc:44:43: error: invalid conversion from 'void (*)()' to 'll' {aka 'long long int'} [-fpermissive]
44 | return mlt(fct[n], mlt(ifct[k], ifct[n-k]));
| ~~~~~~~~^
| |
| void (*)()
a.cc:12:17: note: initializing argument 2 of 'll mlt(ll, ll)'
12 | ll mlt(ll x, ll y){return (x*y)%MOD;}
| ~~~^
a.cc:44:19: error: invalid conversion from 'void (*)()' to 'll' {aka 'long long int'} [-fpermissive]
44 | return mlt(fct[n], mlt(ifct[k], ifct[n-k]));
| ~~~~~^
| |
| void (*)()
a.cc:12:11: note: initializing argument 1 of 'll mlt(ll, ll)'
12 | ll mlt(ll x, ll y){return (x*y)%MOD;}
| ~~~^
a.cc: In function 'int main()':
a.cc:65:18: error: 'ad' was not declared in this scope; did you mean 'add'?
65 | dp[i][j]=ad(dp[i][j], mlt(dp[i+k*j][j-1], comb(i+k*j, j)));
| ^~
| add
|
s464076259 | p03832 | C++ | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fr(i,n) for(int i=0;i<(n);i++)
#define Fr(i,n) for(int i=0;i++<(n);)
#define ifr(i,n) for(int i=(n)-1;i>=0;i--)
#define iFr(i,n) for(int i=(n);i>0;i--)
const ll MOD=1e9+7;
//足し算してmodをとる
ll ad(ll x,ll y=0){
return (x+y)%MOD;
}
//mod _mult
ll mlt(ll x,ll y){
return (x*y)%MOD;
}
//xのy条
ll pwr(ll x,ll n){
ll v=1;
while(n>0){
if (n%2==1) v=mlt(v, x);
x=mlt(x,x);
n/=2;
}
return v;
}
//フェルマーの小定理に夜と、 x^(mod-2)=-1
ll inv(ll x){
return pwr(x,MOD-2);
}
//factorial
ll fc[200010];
void fct(){
fc[0]=1;
for (int i=0;i<200008;++i){
fc[i+1]=mlt(fc[i], i+1);
}
}
//inverse_factorial
ll ifc[200010];
void ifct(ll x){
ifc[200009]=inv(fc[200009]);
for (int i=200009;i>=1;--i) ifc[i-1]=mlt(ifc[i], i);
}
ll comb(ll n,ll r){
if(n<0 || r<0 || n<r) return 0;
return mlt(fc[n],mlt(ifc[r],ifc[n-r]));
}
int main(){
ll n,a,b,c,d,f;
cin>>n>>a>>b>>c>>d;
ll dp[1010][1010]={};
fct();
ifct();
dp[b+1][n]=1;
for(ll i=b;i>=a;i--){
//cout << i << endl;
fr(j,n+1){
dp[i][j]=ad(dp[i][j],dp[i+1][j]);
f=1;
Fr(k,c-1) f=mlt(f,comb(j+k*i,i));
for(ll k=c;k<=d;k++){
if(j+i*k>n) break;
f=mlt(f,comb(j+k*i,i));
dp[i][j]=ad(dp[i][j],mlt(dp[i+1][j+i*k],mlt(f,ifct(k))));
}
}
}
/*for(int i=2;i<4;i++){
fr(j,8) cout<<dp[i][j]<<" ";
cout<<endl;
}*/
cout<<dp[a][0]<<endl;
}
| a.cc: In function 'int main()':
a.cc:64:9: error: too few arguments to function 'void ifct(ll)'
64 | ifct();
| ~~~~^~
a.cc:49:6: note: declared here
49 | void ifct(ll x){
| ^~~~
a.cc:76:67: error: invalid use of void expression
76 | dp[i][j]=ad(dp[i][j],mlt(dp[i+1][j+i*k],mlt(f,ifct(k))));
| ~~~~^~~
|
s589602684 | p03832 | C++ | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fr(i,n) for(int i=0;i<(n);i++)
#define Fr(i,n) for(int i=0;i++<(n);)
#define ifr(i,n) for(int i=(n)-1;i>=0;i--)
#define iFr(i,n) for(int i=(n);i>0;i--)
const ll MOD=1e9+7;
//足し算してmodをとる
ll ad(ll x,ll y=0){
return (x+y)%MOD;
}
//mod _mult
ll mlt(ll x,ll y=1){
return (x*y)%MOD;
}
//xのy条
ll pwr(ll x,ll n){
ll v=1;
while(n>0){
if (n%2==1) v=mlt(v, x);
x=mlt(x,x);
n/=2;
}
return v;
}
//フェルマーの小定理に夜と、 x^(mod-2)=-1
ll inv(ll x){
return pwr(x,MOD-2);
}
//factorial
ll fc[200010];
ll fct(){
fc[0]=1;
for (int i=0;i<200008){
fc[i+1]=mlt(fc[i], i+1);
}
}
//inverse_factorial
ll ifc[200010];
ll ifct(ll x){
ifc[200009]=inv(fc[200009]);
for (int i=200009;i>=1;--i) ifc[i-1]=mlt(ifc, i);
}
ll comb(ll n,ll r){
if(n<0 || r<0 || n<r) return 0;
return mlt(fct(n),mlt(ifct(r),ifct(n-r)));
}
int main(){
ll n,a,b,c,d,f;
cin>>n>>a>>b>>c>>d;
ll dp[1010][1010]={};
fct();
ifct();
dp[b+1][n]=1;
for(ll i=b;i>=a;i--){
//cout << i << endl;
fr(j,n+1){
dp[i][j]=ad(dp[i][j],dp[i+1][j]);
f=1;
Fr(k,c-1) f=mlt(f,comb(j+k*i,i));
for(ll k=c;k<=d;k++){
if(j+i*k>n) break;
f=mlt(f,comb(j+k*i,i));
dp[i][j]=ad(dp[i][j],mlt(dp[i+1][j+i*k],mlt(f,ifct(k))));
}
}
}
/*for(int i=2;i<4;i++){
fr(j,8) cout<<dp[i][j]<<" ";
cout<<endl;
}*/
cout<<dp[a][0]<<endl;
}
| a.cc: In function 'll fct()':
a.cc:42:26: error: expected ';' before ')' token
42 | for (int i=0;i<200008){
| ^
| ;
a.cc:45:1: warning: no return statement in function returning non-void [-Wreturn-type]
45 | }
| ^
a.cc: In function 'll ifct(ll)':
a.cc:51:46: error: invalid conversion from 'll*' {aka 'long long int*'} to 'll' {aka 'long long int'} [-fpermissive]
51 | for (int i=200009;i>=1;--i) ifc[i-1]=mlt(ifc, i);
| ^~~
| |
| ll* {aka long long int*}
a.cc:18:11: note: initializing argument 1 of 'll mlt(ll, ll)'
18 | ll mlt(ll x,ll y=1){
| ~~~^
a.cc:52:1: warning: no return statement in function returning non-void [-Wreturn-type]
52 | }
| ^
a.cc: In function 'll comb(ll, ll)':
a.cc:56:19: error: too many arguments to function 'll fct()'
56 | return mlt(fct(n),mlt(ifct(r),ifct(n-r)));
| ~~~^~~
a.cc:40:4: note: declared here
40 | ll fct(){
| ^~~
a.cc: In function 'int main()':
a.cc:64:9: error: too few arguments to function 'll ifct(ll)'
64 | ifct();
| ~~~~^~
a.cc:49:4: note: declared here
49 | ll ifct(ll x){
| ^~~~
|
s282849843 | p03832 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
const ll MOD=1e9+7;
ll fct[20010];
ll ifct[20010];
ll MULT(int x, int y){
return (x*y)%MOD;
}
ll POW(int x, int n){
ll v=1;
while(n>1){
if(n%2==1)v=MULT(v, x);
x=MULT(x,x);
n/=2;
}
return v;
}
ll INV(int x){
return POW(x, MOD-2);
}
void FCT(){
fct[0]=1;
for (int i=0;i<20010;++i) fct[i+1]=MULT(fct[i],i+1);
}
void INV_FCT(){
ifct[20010-1]=INV(fct[20010-1]);
for (int i=20010-1;i>=1;--i) ifct[i-1]=ifct[i]*i;
}
ll comb(int n, int k){
return MULT(fct[n], MULT(ifct[k], ifct[n-k]));
}
int main(){
int N, A, B, C, D;cin>>N>>A>>B>>C>>D;
ll dp[1010][1010];memset(dp, 0, sizeof(dp));
FCT;INV_FCT;
dp[A-1][0]=1;
for(ll i=A;i<=B;++i){
for (int j=0;j<N+1;++j){
(dp[i][j]+=dp[i-1][j])%=MOD;
ll f=1;
if(C!=1){
for (int k=0;k<C-1;++k) f=MULT(f,comb(j-k*i,i));
}
for(ll k=C;k<=D;++k){
if(j+i*k>N) break;
f=MULT(f,comb(j+k*i,i));
(dp[i][j]+=MULT(dp[i-1][j-i*k],MULT(f,ifct[k]))%=MOD;
}
}
}
cout<<dp[B][N]<<endl;
} | a.cc: In function 'int main()':
a.cc:60:30: error: lvalue required as left operand of assignment
60 | (dp[i][j]+=MULT(dp[i-1][j-i*k],MULT(f,ifct[k]))%=MOD;
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:60:67: error: expected ')' before ';' token
60 | (dp[i][j]+=MULT(dp[i-1][j-i*k],MULT(f,ifct[k]))%=MOD;
| ~ ^
| )
|
s022755998 | p03832 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
const ll MOD=1e9+7;
ll fct[20010];
ll ifct[20010];
ll MULT(int x, int y){
return (x*y)%MOD;
}
ll POW(int x, int n){
ll v=1;
while(n>1){
if(n%2==1)v=MULT(v, x);
x=MULT(x,x);
n/=2;
}
return v;
}
ll INV(int x){
return POW(x, MOD-2);
}
void FCT(){
fct[0]=1;
for (int i=0;i<20010;++i) fct[i+1]=MULT(fct[i],i+1);
}
void INV_FCT(){
ifct[20010-1]=INV(fct[20010-1]);
for (int i=20010-1;i>=1;--i) ifct[i-1]=ifct[i]*i;
}
ll comb(int n, int k){
return MULT(fct[n], MULT(ifct[k], ifct[n-k]);
}
int main(){
int N, A, B, C, D;cin>>N>>A>>B>>C>>D;
ll dp[1010][1010];memset(dp, 0, sizeof(dp));
FCT;INV_FCT;
dp[A-1][0]=1;
for(ll i=A;i<=B;++i){
for (int j=0;j<N+1;++j){
(dp[i][j]+=dp[i-1][j])%=MOD;
f=1;
if(C!=1){
for (int k=0;k<C-1;++k) f=MULT(f,comb(j-k*i,i));
}
for(ll k=C;k<=D;++k){
if(j+i*k>N) break;
f=MULT(f,comb(j+k*i,i));
(dp[i][j]+=MULT(dp[i-1][j-i*k],MULT(f,ifct(k))))%=MOD;
}
}
}
cout<<dp[B][N]<<endl;
} | a.cc: In function 'll comb(int, int)':
a.cc:41:47: error: expected ')' before ';' token
41 | return MULT(fct[n], MULT(ifct[k], ifct[n-k]);
| ~ ^
| )
a.cc: In function 'int main()':
a.cc:53:11: error: 'f' was not declared in this scope
53 | f=1;
| ^
a.cc:60:57: error: 'ifct' cannot be used as a function
60 | (dp[i][j]+=MULT(dp[i-1][j-i*k],MULT(f,ifct(k))))%=MOD;
| ~~~~^~~
|
s657960869 | p03832 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
const ll MOD=1000000007;
ll fact[1001];
ll dp[1001][1001];
int extgcd(int a, int b, int& x, int& y){
int d=a;
if(b!=0){
d=extgcd(b, a/b, x, y);
y-=a/b*x;
}else{
x=1;y=0;
}
return d;
}
int mod_inverse(int a, int p){
int x, y;
int d=extgcd(a, p, x,y);
return (int)(m+x%m)%m;
}
ll mod_fact(int n, int p, int& e){
e=0;
if (n==0) return 1;
ll res=mod_fact(n/p, p, e);
e+=n/p;
if((n/p)%2!=0)return res*(p-fact[n%p])%p;
return res*fact[n%p]%p;
}
ll mod_comb(int n, int k, int p){
if(n<0 || k<0 || n<k) return 0;
int e1, e2, e3;
ll a1=mod_fact(n, p, e1), a2=mod_fact(k, p, e2), a3=mod_fact(n-k, p, e3);
if(e1>e2+e3) return 0;
return a1*mod_inverse(a2*a3%p, p)%p;
}
ll mod_d(int i, int j, int k, int p){
if(k==0) return 1;
return (mod_d(i, j, k-1, p)*mod_comb(i-(k-1)*j, j, p)/k)%p;
}
int main(){
int N, A, B, C, D;cin>>N>>A>>B>>C>>D;
memset(dp, 0, sizeof(dp));
dp[0][A]=1;
for (int i=0;i<=N;++i){
for (int j=A;j<=B;++j){
dp[i][j]=dp[i][j-1];
int D_=min(D, i/j);
for (int k=C;k<=D_;++k){
int e;
dp[i][j]+=dp[i-k*j][j-1]*mod_d(i, j, k, p);
}
}
}
cout << dp[N][B] << endl;
return 0;
} | a.cc: In function 'int mod_inverse(int, int)':
a.cc:25:16: error: 'm' was not declared in this scope
25 | return (int)(m+x%m)%m;
| ^
a.cc: In function 'int main()':
a.cc:64:49: error: 'p' was not declared in this scope
64 | dp[i][j]+=dp[i-k*j][j-1]*mod_d(i, j, k, p);
| ^
|
s903836462 | p03832 | C++ | #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <map>
using ll = long long;
using namespace std;
constexpr ll inf = 1e15;
#define MAX_N 1000
constexpr int MAX = 10000;
constexpr int MOD = 1e9+7;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++){
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算
long long COM(int n, int k){
if (n < k) return 0;
if (n < 0 || k < 0) return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// dp[i][j] := 最大のグループ人数がj人であるとき、i人をグループ分けする場合の数
ll dp[MAX_N+1][MAX_N+1] = {0};
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
int N, A, B, C, D;
cin>>N>>A>>B>>C>>D;
for (int i = 0; i <= B; i++) dp[0][i] = 1;
COMinit();
for (int n = 1; n <= N; n++) {
for (int i = A; i <= B; i++) {
ll comb = 1;
for (int j = 1; j < C; j++) comb = (((comb * COM(n - i * (j - 1), i)) % MOD) * inv[j]) % MOD;
for (int j = C; j <= D; j++) {
ll F = i * j;
comb = (((comb * COM(n - i * (j - 1), i)) % MOD) * inv[j]) % MOD;
if (n - F >= 0) dp[n][i] += dp[n - F][i - 1] * comb % MOD;
}
}
}
ll ans = 0;
for (int i = A; i <= B; i++) ans = (ans + dp[N][i]) % MOD/
cout<<ans<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:65:62: error: no match for 'operator/' (operand types are 'll' {aka 'long long int'} and 'std::ostream' {aka 'std::basic_ostream<char>'})
65 | for (int i = A; i <= B; i++) ans = (ans + dp[N][i]) % MOD/
| ~~~~~~~~~~~~~~~~~~~~~~^
| |
| ll {aka long long int}
66 | cout<<ans<<endl;
| ~~~~
| |
| std::ostream {aka std::basic_ostream<char>}
a.cc:65:62: note: candidate: 'operator/(ll {aka long long int}, int)' (built-in)
65 | for (int i = A; i <= B; i++) ans = (ans + dp[N][i]) % MOD/
| ~~~~~~~~~~~~~~~~~~~~~~^
66 | cout<<ans<<endl;
| ~~~~
a.cc:65:62: note: no known conversion for argument 2 from 'std::ostream' {aka 'std::basic_ostream<char>'} to 'int'
|
s156669268 | p03832 | C++ | #pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1000000007;
const int MAX = 210000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
ll gcd(ll a, ll b) {
if (b == 0) return a;
return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
for (size_t i = 0; i <= n; i++)
{
pr[i] = i;
}
}
int parent(int x) {
if (x == pr[x]) return x;
return pr[x] = parent(pr[x]);
}
bool unit(int x, int y) {
int px = parent(x);
int py = parent(y);
if (px == py) return false;
if (px < py) {
pr[py] = px;
}
else {
pr[px] = py;
}
return true;
}
ll ar[40];
bool use[40];
ll table[1001][1001];
ll n, a, b, c, d;
ll memo[1001][1001];
ll rec(int v, int rem) {
if (rem == 0) return 1;
if (v > b) return 0;
ll & res = memo[v][rem];
if (~res) return res;
res = rec(v + 1, rem);
res %= INF;
ll vr = 1;
ll pt = 1;
for (ll i = 1; i < c; i++)
{
vr *= table[rem - (v * (i - 1))][v];
vr %= INF;
vr *= inv[i];
vr %= INF;
}
for (ll i = c; i <= d; i++)
{
if (v * i > rem) break;
vr *= table[rem - (v * (i - 1))][v];
vr %= INF;
vr *= inv[i];
vr %= INF;
res += (vr * rec(v + 1, rem - v * i)) % INF;
res %= INF;
}
return res;
}
void solv() {
cin >> n;
cin >> a >> b;
cin >> c >> d;
table[0][0] = 1;
for (size_t i = 1; i <= n; i++)
{
table[i][0] = 1;
for (size_t j = 1; j <= n; j++)
{
table[i][j] = table[i - 1][j - 1] + table[i - 1][j];
table[i][j] %= INF;
}
}
memset(memo, -1, sizeof(memo));
cout << rec(a, n);
}
int main() {
COMinit();
solv();
return 0;
}
| a.cc:1:9: warning: #pragma once in main file
1 | #pragma once
| ^~~~
a.cc: In function 'void solv()':
a.cc:124:9: error: 'memset' was not declared in this scope
124 | memset(memo, -1, sizeof(memo));
| ^~~~~~
a.cc:19:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
18 | #include <iomanip>
+++ |+#include <cstring>
19 | using namespace std;
|
s658701478 | p03832 | C++ | //注意点
//Tは3つの値を持つ構造
//だがワイルドカードとしても使っている
#include <bits/stdc++.h>
using namespace std;
//@起動時
struct initon {
initon() {
cin.tie(0);
ios::sync_with_stdio(false);
cout.setf(ios::fixed);
cout.precision(16);
srand((unsigned) clock() + (unsigned) time(NULL));
};
} __initon;
//衝突対策
#define ws ___ws
//@必須構造
struct T {
int f, s, t;
T() { f = -1, s = -1, t = -1; }
T(int f, int s, int t) : f(f), s(s), t(t) {}
bool operator<(const T &r) const {
return f != r.f ? f < r.f : s != r.s ? s < r.s : t < r.t;
//return f != r.f ? f > r.f : s != r.s ? s > r.s : t > r.t; 大きい順
}
bool operator>(const T &r) const {
return f != r.f ? f > r.f : s != r.s ? s > r.s : t > r.t;
//return f != r.f ? f > r.f : s != r.s ? s > r.s : t > r.t; 小さい順
}
int operator[](int i) {
assert(i < 3);
return i == 0 ? f : i == 1 ? s : t;
}
};
//@マクロ省略系 型,構造
#define int long long
#define ll long long
#define double long double
#define ull unsigned long long
using dou = double;
using itn = int;
using str = string;
using bo= bool;
using P = pair<ll, ll>;
#define F first
#define fi first
#define S second
#define se second
#define vec vector
#define beg begin
#define rbeg rbegin
#define con continue
#define bre break
#define brk break
#define is ==
//マクロ省略系 コンテナ
using vi = vector<int>;
#define vvi(a, b, c) vec<vi> a(b,vi(c))
using vb = vector<bool>;
#define vvb(a, b, c) vec<vb> a(b,vb(c))
using vs = vector<string>;
#define vvs(a, b, c) vec<vs> a(b,vs(c))
using vl = vector<ll>;
#define vvl(a, b, c) vec<vl> a(b,vl(c))
using vd = vector<double>;
#define vvd(a, b, c) vec<vd> a(b,vd(c))
using vc=vector<char>;
#define vvc(a, b, c) vec<vc> a(b,vc(c))
using vp = vector<P>;
#define vvp(a, b, c) vec<vp> a(b,vp(c))
using vt = vector<T>;
#define vvt(a, b, c) vec<vt> a(b,vt(c))
#define v3i(a, b, c, d) vector<vector<vi>> a(b, vector<vi>(c, vi(d)))
#define v3d(a, b, c, d) vector<vector<vd>> a(b, vector<vd>(c, vd(d)))
#define v3m(a, b, c, d) vector<vector<vm>> a(b, vector<vm>(c, vm(d)))
#define PQ priority_queue<ll, vector<ll>, greater<ll> >
#define tos to_string
using mapi = map<int, int>;
using mapd = map<dou, int>;
using mapc = map<char, int>;
using maps = map<str, int>;
using seti = set<int>;
using setd = set<dou>;
using setc = set<char>;
using sets = set<str>;
#define uset unordered_set
#define mset multiset
#define umap unordered_map
#define mmap multimap
//マクロ 繰り返し
#define _overloadrep(_1, _2, _3, _4, name, ...) name
# define _rep(i, n) for(int i = 0,_lim=n; i < _lim ; i++)
#define repi(i, m, n) for(int i = m,_lim=n; i < _lim ; i++)
#define repadd(i, m, n, ad) for(int i = m,_lim=n; i < _lim ; i+= ad)
#define rep(...) _overloadrep(__VA_ARGS__,repadd,repi,_rep,)(__VA_ARGS__)
#define _rer(i, n) for(int i = n; i >= 0 ; i--)
#define reri(i, m, n) for(int i = m,_lim=n; i >= _lim ; i--)
#define rerdec(i, m, n, dec) for(int i = m,_lim=n; i >= _lim ; i-=dec)
#define rer(...) _overloadrep(__VA_ARGS__,rerdec,reri,_rer,)(__VA_ARGS__)
#define fora(a, b) for(auto&& a : b)
//#define forg(gi, ve) if (ve.size())for (int gi = 0, f = ve[gi].from, t = ve[gi].to, c = ve[gi].cost; gi < ve.size(); gi++,f = ve[gi].from, t = ve[gi].to, c = ve[gi].cost)
// ve[gi]が参照外を指すのを防ぐ
#define forg(gi, ve) if (ve.size())for (int gi = 0, f, t, c; gi < ve.size() && (f = ve[gi].from, t = ve[gi].to, c = ve[gi].cost, true); gi++)
#define fort(gi, ve) if (ve.size())for (int gi = 0, f, t, c;((ve[gi].to==p?gi++:1),gi < ve.size()) && (f = ve[gi].from, t = ve[gi].to, c = ve[gi].cost, true);gi++ )
//マクロ 定数
#define k4 10101
#define k5 101010
#define k6 1010101
#define k7 10101010
const int inf = (int) 1e9 + 100;
const ll linf = (ll) 1e18 + 100;
const double eps = 1e-9;
const double PI = 3.1415926535897932384626433832795029L;
const int y4[] = {-1, 1, 0, 0};
const int x4[] = {0, 0, -1, 1};
const int y8[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int x8[] = {1, 0, -1, 0, 1, -1, 1, -1};
//マクロ省略形 関数等
#define arsz(a) (sizeof(a)/sizeof(a[0]))
#define sz(a) (a.size())
#define rs(a) (a.resize())
#define mp make_pair
#define pb push_back
#define pf push_front
#define eb emplace_back
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
//@拡張系 こう出来るべきというもの
//埋め込み 存在を意識せずに機能を増やされているもの
// 境界チェック付きvector
namespace std_vector_bounds_checking {
using namespace std;
template<class T, class A = std::allocator<T>> struct vector : std::vector<T, A> {
using std::vector<T, A>::vector;
typename std::vector<T>::reference operator[](typename std::vector<T>::size_type n) {
return this->at(n);
}
};
}
namespace std {
template<> class hash<std::pair<signed, signed>> {
public:
size_t operator()(const std::pair<signed, signed> &x) const {
return hash<ll>()(((ll) x.first << 32) + x.second);
}
};
template<> class hash<std::pair<ll, ll>> {
public:
size_t operator()(const std::pair<ll, ll> &x) const {
return hash<ll>()(((ll) x.first << 32) + x.second);
}
};
}
istream &operator>>(istream &iss, P &a) {
iss >> a.first >> a.second;
return iss;
}
template<typename T> istream &operator>>(istream &iss, vector<T> &vec) {
for (T &x: vec) iss >> x;
return iss;
}
template<typename T> ostream &operator<<(ostream &os, vector <T> &vec) {
for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
return os;
}
template<typename V, typename H> void resize(vector<V> &vec, const H head) { //再帰の終端。 可変長templateの長さが 0 になるとこっちが呼ばれる。
vec.resize(head);
}
template<typename V, typename H, typename ... T> void resize(vector<V> &vec, const H &head, const T ... tail) {
vec.resize(head);
for (auto &v: vec) resize(v, tail...);
}
template<class T> T pop(set<T> &set) {
T res = *set.begin();
set.erase(set.find(res));
return res;
}
template<class T> T pop(mset<T> &set) {
T res = *set.begin();
set.erase(set.find(res));
return res;
}
template<class T> T popBack(set<T> &set) {
T res = *set.rbegin();
set.erase(set.find(res));
return res;
}
template<class T> T popBack(mset<T> &set) {
T res = *set.rbegin();
set.erase(set.find(res));
return res;
}
template<class T> inline void sort(vector<T> &a) { sort(a.begin(), a.end()); };
template<class T> inline void sort(vector<T> &a, int len) { sort(a.begin(), a.begin() + len); };
template<class T, class F> inline void sort(vector<T> &a, F f) { sort(a.begin(), a.end(), [&](T l, T r) { return f(l) < f(r); }); };
template<class T> inline void rsort(vector<T> &a) { sort(a.begin(), a.end(), greater<T>()); };
template<class T> inline void rsort(vector<T> &a, int len) { sort(a.begin(), a.begin() + len, greater<T>()); };
template<class T, class F> inline void rsort(vector<T> &a, F f) { sort(a.begin(), a.end(), greater<T>(), [&](T l, T r) { return f(l) > f(r); }); };
template<class U, class F> inline void sortp(vector<U> &a, vector<U> &b, F f) {
vp c;
int n = sz(a);
assert(n == sz(b));
rep(i, n)c.eb(a[i], b[i]);
sort(c, f);
rep(i, n) {
a[i] = c[i].first;
b[i] = c[i].second;
}
};
template<class U, class F> inline void rsortp(vector<U> &a, vector<U> &b, F f) {
vp c;
int n = sz(a);
assert(n == sz(b));
rep(i, n)c.eb(a[i], b[i]);
rsort(c, f);
rep(i, n) {
a[i] = c[i].first;
b[i] = c[i].second;
}
};
template<class T> inline void sort2(vector<vector<T>> &a) { for (int i = 0, n = a.size(); i < n; i++)sort(a[i]); }
template<class T> inline void rsort2(vector<vector<T>> &a) { for (int i = 0, n = a.size(); i < n; i++)rsort(a[i]); }
template<typename A, size_t N, typename T> void fill(A (&a)[N], const T &v) { rep(i, N)a[i] = v; }
template<typename A, size_t N, size_t O, typename T> void fill(A (&a)[N][O], const T &v) { rep(i, N)rep(j, O)a[i][j] = v; }
template<typename A, size_t N, size_t O, size_t P, typename T> void fill(A (&a)[N][O][P], const T &v) { rep(i, N)rep(j, O)rep(k, P)a[i][j][k] = v; }
template<typename A, size_t N, size_t O, size_t P, size_t Q, typename T> void fill(A (&a)[N][O][P][Q], const T &v) { rep(i, N)rep(j, O)rep(k, P)rep(l, Q)a[i][j][k][l] = v; }
template<typename A, size_t N, size_t O, size_t P, size_t Q, size_t R, typename T> void fill(A (&a)[N][O][P][Q][R], const T &v) { rep(i, N)rep(j, O)rep(k, P)rep(l, Q)rep(m, R)a[i][j][k][l][m] = v; }
template<typename A, size_t N, size_t O, size_t P, size_t Q, size_t R, size_t S, typename T> void fill(A (&a)[N][O][P][Q][R][S], const T &v) { rep(i, N)rep(j, O)rep(k, P)rep(l, Q)rep(m, R)rep(n, S)a[i][j][k][l][m][n] = v; }
template<typename V, typename T>
void fill(V &xx, const T &vall) {
xx = vall;
}
template<typename V, typename T>
void fill(vector<V> &vecc, const T &vall) {
for (auto &vx: vecc) fill(vx, vall);
}
//@汎用便利関数 入力
template<typename T = int> T in() {
T x;
cin >> x;
return (x);
}
string sin() { return in<string>(); }
double din() { return in<double>(); }
ll lin() { return in<ll>(); }
#define na(a, n) a.resize(n); rep(i,n) cin >> a[i];
#define nao(a, n) a.resize(n+1); rep(i,n) cin >> a[i+1];
#define nad(a, n) a.resize(n); rep(i,n) cin >> a[i], a[i]--;
#define na2(a, b, n) a.resize(n),b.resize(n);rep(i, n)cin >> a[i] >> b[i];
#define na2d(a, b, n) a.resize(n),b.resize(n);rep(i, n)cin >> a[i] >> b[i],a[i]--,b[i]--;
#define na3(a, b, c, n) a.resize(n),b.resize(n),c.resize(n); rep(i, n)cin >> a[i] >> b[i] >> c[i];
#define na3d(a, b, c, n) a.resize(n),b.resize(n),c.resize(n); rep(i, n)cin >> a[i] >> b[i] >> c[i],a[i]--,b[i]--,c[i]--;
#define nt(a, h, w) resize(a,h,w);rep(hi,h)rep(wi,w) cin >> a[hi][wi];
#define ntd(a, h, w) rs(a,h,w);rep(hi,h)rep(wi,w) cin >> a[hi][wi], a[hi][wi]--;
#define ntp(a, h, w) fill(a,'#');rep(hi,1,h+1)rep(wi,1,w+1) cin >> a[hi][wi];
//汎用便利関数 出力
template<class T> void out(T x) { typeid(x) == typeid(double) ? cout << fixed << setprecision(10) << x << endl : cout << x << endl; }
//デバッグ
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';
//よく使うクラス、構造体
class UnionFind {
public:
vi par, rank, sizes;
int n, trees;
UnionFind(int n) : n(n), trees(n) {
par.resize(n), rank.resize(n), sizes.resize(n);
rep(i, n)par[i] = i, sizes[i] = 1;
}
int root(int x) {
if (par[x] == x)return x;
else return par[x] = root(par[x]);
}
int find(int x) { return root(x); }
void unite(int x, int y) {
x = root(x);
y = root(y);
if (x == y)return;
if (rank[x] < rank[y])swap(x, y);
trees--;
par[y] = x;
sizes[x] += sizes[y];
if (rank[x] == rank[y])rank[x]++;
}
bool same(int x, int y) { return root(x) == root(y); }
int size(int x) { return sizes[root(x)]; }
//順不同 umapなので
vec<vi> sets() {
vec<vi> res(trees);
umap<int, vi> map;
rep(i, n) map[root(i)].push_back(i);
int i = 0;
for (auto &&p:map) {
int r = p.F;
res[i].push_back(r);
for (auto &&v:p.S) {
if (r == v)continue;
res[i].push_back(v);
}
i++;
}
return res;
}
};
//MOD関連
ll MOD = (int) 1e9 + 7;
class mint {
public:
int x;
mint() : x(0) {}
mint(signed y) : x(y >= 0 ? y % MOD : MOD - (-y) % MOD) {}
mint(int y) : x(y >= 0 ? y % MOD : MOD - (-y) % MOD) {}
static int _mpow(int v, ll a) {
ll x = v, n = a, res = 1;
while (n) {
if (n & 1)res = (res * x) % MOD;
x = (x * x) % MOD;
n >>= 1;
}
return res;
}
// Arithmetic Oprators
mint &operator+=(mint that) {
if ((x += that.x) >= MOD) x -= MOD;
return *this;
}
mint &operator-=(mint that) {
if ((x += MOD - that.x) >= MOD) x -= MOD;
return *this;
}
mint &operator*=(mint that) {
x = 1LL * x * that.x % MOD;
return *this;
}
mint &operator/=(const mint &that);
mint &operator^=(const mint &that) {
this->x = _mpow(x, that.x);
return *this;
}
mint &operator%=(mint that) {
x %= that.x;
return *this;
}
mint &operator+=(const int that) { return *this += mint(that); }
mint &operator-=(const int that) { return *this -= mint(that); }
mint &operator*=(const int that) { return *this *= mint(that); }
mint &operator/=(const int that);
mint &operator^=(const int that) {
this->x = _mpow(x, that);
return *this;
}
mint &operator%=(const int that) { return *this %= mint(that); }
mint &operator+=(const signed that) { return *this += mint(that); }
mint &operator-=(const signed that) { return *this -= mint(that); }
mint &operator*=(const signed that) { return *this *= mint(that); }
mint &operator/=(const signed that);
mint &operator^=(const signed that) {
this->x = _mpow(x, that);
return *this;
}
mint &operator%=(const signed that) { return *this %= mint(that); }
// Comparators
bool operator<(mint that) { return x < that.x; }
bool operator>(mint that) { return x > that.x; }
bool operator<=(mint that) { return x <= that.x; }
bool operator>=(mint that) { return x >= that.x; }
bool operator!=(mint that) { return x != that.x; }
bool operator==(mint that) { return x == that.x; }
bool operator!=(int that) { return x != that; }
bool operator==(int that) { return x == that; }
bool operator!=(signed that) { return x != that; }
bool operator==(signed that) { return x == that; }
// Utilities
unsigned getval() const { return x; }
operator int() { return x; }
mint operator+(mint that) const { return mint(*this) += that; }
mint operator-(mint that) const { return mint(*this) -= that; }
mint operator*(mint that) const { return mint(*this) *= that; }
mint operator%(mint that) const { return mint(*this) %= that; }
mint operator+(const int that) const { return mint(*this) += that; }
mint operator-(const int that) const { return mint(*this) -= that; }
mint operator*(const int that) const { return mint(*this) *= that; }
mint operator%(const int that) const { return mint(*this) %= that; }
mint operator=(const int that) { return *this = mint(that); }
mint operator+(const signed that) const { return mint(*this) += that; }
mint operator-(const signed that) const { return mint(*this) -= that; }
mint operator*(const signed that) const { return mint(*this) *= that; }
mint operator%(const signed that) const { return mint(*this) %= that; }
mint operator=(const signed that) { return *this = mint(that); }
mint operator++() {
x++;
return *this;
}
mint operator++(signed) {
auto ret = *this;
x++;
return ret;
}
friend void operator+=(ll &a, const mint &b) { a = mint(a % MOD + b.x); }
friend void operator-=(ll &a, const mint &b) { a = mint(a % MOD - b.x); }
friend void operator*=(ll &a, const mint &b) { a = mint(a % MOD * b.x); }
friend void operator/=(ll &a, const mint &b);
friend mint operator+(const ll a, const mint &b) { return mint(a % MOD + b.x); }
friend mint operator-(const ll a, const mint &b) { return mint(a % MOD - b.x); }
friend mint operator*(const ll a, const mint &b) { return mint(a % MOD * b.x); }
friend mint operator^(const ll a, const mint &b) { return _mpow(a, b.x); }
};
const int setModMax = 510000;
mint fac[setModMax], finv[setModMax], inv[setModMax];
void setMod(int m = MOD) {
MOD = m;
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < setModMax; i++) {
fac[i] = fac[i - 1].x * i % MOD;
inv[i] = MOD - inv[MOD % i].x * (MOD / i) % MOD;
finv[i] = finv[i - 1].x * inv[i].x % MOD;
}
}
mint mpow(int v, ll a) {
return mint::_mpow(v, a);
}
mint com(ll n, ll r) {
if (n < r || n < 0 || r < 0)return 0;
if (fac[0] == 0)setMod();
return fac[n] * finv[r] * finv[n - r];
}
mint ncr(ll n, ll r) { return com(n, r); }
mint nhr(ll n, ll r) { return com(n + r - 1, r); }
//拡張ユークリッドの互除法
mint minv(ll a) {
if (fac[0] == 0)setMod();
if (a < setModMax) return inv[a];
a %= MOD;
ll b = MOD, x = 1, y = 0;
while (b) {
ll t = a / b;
a -= t * b;
swap(a, b);
x -= t * y;
swap(x, y);
}
return x;
}
mint &mint::operator/=(const mint &that) { return *this *= minv(that.x); }
mint &mint::operator/=(const ll a) { return *this *= minv(a); }
mint &mint::operator/=(const signed a) { return *this *= minv(a); }
void operator/=(ll &a, const mint &b) { a = (a * minv(b.x)).x; }
using vm=vector<mint>;
#define vvm(a, b, c) vec<vm> a(b,vm(c))
using PM = pair<mint, mint>;
bool isPrime[4010101];
vi primes;
void setPrime() {
fill(isPrime, true);
int len = sizeof(isPrime) / sizeof(isPrime[0]);
isPrime[0] = isPrime[1] = false;
for (int i = 2; i <= sqrt(len) + 5; ++i) {
if (!isPrime[i])continue;
for (int j = 2; i * j < len; ++j) {
isPrime[i * j] = false;
}
}
rep(i, len)if (isPrime[i])primes.pb(i);
}
class fmint {
public:
int x;
fmint() : x(0) {}
fmint(signed y) : x(y % MOD) {}
fmint(int y) : x(y % MOD) {}
static int _mpow(int v, ll a) {
ll x = v, n = a, res = 1;
while (n) {
if (n & 1)res = (res * x) % MOD;
x = (x * x) % MOD;
n >>= 1;
}
return res;
}
// Arithmetic Oprators
fmint &operator+=(fmint that) {
x += that.x;
x %= MOD;
return *this;
}
fmint &operator*=(fmint that) {
x = x * that.x % MOD;
return *this;
}
fmint &operator/=(const fmint &that);
fmint &operator^=(const fmint &that) {
this->x = _mpow(x, that.x);
return *this;
}
fmint &operator%=(fmint that) {
x %= that.x;
return *this;
}
fmint &operator+=(const int that) { return *this += fmint(that); }
fmint &operator*=(const int that) { return *this *= fmint(that); }
fmint &operator/=(const int that);
fmint &operator^=(const int that) {
this->x = _mpow(x, that);
return *this;
}
fmint &operator%=(const int that) { return *this %= fmint(that); }
fmint &operator+=(const signed that) { return *this += fmint(that); }
fmint &operator*=(const signed that) { return *this *= fmint(that); }
fmint &operator/=(const signed that);
fmint &operator^=(const signed that) {
this->x = _mpow(x, that);
return *this;
}
fmint &operator%=(const signed that) { return *this %= fmint(that); }
// Comparators
bool operator<(fmint that) { return x < that.x; }
bool operator>(fmint that) { return x > that.x; }
bool operator<=(fmint that) { return x <= that.x; }
bool operator>=(fmint that) { return x >= that.x; }
bool operator!=(fmint that) { return x != that.x; }
bool operator==(fmint that) { return x == that.x; }
bool operator!=(int that) { return x != that; }
bool operator==(int that) { return x == that; }
bool operator!=(signed that) { return x != that; }
bool operator==(signed that) { return x == that; }
// Utilities
unsigned getval() const { return x; }
operator int() { return x; }
fmint operator+(fmint that) const { return fmint(*this) += that; }
fmint operator*(fmint that) const { return fmint(*this) *= that; }
fmint operator%(fmint that) const { return fmint(*this) %= that; }
fmint operator+(const int that) const { return fmint(*this) += that; }
fmint operator*(const int that) const { return fmint(*this) *= that; }
fmint operator%(const int that) const { return fmint(*this) %= that; }
fmint operator=(const int that) { return *this = fmint(that); }
fmint operator+(const signed that) const { return fmint(*this) += that; }
fmint operator*(const signed that) const { return fmint(*this) *= that; }
fmint operator%(const signed that) const { return fmint(*this) %= that; }
fmint operator=(const signed that) { return *this = fmint(that); }
fmint operator++() {
x++;
return *this;
}
fmint operator++(signed) {
auto ret = *this;
x++;
return ret;
}
friend void operator+=(ll &a, const fmint &b) { a = fmint(a % MOD + b.x); }
friend void operator*=(ll &a, const fmint &b) { a = fmint(a % MOD * b.x); }
friend void operator/=(ll &a, const fmint &b);
friend fmint operator+(const ll a, const fmint &b) { return fmint(a % MOD + b.x); }
friend fmint operator*(const ll a, const fmint &b) { return fmint(a % MOD * b.x); }
friend fmint operator^(const ll a, const fmint &b) { return _mpow(a, b.x); }
};
fmint &fmint::operator/=(const fmint &that) { return *this *= minv(that.x); }
fmint &fmint::operator/=(const ll a) { return *this *= minv(a); }
fmint &fmint::operator/=(const signed a) { return *this *= minv(a); }
void operator/=(ll &a, const fmint &b) { a = (a * minv(b.x)).x; }
using vfm=vector<fmint>;
#define vvfm(a, b, c) vec<vm> a(b,vm(c))
using PFM = pair<fmint, fmint>;
//幾何 Pをcomplexとして扱う
bool eq(double a, double b) { return fabs(a - b) < eps; }
using C =complex<double>;
C rot(C &a, dou th) {
return a * C(cos(th), sin(th));
}
dou inpro(C &a, C &b) {
return real(a * conj(b));
}
//90度回転させて内積が0なら平行
bool line(C a, C b, C c) {
C ab = b - a;
C ac = c - a;
//複素数の掛け算は回転
ab *= C(0, 1);
return eq(inpro(ab, ac), 0);
}
bool line(P a, P b, P c) {
return line(C(a.F, a.S), C(b.F, b.S), C(c.F, c.S));
}
bool line(int xa, int ya, int xb, int yb, int xc, int yc) {
C a = C(xa, ya);
C b = C(xb, yb);
C c = C(xc, yc);
return line(a, b, c);
}
//便利関数
//テスト用
char ranc() {
return (char) ('a' + rand() % 26);
}
int rand(int min, int max) {
return rand() % (max + 1 - min) + min;
}
vi ranv(int n, int min, int max) {
vi v(n);
rep(i, n)v[i] = rand(min, max);
return v;
}
vi ranvi(int n, int min, int max) {
vi v(n);
bool bad = 1;
while (bad) {
bad = 0;
v.resize(n);
rep(i, n) {
if (i && min > max - v[i - 1]) {
bad = 1;
break;
}
if (i)v[i] = v[i - 1] + rand(min, max - v[i - 1]);
else v[i] = rand(min, max);
}
}
return v;
}
void iota(vector<int> ve, int s, int n) {
ve.resize(n);
iota(all(ve), s);
}
void ole() {
string a = "a";
rep(i, 30)a += a;
rep(i, 1 << 17)cout << a << endl;
cout << "OLE 出力長制限超過" << endl;
exit(0);
}
void tle() { while (inf)cout << inf << endl; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll gcd(vi b) {
ll res = b[0];
for (auto &&v :b)res = gcd(v, res);
return res;
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll reverse(ll a) {
ll res = 0;
while (a) {
res *= 10;
res += a % 10;
a /= 10;
}
return res;
}
template<class T> void reverse(vector<T> &a) {
reverse(all(a));
}
ll ceil(ll a, ll b) {
if (b == 0) {
ole();
return -1;
} else return (a + b - 1) / b;
}
ll sqrt(ll a) {
if (a < 0)ole();
ll res = (ll) std::sqrt(a);
while (res * res < a)res++;
return res;
}
double log(double e, double x) { return log(x) / log(e); }
ll sig(ll t) { return (1 + t) * t / 2; }
ll sig(ll s, ll t) { return (s + t) * (t - s + 1) / 2; }
vi divisors(int v) {
vi res;
for (int i = 1; i <= sqrt(v); ++i) {
if (v % i == 0) {
res.pb(i);
if (i != v / i)res.pb(v / i);
}
}
return res;
}
vi factorization(int v) {
int tv = v;
vi res;
if (!isPrime[2])setPrime();
for (auto &&p :primes) {
if (v % p == 0)res.push_back(p);
while (v % p == 0) {
v /= p;
}
if (v == 1 || p * p > tv)break;
}
if (v > 1)res.pb(v);
return res;
}
unordered_map<int, int> factorizationMap(int v) {
int tv = v;
unordered_map<int, int> res;
if (!isPrime[2])setPrime();
for (auto &&p :primes) {
while (v % p == 0) {
res[p]++;
v /= p;
}
if (v == 1 || p * p > tv)break;
}
if (v > 1)res[v]++;
return res;
}
int get(int a, int keta) { return (a / (int) pow(10, keta)) % 10; }
int keta(int v) {
int cou = 0;
while (v) { cou++, v %= 10; }
return cou;
}
template<class T> void imo(vector<T> &v) {
int n = v.size();
rep(i, n - 1)v[i + 1] += v[i];
}
//変換系
template<class T, class U> vector<T> keys(vector<pair<T, U>> a) {
vector<T> res;
for (auto &&k :a)res.pb(k.F);
return res;
}
template<class T, class U> vector<U> keys(map<T, U> a) {
vector<U> res;
for (auto &&k :a)res.pb(k.F);
return res;
}
template<class T, class U> vector<U> keys(umap<T, U> a) {
vector<U> res;
for (auto &&k :a)res.pb(k.F);
return res;
}
template<class T, class U> vector<U> values(vector<pair<T, U>> a) {
vector<U> res;
for (auto &&k :a)res.pb(k.S);
return res;
}
template<class T, class U> vector<T> values(map<T, U> a) {
vector<T> res;
for (auto &&k :a)res.pb(k.S);
return res;
}
template<class T, class U> vector<T> values(umap<T, U> a) {
vector<T> res;
for (auto &&k :a)res.pb(k.S);
return res;
}
vi list(int a) {
vi res;
while (a) {
res.insert(res.begin(), a % 10);
a /= 10;
}
return res;
}
template<class T, class U> bool chmax(T &a, const U &b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template<class T, class U> bool chmin(T &a, const U &b) {
if (b < a) {
a = b;
return true;
}
return false;
}
template<class T> T min(T a, signed b) {
return a < b ? a : b;
}
template<class T> T max(T a, signed b) {
return a < b ? b : a;
}
template<class T> T min(T a, T b, T c) {
return a >= b ? b >= c ? c : b : a >= c ? c : a;
}
template<class T> T max(T a, T b, T c) {
return a <= b ? b <= c ? c : b : a <= c ? c : a;
}
template<class T> T min(vector<T> a) {
return *min_element(all(a));
}
template<class T> T min(vector<T> a, int n) {
return *min_element(a.begin(), a.begin() + min(n, sz(a)));
}
template<class T> T min(vector<T> a, int s, int n) {
return *min_element(a.begin() + s, a.begin() + min(n, sz(a)));
}
template<class T> T max(vector<T> a) {
return *max_element(all(a));
}
template<class T> T max(vector<T> a, int n) {
return *max_element(a.begin(), a.begin() + min(n, sz(a)));
}
template<class T> T max(vector<T> a, int s, int n) {
return *max_element(a.begin() + s, a.begin() + min(n, sz(a)));
}
template<typename A, size_t N> A max(A (&a)[N]) {
A res = a[0];
rep(i, N)res = max(res, a[i]);
return res;
}
template<typename A, size_t N, size_t O> A max(A (&a)[N][O]) {
A res = max(a[0]);
rep(i, N)res = max(res, max(a[i]));
return res;
}
template<typename A, size_t N, size_t O, size_t P> A max(A (&a)[N][O][P]) {
A res = max(a[0]);
rep(i, N)res = max(res, max(a[i]));
return res;
}
template<typename A, size_t N, size_t O, size_t P, size_t Q> A max(A (&a)[N][O][P][Q], const T &v) {
A res = max(a[0]);
rep(i, N)res = max(res, max(a[i]));
return res;
}
template<typename A, size_t N, size_t O, size_t P, size_t Q, size_t R> A max(A (&a)[N][O][P][Q][R]) {
A res = max(a[0]);
rep(i, N)res = max(res, max(a[i]));
return res;
}
template<typename A, size_t N, size_t O, size_t P, size_t Q, size_t R, size_t S> A max(A (&a)[N][O][P][Q][R][S]) {
A res = max(a[0]);
rep(i, N)res = max(res, max(a[i]));
return res;
}
template<typename A, size_t N> A min(A (&a)[N]) {
A res = a[0];
rep(i, N)res = min(res, a[i]);
return res;
}
template<typename A, size_t N, size_t O> A min(A (&a)[N][O]) {
A res = min(a[0]);
rep(i, N)res = min(res, max(a[i]));
return res;
}
template<typename A, size_t N, size_t O, size_t P> A min(A (&a)[N][O][P]) {
A res = min(a[0]);
rep(i, N)res = min(res, min(a[i]));
return res;
}
template<typename A, size_t N, size_t O, size_t P, size_t Q> A min(A (&a)[N][O][P][Q], const T &v) {
A res = min(a[0]);
rep(i, N)res = min(res, min(a[i]));
return res;
}
template<typename A, size_t N, size_t O, size_t P, size_t Q, size_t R> A min(A (&a)[N][O][P][Q][R]) {
A res = min(a[0]);
rep(i, N)res = min(res, min(a[i]));
return res;
}
template<typename A, size_t N, size_t O, size_t P, size_t Q, size_t R, size_t S> A min(A (&a)[N][O][P][Q][R][S]) {
A res = min(a[0]);
rep(i, N)res = min(res, min(a[i]));
return res;
}
template<class T> T sum(vector<T> v, int len = -1) {
if (len == -1)len = v.size();
T res = 0;
chmin(len, v.size());
rep(i, len)res += v[i];
return res;
}
template<class T> T sum(vector<vector<T>> &v, int h = -1, int w = -1) {
if (h == -1)h = v.size();
if (w == -1)w = v[0].size();
T res = 0;
chmin(h, v.size());
chmin(w, v[0].size());
rep(i, h)rep(j, w)res += v[i][j];
return res;
}
P sump(vp &v, int len = -1) {
if (len == -1)len = v.size();
P res = {0, 0};
chmin(len, v.size());
rep(i, len) {
res.F += v[i].F;
res.S += v[i].S;
}
return res;
}
///要素が0の時、返り値は0か1か
template<class T> T mul(vector<T> &v, int len = -1) {
if (len == -1)len = v.size();
T res = 1;
chmin(len, v.size());
rep(i, len)res *= v[i];
return res;
}
void clear(PQ &q) { while (q.size())q.pop(); }
template<class T> void clear(queue<T> &q) { while (q.size())q.pop(); }
template<class T> T *negarr(int size) {
T *body = (T *) malloc((size * 2 + 1) * sizeof(T));
return body + size;
}
template<class T> T *negarr2(int h, int w) {
double **dummy1 = new double *[2 * h + 1];
double *dummy2 = new double[(2 * h + 1) * (2 * w + 1)];
dummy1[0] = dummy2 + w;
for (int i = 1; i <= 2 * h + 1; i++) {
dummy1[i] = dummy1[i - 1] + 2 * w + 1;
}
double **a = dummy1 + h;
}
template<class T> vector<T> ruiv(vector<T> &a) {
vector<T> res(a.size() + 1);
rep(i, a.size())res[i + 1] = res[i] + a[i];
return res;
}
template<class T> vector<T> ruim(vector<T> &a) {
vector<T> res(a.size() + 1, 1);
rep(i, a.size())res[i + 1] = res[i] * a[i];
return res;
}
//右から左にかけての半開区間 (-1 n-1]
template<class T> T *rrui(vector<T> &a) {
int len = a.size();
T *body = (T *) malloc((len + 1) * sizeof(T));
T *res = body + 1;
rer(i, len - 1)res[i - 1] = res[i] + a[i];
return res;
}
//掛け算
template<class T> T *rruim(vector<T> &a) {
int len = a.size();
T *body = (T *) malloc((len + 1) * sizeof(T));
T *res = body + 1;
res[len - 1] = 1;
rer(i, len - 1)res[i - 1] = res[i] * a[i];
return res;
}
template<class T> void plus(vector<T> &a, T v = 1) { for (auto &&u :a)u += v; }
template<class T> void minu(vector<T> &a, T v = 1) { for (auto &&u :a)u -= v; }
template<class T> void minus(vector<T> &a, T v = 1) { for (auto &&u :a)u -= v; }
inline bool inside(int y, int x, int H, int W) { return y >= 0 && x >= 0 && y < H && x < W; }
ll u(ll a) { return a < 0 ? 0 : a; }
#define MIN(a) numeric_limits<a>::min()
#define MAX(a) numeric_limits<a>::max()
ll goldd(ll left, ll right, function<ll(ll)> calc) {
double GRATIO = 1.6180339887498948482045868343656;
ll lm = left + (ll) ((right - left) / (GRATIO + 1.0));
ll rm = lm + (ll) ((right - lm) / (GRATIO + 1.0));
ll fl = calc(lm);
ll fr = calc(rm);
while (right - left > 10) {
if (fl < fr) {
right = rm;
rm = lm;
fr = fl;
lm = left + (ll) ((right - left) / (GRATIO + 1.0));
fl = calc(lm);
} else {
left = lm;
lm = rm;
fl = fr;
rm = lm + (ll) ((right - lm) / (GRATIO + 1.0));
fr = calc(rm);
}
}
ll minScore = MAX(ll);
ll resIndex = left;
for (ll i = left; i < right + 1; i++) {
ll score = calc(i);
if (minScore > score) {
minScore = score;
resIndex = i;
}
}
return resIndex;
}
ll goldt(ll left, ll right, function<ll(ll)> calc) {
double GRATIO = 1.6180339887498948482045868343656;
ll lm = left + (ll) ((right - left) / (GRATIO + 1.0));
ll rm = lm + (ll) ((right - lm) / (GRATIO + 1.0));
ll fl = calc(lm);
ll fr = calc(rm);
while (right - left > 10) {
if (fl > fr) {
right = rm;
rm = lm;
fr = fl;
lm = left + (ll) ((right - left) / (GRATIO + 1.0));
fl = calc(lm);
} else {
left = lm;
lm = rm;
fl = fr;
rm = lm + (ll) ((right - lm) / (GRATIO + 1.0));
fr = calc(rm);
}
}
if (left > right) {
ll l = left;
left = right;
right = l;
}
ll maxScore = MIN(ll);
ll resIndex = left;
for (ll i = left; i < right + 1; i++) {
ll score = calc(i);
if (maxScore < score) {
maxScore = score;
resIndex = i;
}
}
return resIndex;
}
template<class T> T min(vector<vector<T>> &a) {
T res = MAX(T);
rep(i, a.size())chmin(res, *min_element(all(a[i])));
return res;
}
template<class T> T max(vector<vector<T>> &a) {
T res = MIN(T);
rep(i, a.size())chmax(res, *max_element(all(a[i])));
return res;
}
bool bget(ll m, int keta) { return (m >> keta) & 1; }
int bget(ll m, int keta, int sinsuu) {
m /= (ll) pow(sinsuu, keta);
return m % sinsuu;
}
inline ll bit(int n) { return (1LL << (n)); }
inline ll bit(int n, int sinsuu) { return (ll) pow(sinsuu, n); }
int bcou(ll m) { return __builtin_popcount(m & 0xFFFFFFFF) + __builtin_popcount(m >> 32); }
//初期化は0を渡す
ll nextComb(ll &mask, int n, int r) {
if (!mask)return mask = (1LL << r) - 1;
ll x = mask & -mask; //最下位の1
ll y = mask + x; //連続した下の1を繰り上がらせる
ll res = ((mask & ~y) / x >> 1) | y;
if (bget(res, n))return mask = 0;
else return mask = res;
}
//n桁以下でビットがr個立っているもののvectorを返す
vl bitCombList(int n, int r) {
vl res;
int m = 0;
while (nextComb(m, n, r)) {
res.pb(m);
}
return res;
}
//大文字小文字を区別する
int altoiaZ(char c) {
if ('A' <= c && c <= 'Z')return c - 'A';
return c - 'a' + 26;
}
char itoalaZ(int i) {
if (i < 26)return 'A' + i;
return 'a' + i - 26;
}
//aもAも0を返す 基本小文字
int altoi(char c) {
if ('A' <= c && c <= 'Z')return c - 'A';
return c - 'a';
}
char itoal(int i) {
return 'a' + i;
}
int ctoi(char c) { return c - '0'; }
char itoc(int i) { return i + '0'; }
int vtoi(vi &v) {
int res = 0;
if (sz(v) > 18)ole();
rep(i, sz(v)) {
res *= 10;
res += v[i];
}
return res;
}
vi itov(int i) {
vi res;
while (i) {
res.pb(i % 10);
i /= 10;
}
reverse(res);
return res;
}
vector<vector<int>> ctoi(vector<vector<char>> s, char c) {
int n = sz(s), m = sz(s[0]);
vector<vector<int>> res(n, vector<int>(m));
rep(i, n)rep(j, m)res[i][j] = s[i][j] == c;
return res;
}
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
void compress(vi &a) {
vi b;
int len = a.size();
for (int i = 0; i < len; ++i) {
b.push_back(a[i]);
}
sort(b);
UNIQUE(b);
for (int i = 0; i < len; ++i) {
a[i] = lower_bound(all(b), a[i]) - b.begin();
}
}
void compress(int a[], int len) {
vi b;
for (int i = 0; i < len; ++i) {
b.push_back(a[i]);
}
sort(b);
UNIQUE(b);
for (int i = 0; i < len; ++i) {
a[i] = lower_bound(all(b), a[i]) - b.begin();
}
}
//要素が見つからなかったときに困る
#define binarySearch(a, v) (binary_search(all(a),v))
#define lowerIndex(a, v) (lower_bound(all(a),v)-a.begin())
#define lowerBound(a, v) (*lower_bound(all(a),v))
#define upperIndex(a, v) (upper_bound(all(a),v)-a.begin())
#define upperBound(a, v) (*upper_bound(all(a),v))
#define ans(a) cout<<a<<endl;continue;
#define poll(a) q.front();q.pop()
#define dpoll(a) q.front();q.pop_front()
#define pollLast(a) q.back();q.pop_back()
#define pollBack(a) q.back();q.pop_back()
template<class T> inline void fin(T s) { cout << s << endl, exit(0); }
template<class T> struct edge {
int from, to;
T cost;
int id;
int type;
edge(int f, int t, T c = 1, int id = -1, int ty = -1) : from(f), to(t), cost(c), id(id), type(ty) {}
bool operator<(const edge &b) const { return cost < b.cost; }
bool operator>(const edge &b) const { return cost > b.cost; }
};
template<typename T> class graph {
protected:
vector<bool> _used;
public :
vector<vector<edge<T>>> g;
vector<edge<T>> edges;
int n, root = -1;
graph(int n) : n(n) { g.resize(n), _used.resize(n); }
void clear() { g.clear(), edges.clear(); }
void resize(int n) {
this->n = n;
g.resize(n);
_used.resize(n);
}
int size() { return g.size(); }
bool isleaf(int v) {
assert(root != -1);
return g[v].size() == 1 && g[v][0].from != root;
}
vector<edge<T> > &operator[](int i) { return g[i]; }
virtual void add(int from, int to, T cost, int ty) = 0;
virtual bool used(edge<T> &e) = 0;
virtual bool used(int id) = 0;
virtual void del(edge<T> &e) = 0;
virtual void del(int id) = 0;
};
template<class T=int> class undigraph : public graph<T> {
public:
using graph<T>::g;
using graph<T>::n;
using graph<T>::edges;
using graph<T>::_used;
undigraph(int n) : graph<T>(n) {
}
void add(int f, int t, T cost = 1, int ty = -1) {
if (!(0 <= f && f < n && 0 <= t && t < n))ole();
int id = edges.size();
g[f].emplace_back(f, t, cost, id, ty);
g[t].emplace_back(t, f, cost, id + 1, ty);
edges.emplace_back(f, t, cost, id, ty);
edges.emplace_back(t, f, cost, id + 1, ty);
}
void add(edge<T> &e) {
int f = e.from, t = e.to, ty = e.type;
T cost = e.cost;
add(f, t, cost, ty);
}
bool used(edge<T> &e) { return _used[e.id]; }
bool used(int id) { return _used[id]; }
void del(edge<T> &e) { _used[e.id] = _used[e.id ^ 1] = 1; }
void del(int id) { _used[id] = _used[id ^ 1] = 1; }
};
template<typename T =ll> class digraph : public graph<T> {
public:
using graph<T>::g;
using graph<T>::n;
using graph<T>::edges;
using graph<T>::_used;
digraph(int n) : graph<T>(n) {}
void add(int f, int t, T cost = 1, int ty = -1) {
if (!(0 <= f && f < n && 0 <= t && t < n))ole();
int id = edges.size();
g[f].emplace_back(f, t, cost, ty, id);
edges.emplace_back(f, t, cost, ty, id);
}
bool used(edge<T> &e) { return _used[e.id]; }
bool used(int id) { return _used[id]; }
void del(edge<T> &e) { _used[e.id] = _used[e.id ^ 1] = 1; }
void del(int id) { _used[id] = _used[id ^ 1] = 1; }
};
template<class T> bool nibu(const graph<T> &g) {
UnionFind uf(g.n * 2);
for (auto &&e :g.edges)uf.unite(e.f, e.t + g.n), uf.unite(e.f + g.n, e.t);
return !uf.same(0, g.n);
}
template<class T> vector<T> dijkstra(const graph<T> &g, int s) {
if (!(0 <= s && s < g.n))ole();
T initValue = MAX(T);
vector<T> dis(g.n, initValue);
priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T, int>>> q;
dis[s] = 0;
q.emplace(0, s);
while (q.size()) {
T nowc = q.top().F;
int i = q.top().S;
q.pop();
if (dis[i] != nowc)continue;
for (auto &&e : g.g[i]) {
int to = e.to;
T cost = nowc + e.cost;
if (dis[to] > cost) {
dis[to] = cost;
q.emplace(dis[to], to);
}
}
}
//たどり着かないなら-1
for (auto &&d :dis) if (d == initValue)d = -1;
return dis;
}
//機能拡張
vp vtop(vi &a, vi &b) {
vp res(sz(a));
rep(i, sz(a))res[i] = mp(a[i], b[i]);
return res;
}
void ptov(vp &p, vi &a, vi &b) {
a.resize(sz(p));
b.resize(sz(p));
rep(i, sz(p))a[i] = p[i].F, b[i] = p[i].S;
}
template<typename _CharT, typename _Traits, typename _Alloc>
basic_string<_CharT, _Traits, _Alloc>
operator+(const basic_string<_CharT, _Traits, _Alloc> &__lhs, const int __rv) {
basic_string<_CharT, _Traits, _Alloc> __str(__lhs);
__str.append(to_string(__rv));
return __str;
}
template<typename _CharT, typename _Traits, typename _Alloc>
void operator+=(basic_string<_CharT, _Traits, _Alloc> &__lhs, const int __rv) {
__lhs += to_string(__rv);
}
template<typename _CharT, typename _Traits, typename _Alloc>
basic_string<_CharT, _Traits, _Alloc>
operator+(const basic_string<_CharT, _Traits, _Alloc> &__lhs, const signed __rv) {
basic_string<_CharT, _Traits, _Alloc> __str(__lhs);
__str.append(to_string(__rv));
return __str;
}
template<typename _CharT, typename _Traits, typename _Alloc>
void operator+=(basic_string<_CharT, _Traits, _Alloc> &__lhs, const signed __rv) {
__lhs += to_string(__rv);
}
template<class T, class U> void operator+=(queue<T> &a, U v) {
a.push(v);
}
template<class T, class U>
priority_queue<T, vector<T>, greater<T> > &operator+=(priority_queue<T, vector<T>, greater<T> > &a, U v) {
a.push(v);
return a;
}
template<class T, class U> priority_queue<T> &operator+=(priority_queue<T> &a, U v) {
a.push(v);
return a;
}
template<class T, class U> set<T> &operator+=(set<T> &a, U v) {
a.insert(v);
return a;
}
template<class T, class U> set<T, greater<T>> &operator+=(set<T, greater<T>> &a, U v) {
a.insert(v);
return a;
}
template<class T, class U> vector<T> &operator+=(vector<T> &a, U v) {
a.pb(v);
return a;
}
template<class T> vector<T> &operator+=(vector<T> &a, vector <T> &b) {
a.pb(b);
return a;
}
template<class T, class U> vector<T> &operator+=(vector<T> &a, initializer_list<U> v) {
for (auto &&va :v)a.pb(va);
return a;
}
template<class T> vector<T> &operator-=(vector<T> &a, vector <T> &b) {
if (sz(a) != sz(b))ole();
rep(i, sz(a))a[i] -= b[i];
return a;
}
template<class T> vector<T> &operator-(vector<T> &a, vector <T> &b) {
if (sz(a) != sz(b))ole();
vector<T> res;
rep(i, sz(a))res[i] = a[i] - b[i];
return res;
}
template<typename T> void remove(vector<T> &v, unsigned int i) { v.erase(v.begin() + i); }
template<typename T> void remove(vector<T> &v, unsigned int s, unsigned int e) {
v.erase(v.begin() + s, v.begin() + e);
}
template<typename T> void removen(vector<T> &v, unsigned int s, unsigned int n) {
v.erase(v.begin() + s, v.begin() + s + n);
}
template<typename T> void erase(vector<T> &v, unsigned int i) { v.erase(v.begin() + i); }
template<typename T> void erase(vector<T> &v, unsigned int s, unsigned int e) {
v.erase(v.begin() + s, v.begin() + e);
}
template<typename T> void erasen(vector<T> &v, unsigned int s, unsigned int n) {
v.erase(v.begin() + s, v.begin() + s + n);
}
template<typename T> void insert(vector<T> &v, unsigned int i, T t) { v.insert(v.begin() + i, t); }
template<typename T> void insert(vector<T> &v, unsigned int i, vector<T> list) {
for (auto &&va :list)v.insert(v.begin() + i++, va);
}
template<typename T, typename U> void insert(vector<T> &v, initializer_list<U> list) {
for (auto &&va :list)v.pb(va);
}
template<typename T, typename U> void insert(vector<T> &v, unsigned int i, initializer_list<U> list) {
for (auto &&va :list)v.insert(v.begin() + i++, va);
}
template<typename T> void insert(set<T> &v, vector<T> list) {
for (auto &&va :list)v.insert(va);
}
template<typename T> void insert(set<T> &v, initializer_list<T> list) {
for (auto &&va :list)v.insert(va);
}
ll ma = numeric_limits<ll>::min();
ll mi = numeric_limits<ll>::max();
//閉路がなければtrue
bool topo(vi &res, digraph<int> &g) {
int n = g.g.size();
vi nyu(n);
rep(i, n)for (auto &&e :g[i])nyu[e.to]++;
queue<int> st;
rep(i, n)if (nyu[i] == 0)st.push(i);
while (st.size()) {
int v = st.front();
st.pop();
res.pb(v);
fora(e, g[v]) if (--nyu[e.to] == 0)st.push(e.to);
}
return res.size() == n;
}
//辞書順最小トポロジカルソート
bool topos(vi &res, digraph<int> &g) {
int n = g.g.size();
vi nyu(n);
rep(i, n)for (auto &&e :g[i])nyu[e.to]++;
//小さい順
priority_queue<int, vector<int>, greater<int> > q;
rep(i, n)if (nyu[i] == 0)q.push(i);
while (q.size()) {
int i = q.top();
q.pop();
res.pb(i);
fora(e, g[i])if (--nyu[e.to] == 0)q.push(e.to);
}
return res.size() == n;
}
vector<string> split(const string a, const char deli) {
string b = a + deli;
int l = 0, r = 0, n = b.size();
vector<string> res;
rep(i, n) {
if (b[i] == deli) {
r = i;
if (l < r)res.push_back(b.substr(l, r - l));
l = i + 1;
}
}
return res;
}
vector<string> split(const string a, const string deli) {
string b = a + deli;
int l = 0, r = 0, n = b.size(), dn = deli.size();
vector<string> res;
rep(i, n) {
if (i + dn <= n && b.substr(i, i + dn) == deli) {
r = i;
if (l < r)res.push_back(b.substr(l, r - l));
i += dn - 1;
l = i + 1;
}
}
return res;
}
void yn(bool a) {
if (a)cout << "yes" << endl;
else cout << "no" << endl;
}
void Yn(bool a) {
if (a)cout << "Yes" << endl;
else cout << "No" << endl;
}
void YN(bool a) {
if (a)cout << "YES" << endl;
else cout << "NO" << endl;
}
void fyn(bool a) {
if (a)cout << "yes" << endl;
else cout << "no" << endl;
exit(0);
}
void fYn(bool a) {
if (a)cout << "Yes" << endl;
else cout << "No" << endl;
exit(0);
}
void fYN(bool a) {
if (a)cout << "YES" << endl;
else cout << "NO" << endl;
exit(0);
}
int n, m, k, d, H, W, x, y, z, q;
int cou;
vi a, b, c;
vvi (s, 0, 0);
vvc (ba, 0, 0);
vp p;
undigraph<> g(2 * k5);
vvi(fa, k5 * 2, 0);
mapi dp[k5 * 2];
void ds(int i, int p) {
fora(v, fa[i])dp[i][v] = 1;
fort(gi, g[i]) {
ds(t, i);
fora(v, fa[i]) {
chmax(ma, dp[i][v] + dp[t][v]);
chmax(dp[i][v], dp[t][v] + 1);
}
}
}
void solve() {
int a, b, c, d;
cin >> n >> a >> b >> c >> d;
setMod();
vvm(dp, 1010, 1010); //dp[i][j] i人未満で残りj人までした
dp[0][n] = 1;
rep(i, n + 1) {
rep(r, n + 1) {
dp[i + 1][r] += dp[i][r];
if (!(a <= i && i <= b))con;
mint comb = 1;
int nr = r;
for (int g = 1; nr - i >= 0; ++g) {
comb *= com(nr, i);
comb /= g;
if (c <= g && g <= d)dp[i + 1][nr - i] += dp[i][r] * comb;
nr -= i;
}
}
}
cout << dp[n + 1][0] << endl;
}
int my(int n, vi a) {
return 0;
}
int sister(int n, vi a) {
return 0;
}
signed main() {
solve();
// cin >> n;
// addn(a, n);
// cout << my(n, m, a) << endl;
// cout << sister(n, m, a) << endl;
#ifdef _DEBUG
bool bad = 0;
for (int i = 0, ok = 1; i < k5 && ok; i++) {
int n = rand(2, 5);
int m = rand(2, 5);
int k = rand(2, 5);
vi a = ranv(n, 1, 10);
vi b = ranv(n, 1, 10);
#define _arg n,a
int myres = my(_arg);
int res = sister(_arg);
ok = myres == res;
if (!ok) {
cout << n << endl;
cout << a << endl;
cout << "正解 : " << res << endl;
cout << "出力 : " << myres << endl;
bad = 1;
break;
}
}
// if(!bad)cout << "お兄ちゃんすごい!天才!!" << endl;
#endif
return 0;
};
h | a.cc:1579:1: error: 'h' does not name a type
1579 | h
| ^
|
s333681090 | p03832 | C++ | #include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF 1e18
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;
const ll MOD = 1e9 + 7;
ll fastPow(ll x, ll n)
{
if (n == 0)
return 1;
if (n % 2 == 0)
return fastPow(x * x % MOD, n / 2);
else
return x * fastPow(x, n - 1) % MOD;
}
ll fac[11234];
void combInit(int mx)
{
fac[0] = 0;
fac[1] = 1;
for (int i = 2; i <= mx; i++)
{
fac[i] = fac[i - 1] * i % MOD;
}
}
ll modDiv(ll a, ll b)
{
return a * fastPow(b, MOD - 2) % MOD;
}
int main()
{
combInit(11234);
ll perm[101][101];
for (int i = 1; i <= 100; i++)
{
perm[i][1] = i;
for (int j = 2; j <= 100; j++)
{
perm[i][j] = perm[i][j - 1] * (i - j + 1);
perm[i][j] %= MOD;
}
}
int n, a, b, c, d;
cin >> n >> a >> b >> c >> d;
ll dp[101][101];
memset(dp, 0, sizeof(dp));
for (int i = 0; i <= n; i++)
dp[0][i] = 1;
for (int i = 1; i <= n; i++)
{
for (int j = a; j <= b; j++)
{
dp[i][j] += dp[i][j - 1];
for (int k = c; k <= d; k++)
{
if (i - j * k < 0)
break;
dp[i][j] += dp[i - j * k][j - 1] * modDiv(perm[n - i + j * k][j * k], fastPow(fac[j], k) * fac[k]);
dp[i][j] %= MOD;
}
}
}
ll res = 0;
cout << dp[n][b] << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:72:5: error: 'memset' was not declared in this scope
72 | memset(dp, 0, sizeof(dp));
| ^~~~~~
a.cc:9:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
8 | #include <numeric>
+++ |+#include <cstring>
9 |
|
s238403446 | p03832 | C++ | #include <iostream>
#include <fstream>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string>
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
using namespace std;
using ll = long long;
#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;
template <class T> void corner(bool flg, T hoge) { if (flg) { cout << hoge << endl; exit(0); } }
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) { o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o; }
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; }
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) { o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o; }
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) { o << "{" << obj.first << ", " << obj.second << "}"; return o; }
template <template <class tmp> class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; }
void print(void) { cout << endl; }
template <class Head> void print(Head&& head) { cout << head; print(); }
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) { cout << head << " "; print(forward<Tail>(tail)...); }
void YN(bool flg) { cout << ((flg) ? "YES" : "NO") << endl; }
void Yn(bool flg) { cout << ((flg) ? "Yes" : "No") << endl; }
void yn(bool flg) { cout << ((flg) ? "yes" : "no") << endl; }
//Repeat Square Method x^n MOD
long long RSM(long long x, long long n, long long MOD) {
long long y = 1;
for (; n > 0; n >>= 1, (x *= x) %= MOD) if (n & 1) (y *= x) %= MOD;
return y;
}
vector<long long> Factorial(int N, long long mod){
vector<long long> ret(N + 1,1);
for (int i = 1; i < N + 1; ++i) (ret[i] *= (i*ret[i - 1]) %mod) %= mod;
return ret;
}
vector<vector<long long>> Permutation(int N, long long mod) {
vector<long long> fac(N + 1, 1);
for (int i = 1; i < N + 1; ++i) (fac[i] *= (i*fac[i - 1]) % mod) %= mod;
vector<long long> inv(N + 1, 1);
for (int i = 1; i < N + 1; ++i) inv[i] = RSM(fac[i],mod-2,mod);
vector<vector<long long>> ret(N + 1,vector<long long>(N + 1, 1));
for (int i = 1; i < N + 1; ++i) for (int j = 1; j < i; ++j) ret[i][j] = (fac[i] * inv[i - j]) % mod;
return ret;
}
int main() {
ll N, A, B, C, D;
cin >> N >> A >> B >> C >> D;
auto Fact = Factorial(N, MOD);
auto Perm = Permutation(N, MOD);
V<V<ll>> Factk(N + 1, V<ll>(N + 1, 1));
FOR(i, 1, N + 1) FOR(j, 1, N + 1) Factk[i][j] = (Factk[i][j - 1] * Fact[i]) % MOD;
V<V<ll>> dp(N + 1, V<ll>(N + 1, 0));
dp[A-1][0] = 1;
FOR(i,A,B+1){
FOR(j,0,N + 1){
(dp[i][j] += dp[i - 1][j]) %= MOD;
REP(k, D - C + 2) {
if (N - (j - g[k] * i) < 0 || j - g[k] * i < 0) continue;
ll cnt = 1;
(cnt *= dp[i - 1][j - g[k] * i]) %= MOD;
(cnt *= Perm[N - (j - g[k] * i)][g[k] * i]) %= MOD;
(cnt *= RSM(Factk[i][g[k]], MOD - 2, MOD)) %= MOD;
(cnt *= RSM(Fact[g[k]], MOD - 2, MOD)) %= MOD;
(dp[i][j] += cnt) %= MOD;
}
}
}
ll ans = dp[B][N];
REP(i, B + 1) print("dp",i, dp[i]);
print("k", g);
print("Fact", Fact);
REP(i, N)print("PErm",i,Perm[i]);
REP(i, N)print("Factk",i,Factk[i]);
cout << ans << endl;
cin >> N;
return 0;
} | a.cc: In function 'int main()':
a.cc:88:46: error: 'g' was not declared in this scope
88 | if (N - (j - g[k] * i) < 0 || j - g[k] * i < 0) continue;
| ^
a.cc:90:55: error: 'g' was not declared in this scope
90 | (cnt *= dp[i - 1][j - g[k] * i]) %= MOD;
| ^
a.cc:101:20: error: 'g' was not declared in this scope
101 | print("k", g);
| ^
|
s931968010 | p03832 | C++ | //セグフォは関数内で要素のでかい配列を定義しているから
//todo idef DEBUGで、境界チェック付きのvectorを作りたい
//http://marycore.jp/prog/cpp/class-extension-methods/
//現状ifdef DEBUG が何故か動かないので出来ない
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define double long double
struct initon {
initon() {
cin.tie(0);
ios::sync_with_stdio(false);
cout.setf(ios::fixed);
cout.precision(16);
};
} hoee;
namespace std {
template<> class hash<std::pair<signed, signed>> {
public:
size_t operator()(const std::pair<signed, signed> &x) const {
return hash<ll>()(((ll) x.first << 32) + x.second);
}
};
template<> class hash<std::pair<ll, ll>> {
public:
size_t operator()(const std::pair<ll, ll> &x) const {
return hash<ll>()(((ll) x.first << 32) + x.second);
}
};
}
struct Tri {
int f, s, t;
Tri() {
f = -1, s = -1, t = -1;
}
Tri(int f, int s, int t) : f(f), s(s), t(t) {}
bool operator<(const Tri &r) const {
return f != r.f ? f < r.f : s != r.s ? s < r.s : t < r.t;
//return f != r.f ? f > r.f : s != r.s ? s > r.s : t > r.t; 大きい順
}
int operator[](int i) {
assert(i < 3);
switch (i) {
case 0:
return f;
break;
case 1:
return s;
break;
default:
return t;
break;
}
}
};
//別名
#define ull unsigned long long
#define vec vector
#define con continue
#define bre break
#define brk break
#define is ==
#define eq ==
#define no !=
#define ne !=
#define dif !=
#define df !=
#define rs resize
#define PQ priority_queue<ll, vector<ll>, greater<ll> >
using vi = vector<int>;
#define vvi(a, b, c) vec<vi> a(b,vi(c))
using vb = vector<bool>;
#define vvb(a, b, c) vec<vb> a(b,vb(c))
using vs = vector<string>;
#define vvs(a, b, c) vec<vs> a(b,vs(c))
using vl = vector<ll>;
#define vvl(a, b, c) vec<vl> a(b,vl(c))
using vc=vector<char>;
#define vvc(a, b, c) vec<vc> a(b,vc(c))
using P = pair<int, int>;
//using T = tuple<int, int, int>;
using vp = vector<P>;
#define vvp(a, b, c) vec<vp> a(b,vp(c))
using vt = vector<Tri>;
#define vvt(a, b, c) vec<vt> a(b,vt(c))
using dou = double;
using itn = int;
using str = string;
using bo= bool;
#define uset unordered_set
#define umap unordered_map
#define F first
#define S second
//定数
#define k4 10101
#define k5 101010
#define k6 1010101
#define k7 10101010
const int INF = (int) 1e9 + 100;
const ll LINF = (ll) 1e18 + 100;
const double EPS = 1e-9;
const int y4[] = {-1, 1, 0, 0};
const int x4[] = {0, 0, -1, 1};
const int y8[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int x8[] = {1, 0, -1, 0, 1, -1, 1, -1};
//配列
#define sz(a) (sizeof(a)/sizeof(a[0]))
//コンテナ
#define mp make_pair
#define pb push_back
#define pf push_front
#define eb emplace_back
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
template<class T> inline void sort(vector<T> &a) { sort(a.begin(), a.end()); };
template<class T> inline void rsort(vector<T> &a) { sort(a.begin(), a.end(), greater<T>()); };
template<class T> inline void sort(vector<T> &a, int len) { sort(a.begin(), a.begin() + len); };
template<class T> inline void rsort(vector<T> &a, int len) { sort(a.begin(), a.begin() + len, greater<T>()); };
//繰り返し
#define _overloadrep(_1, _2, _3, name, ...) name
# define _rep(i, n) for(int i = 0; i < n ; i++)
#define repi(i, m, n) for(int i = m; i < n ; i++)
#define rep(...) _overloadrep(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rer(i, n) for(int i = n; i >= 0 ; i--)
#define reri(i, m, n) for(int i = m; i >= n ; i--)
#define rer(...) _overloadrep(__VA_ARGS__,reri,_rer,)(__VA_ARGS__)
#define fora(a, b) for(auto&& a : b)
#define forr(a, b) for_each(map.rbegin(),map.rend(),[](auto&& a)
#define rea(a, b) for(auto&& a : b)
#define repa(a, b) for(auto&& a : b)
template<typename A, size_t N, typename T> void fill(A (&a)[N], const T &v) {
rep(i, N)a[i] = v;
}
template<typename A, size_t N, size_t O, typename T> void fill(A (&a)[N][O], const T &v) {
rep(i, N)rep(j, O)a[i][j] = v;
}
template<typename A, size_t N, size_t O, size_t P, typename T> void fill(A (&a)[N][O][P], const T &v) {
rep(i, N)rep(j, O)rep(k, P)a[i][j][k] = v;
}
template<typename A, size_t N, size_t O, size_t P, size_t Q, typename T> void fill(A (&a)[N][O][P][Q], const T &v) {
rep(i, N)rep(j, O)rep(k, P)rep(l, Q)a[i][j][k][l] = v;
}
template<typename A, size_t N, size_t O, size_t P, size_t Q, size_t R, typename T> void fill(A (&a)[N][O][P][Q][R], const T &v) {
rep(i, N)rep(j, O)rep(k, P)rep(l, Q)rep(m, R)a[i][j][k][l][m] = v;
}
template<typename A, size_t N, size_t O, size_t P, size_t Q, size_t R, size_t S, typename T> void fill(A (&a)[N][O][P][Q][R][S], const T &v) {
rep(i, N)rep(j, O)rep(k, P)rep(l, Q)rep(m, R)rep(n, S)a[i][j][k][l][m][n] = v;
}
template<class T, class U> void fill(vector<T> &a, U v) {
rep(i, a.size())a[i] = v;
}
template<class T, class U> void fill(vector<vector<T>> &a, U v) {
rep(i, a.size())rep(j, a[0].size())a[i][j] = v;
}
template<class T, class U> void fill(vector<vector<vector<T>>> &a, U v) {
rep(i, a.size())rep(j, a[0].size())rep(k, a[0][0].size())a[i][j][k] = v;
}
#define arcpy(a, b) memcpy(a,b,sizeof(b))
//入力
template<typename T = int> T in() {
T x;
cin >> x;
return (x);
}
string sin() { return in<string>(); }
double din() { return in<double>(); }
ll lin() { return in<ll>(); }
#define na(a, n) rep(i,n) cin >> a[i];
#define nad(a, n) rep(i,n) cin >> a[i], a[i]--;
#define na3(a, b, c, n) rep(i, n)cin >> a[i] >> b[i] >> c[i];
#define add2(a, b, n) rep(i, n)a.pb(in()),b.pb(in());
#define add2d(a, b, n) rep(i, n)a.pb(in()-1),b.pb(in()-1);
#define add3(a, b, c, n) rep(i, n)a.pb(in()),b.pb(in()),c.pb(in());
#define add3d(a, b, c, n) rep(i, n)a.pb(in()-1),b.pb(in()-1),c.pb(in());
#define na2(a, b, n) rep(i, n)cin >> a[i] >> b[i];
#define nt(a, h, w) rep(hi,h)rep(wi,w) cin >> a[hi][wi];
#define ntd(a, h, w) rep(hi,h)rep(wi,w) cin >> a[hi][wi], a[hi][wi]--;
#define ntp(a, h, w) fill(a,'#');rep(hi,1,h+1)rep(wi,1,w+1) cin >> a[hi][wi];
#define addAll(a, n) rep(i,n) a.pb(in());
#define addAlld(a, n) rep(i,n) a.pb(in()-1);
//出力
template<class T> void out(T x) {
if (typeid(x) == typeid(double))cout << fixed << setprecision(10) << x << endl;
else cout << x << endl;
}
//デバッグ
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';
// 境界チェック付きvector
namespace std_vector_bounds_checking {
using namespace std;
template<class T, class A = std::allocator<T>> struct vector : std::vector<T, A> {
using std::vector<T, A>::vector;
typename std::vector<T>::reference operator[](typename std::vector<T>::size_type n) {
return this->at(n);
}
};
}
//よく使うクラス、構造体
class UnionFind {
public:
vi par, rank, sizes;
int n, trees;
UnionFind(int n) : n(n), trees(n) {
par.resize(n), rank.resize(n), sizes.resize(n);
rep(i, n)par[i] = i, sizes[i] = 1;
}
int root(int x) {
if (par[x] == x)return x;
else return par[x] = root(par[x]);
}
void unite(int x, int y) {
x = root(x);
y = root(y);
if (x == y)return;
if (rank[x] < rank[y])swap(x, y);
trees--;
par[y] = x;
sizes[x] += sizes[y];
if (rank[x] == rank[y])rank[x]++;
}
bool same(int x, int y) { return root(x) == root(y); }
int size(int x) { return sizes[root(x)]; }
//順不同 umapなので
vec<vi> sets() {
vec<vi> res(trees);
umap<int, vi> map;
rep(i, n) map[root(i)].push_back(i);
int i = 0;
for (auto &&p:map) {
int r = p.F;
res[i].push_back(r);
for (auto &&v:p.S) {
if (r == v)continue;
res[i].push_back(v);
}
i++;
}
return res;
}
};
//MOD関連
ll MOD = (int) 1e9 + 7;
int mpow(int v, ll a) {
ll x = v, n = a, res = 1;
while (n) {
if (n & 1)res = (res * x) % MOD;
x = (x * x) % MOD;
n >>= 1;
}
return res;
}
class mint {
private:
ll v;
public:
static ll mod(ll a) { return (a % MOD + MOD) % MOD; }
mint(ll a = 0) { this->v = mod(a); };
mint(const mint &a) { v = a.v; }
mint operator+(const mint &a) { return mint(v + a.v); }
mint operator+(const ll a) { return mint(v + a % MOD); }
mint operator+(const signed a) { return mint(v + a % MOD); }
friend mint operator+(const ll a, const mint &b) { return mint(a % MOD + b.v); }
void operator+=(const mint &a) { v = (v + a.v) % MOD; }
void operator+=(const ll a) { v = mod(v + a % MOD); }
void operator+=(const signed a) { v = mod(v + a % MOD); }
friend void operator+=(ll &a, const mint &b) { a = mod(a % MOD + b.v); }
mint operator-(const mint &a) { return mint(v - a.v); }
mint operator-(const ll a) { return mint(v - a % MOD); }
mint operator-(const signed a) { return mint(v - a % MOD); }
friend mint operator-(const ll a, const mint &b) { return mint(a % MOD - b.v); }
void operator-=(const mint &a) { v = mod(v - a.v); }
void operator-=(const ll a) { v = mod(v - a % MOD); }
void operator-=(const signed a) { v = mod(v - a % MOD); }
friend void operator-=(ll &a, const mint &b) { a = mod(a % MOD - b.v); }
mint operator*(const mint &a) { return mint(v * a.v); }
mint operator*(const ll a) { return mint(v * (a % MOD)); }
mint operator*(const signed a) { return mint(v * (a % MOD)); }
friend mint operator*(const ll a, const mint &b) { return mint(a % MOD * b.v); }
void operator*=(const mint &a) { v = (v * a.v) % MOD; }
void operator*=(const ll a) { v = mod(v * (a % MOD)); }
void operator*=(const signed a) { v = mod(v * (a % MOD)); }
friend void operator*=(ll &a, const mint &b) { a = mod(a % MOD * b.v); }
mint operator/(const mint &a);
mint operator/(const ll a);
mint operator/(const signed a);
friend mint operator/(const ll a, const mint &b);
void operator/=(const mint &a);
void operator/=(const ll a);
void operator/=(const signed a);
friend void operator/=(ll &a, const mint &b);
mint operator^(const mint &a) { return mpow(v, a.v); };
mint operator^(const ll a) { return mpow(v, a); };
mint operator^(const signed a) { return mpow(v, a); };
friend mint operator^(const ll a, const mint &b) { return mpow(a, b.v); };
void operator^=(const mint &a) { v = mpow(v, a.v); }
void operator^=(const ll a) { v = mpow(v, a); }
void operator^=(const signed a) { v = mpow(v, a); }
//単項演算子
mint operator+() { return *this; }
mint operator++() {
v++;
return *this;
}
mint operator++(signed d) {
mint res = *this;
v++;
return res;
}
mint operator-() { return operator*(-1); }
mint operator--() {
v++;
return *this;
}
void operator--(signed d) {
mint res = *this;
v++;
}
bool operator==(mint &a) {
return v == a.v;
}
bool operator==(signed a) {
return v == a;
}
friend bool operator==(signed a, mint &b) {
return a == b.v;
}
bool operator!=(mint &a) {
return v != a.v;
}
bool operator!=(signed a) {
return v != a;
}
friend bool operator!=(signed a, mint &b) {
return a != b.v;
}
operator int() { return v; }
};
const int setModMax = 510000;
mint fac[setModMax], finv[setModMax], inv[setModMax];
void setMod() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < setModMax; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
mint minv(ll a) {
if (fac[0] == 0)setMod();
if (a < setModMax) return inv[a];
a %= MOD;
ll b = MOD, x = 1, y = 0;
while (b) {
ll t = a / b;
a -= t * b;
swap(a, b);
x -= t * y;
swap(x, y);
}
return (x % MOD + MOD) % MOD;
}
mint mint::operator/(const mint &a) { return mint(v * minv(a.v)); }
mint mint::operator/(const ll a) { return mint(v * minv(a)); }
mint mint::operator/(const signed a) { return mint(v * minv(a)); }
mint operator/(const ll a, const mint &b) { return mint(a % MOD * minv(b.v)); }
void mint::operator/=(const mint &a) { v = (v * minv(a.v)) % MOD; }
void mint::operator/=(const ll a) { v = mod(v * minv(a)); }
void mint::operator/=(const signed a) { v = mod(v * minv(a)); }
void operator/=(ll &a, const mint &b) { a = mint::mod(a % MOD * minv(b.v)); }
using vm=vector<mint>;
#define vvm(a, b, c) vec<vm> a(b,vm(c))
bool isPrime[4010101];
vi primes;
void setPrime() {
fill(isPrime, true);
isPrime[0] = isPrime[1] = false;
for (int i = 2; i <= sqrt(sz(isPrime)) + 5; ++i) {
if (!isPrime[i])continue;
for (int j = 2; i * j < sz(isPrime); ++j) {
isPrime[i * j] = false;
}
}
rep(i, sz(isPrime))if (isPrime[i])primes.pb(i);
}
mint com(ll n, ll r) {
if (n < r || n < 0 || r < 0)return 0;
if (fac[0] == 0)setMod();
return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}
//便利関数
bool equal(double a, double b) {
return fabs(a - b) < EPS;
}
ll reverse(ll a) {
ll res = 0;
while (a) {
res *= 10;
res += a % 10;
a /= 10;
}
return res;
}
ll ceil(ll a, ll b) {
return (a + b - 1) / b;
}
ll sqrt(ll a) {
ll res = (ll) std::sqrt(a);
while (res * res < a)res++;
return res;
}
double log(double e, double x) {
return log(x) / log(e);
}
ll sig(ll t) { return (1 + t) * t / 2; }
ll sig(ll s, ll t) { return (s + t) * (t - s + 1) / 2; }
vi divisors(int v) {
vi res;
for (int i = 1; i <= sqrt(v); ++i) {
if (v % i == 0) {
res.pb(i);
if (i != v / i)res.pb(v / i);
}
}
return res;
}
vi factorization(int v) {
int tv = v;
vi res;
if (!isPrime[2])setPrime();
for (auto &&p :primes) {
if (v % p == 0)res.push_back(p);
while (v % p == 0) {
v /= p;
}
if (v == 1 || p * p > tv)break;
}
if (v > 1)res.pb(v);
return res;
}
unordered_map<int, int> factorizationMap(int v) {
int tv = v;
unordered_map<int, int> res;
if (!isPrime[2])setPrime();
for (auto &&p :primes) {
while (v % p == 0) {
res[p]++;
v /= p;
}
if (v == 1 || p * p > tv)break;
}
if (v > 1)res[v]++;
return res;
}
int get(int a, int keta) {
a /= (int) pow(10, keta);
return a % 10;
}
//変換系
template<class T, class U> vector<U> keys(map<T, U> a) {
vector<U> res;
for (auto &&k :a)res.pb(k.F);
return res;
}
template<class T, class U> vector<U> keys(umap<T, U> a) {
vector<U> res;
for (auto &&k :a)res.pb(k.F);
return res;
}
template<class T, class U> vector<T> values(map<T, U> a) {
vector<T> res;
for (auto &&k :a)res.pb(k.S);
return res;
}
template<class T, class U> vector<T> values(umap<T, U> a) {
vector<T> res;
for (auto &&k :a)res.pb(k.S);
return res;
}
vi list(int a) {
vi res;
while (a) {
res.insert(res.begin(), a % 10);
a /= 10;
}
return res;
}
template<class T, class U> bool chmax(T &a, const U &b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template<class T, class U> bool chmin(T &a, const U &b) {
if (b < a) {
a = b;
return true;
}
return false;
}
template<class T> T min(T a, signed b) {
return a < b ? a : b;
}
template<class T> T max(T a, signed b) {
return a < b ? b : a;
}
template<class T> T min(vector<T> a) {
return *min_element(all(a));
}
template<class T> T max(vector<T> a) {
return *max_element(all(a));
}
template<class T> T min(T a[]) {
T res = a[0];
rep(i, sz(a))chmin(res, a[i]);
return res;
}
template<class T> T max(T a[]) {
T res = a[0];
rep(i, sz(a))chmax(res, a[i]);
return res;
}
template<class T> T sum(vector<T> &v, int len = -1) {
if (len == -1)len = v.size();
T res = 0;
rep(i, min((int) len, (int) v.size()))res += v[i];
return res;
}
///要素が0の時、返り値は0か1か
template<class T> T mul(vector<T> &v, int len = -1) {
if (len == -1)len = v.size();
T res = 1;
rep(i, min((int) len, (int) v.size()))res *= v[i];
return res;
}
void clear(PQ &q) {
while (q.size())q.pop();
}
template<class T> void clear(queue<T> &q) {
while (q.size())q.pop();
}
template<class T> vector<T> ruiv(vector<T> &a) {
vector<T> res(a.size() + 1);
rep(i, a.size())res[i + 1] = res[i] + a[i];
return res;
}
template<class T> void plus(vector<T> &a, T v = 1) {
for (auto &&u :a)u += v;
}
template<class T> void minu(vector<T> &a, T v = 1) {
for (auto &&u :a)u -= v;
}
template<class T> void minus(vector<T> &a, T v = 1) {
for (auto &&u :a)u -= v;
}
inline bool inside(int y, int x, int H, int W) { return y >= 0 && x >= 0 && y < H && x < W; }
ll u(ll a) { return a < 0 ? 0 : a; }
#define inc(s, x, t) s<=x&&x<t
#define MIN(a) numeric_limits<a>::min()
#define MAX(a) numeric_limits<a>::max()
template<class T> T min(vector<vector<T>> &a) {
T res = MAX(T);
rep(i, a.size())chmin(res, *min_element(all(a[i])));
return res;
}
template<class T> T max(vector<vector<T>> &a) {
T res = MIN(T);
rep(i, a.size())chmax(res, *max_element(all(a[i])));
return res;
}
bool bget(ll m, int keta) {
return (m >> keta) & 1;
}
int bget(ll m, int keta, int sinsuu) {
m /= (ll) pow(sinsuu, keta);
return m % sinsuu;
}
inline ll bit(int n) {
return (1LL << (n));
}
inline ll bit(int n, int sinsuu) {
return (ll) pow(sinsuu, n);
}
int bcou(ll m) {
return __builtin_popcount(m & 0xFFFFFFFF) + __builtin_popcount(m >> 32);
}
//初期化は0を渡す
ll nextComb(ll &mask, int n, int r) {
if (!mask)return mask = (1LL << r) - 1;
ll x = mask & -mask; //最下位の1
ll y = mask + x; //連続した下の1を繰り上がらせる
ll res = ((mask & ~y) / x >> 1) | y;
if (bget(res, n))return mask = 0;
else return mask = res;
}
//n桁以下でビットがr個立っているもののvectorを返す
vl bitCombList(int n, int r) {
vl res;
int m = 0;
while (nextComb(m, n, r)) {
res.pb(m);
}
return res;
}
int ctoi(char c) {
if ('A' <= c && c <= 'Z')return c - 'A';
return c - 'a' + 26;
}
char itoc(int i) {
if (i < 26)return 'A' + i;
return 'a' + i - 26;
}
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
void compress(vi &a) {
vi b;
int len = a.size();
for (int i = 0; i < len; ++i) {
b.push_back(a[i]);
}
sort(b);
UNIQUE(b);
for (int i = 0; i < len; ++i) {
a[i] = lower_bound(all(b), a[i]) - b.begin();
}
}
void compress(int a[], int len) {
vi b;
for (int i = 0; i < len; ++i) {
b.push_back(a[i]);
}
sort(b);
UNIQUE(b);
for (int i = 0; i < len; ++i) {
a[i] = lower_bound(all(b), a[i]) - b.begin();
}
}
//要素が見つからなかったときに困る
#define lowerIndex(a, v) (lower_bound(a,v)-a.begin())
#define lowerBound(a, v) (*lower_bound(all(a),v))
#define upperIndex(a, v) (upper_bound(a,v)-a.begin())
#define upperBound(a, v) (*upper_bound(all(a),v))
#define ans(a) cout<<a<<endl;continue;
#define poll(a) q.front();q.pop()
#define dpoll(a) q.front();q.pop_front()
#define pollLast(a) q.back();q.pop_back()
#define pollBack(a) q.back();q.pop_back()
template<class T> inline void fin(T s) { cout << s << endl, exit(0); }
template<class T> struct edge {
int from, to;
T cost;
int id;
int type;
edge(int f, int t, T c = 1, int id = -1, int ty = -1) : from(f), to(t), cost(c), id(id), type(ty) {}
bool operator<(const edge &b) const {
return cost < b.cost;
}
bool operator>(const edge &b) const {
return cost > b.cost;
}
};
template<typename T> class graph {
protected:
vector<bool> _used;
public :
vector<vector<edge<T>>> g;
vector<edge<T>> edges;
int n;
graph(int n) : n(n) {
g.resize(n);
_used.resize(n);
}
void clear() {
g.clear();
edges.clear();
}
void resize(int n) {
this->n = n;
g.resize(n);
_used.resize(n);
}
bool isleaf(int v, int r) {
return g[v].size() == 1 && g[v][0].to == r;
}
T operator[](int i) {
return g[i];
}
virtual void add(int from, int to, T cost, int ty) = 0;
virtual bool used(edge<T> &e) = 0;
virtual bool used(int id) = 0;
virtual void del(edge<T> &e) = 0;
virtual void del(int id) = 0;
};
template<class T=int> class undigraph : public graph<T> {
public:
using graph<T>::g;
using graph<T>::n;
using graph<T>::edges;
using graph<T>::_used;
undigraph(int n) : graph<T>(n) {
}
void add(int f, int t, T cost = 1, int ty = -1) {
assert(0 <= f && f < n && 0 <= t && t < n);
int id = edges.size();
g[f].emplace_back(f, t, cost, id, ty);
g[t].emplace_back(t, f, cost, id + 1, ty);
edges.emplace_back(f, t, cost, id, ty);
edges.emplace_back(t, f, cost, id + 1, ty);
}
void add(edge<T> &e) {
int f = e.from, t = e.to, ty = e.type;
T cost = e.cost;
add(f, t, cost, ty);
}
bool used(edge<T> &e) {
return _used[e.id];
}
bool used(int id) {
return _used[id];
}
void del(edge<T> &e) {
_used[e.id] = _used[e.id ^ 1] = 1;
}
void del(int id) {
_used[id] = _used[id ^ 1] = 1;
}
};
template<typename T =ll> class digraph : public graph<T> {
public:
using graph<T>::g;
using graph<T>::n;
using graph<T>::edges;
using graph<T>::_used;
digraph(int n) : graph<T>(n) {
}
void add(int f, int t, T cost = 1, int ty = -1) {
assert(0 <= f && f < n && 0 <= t && t < n);
int id = edges.size();
g[f].emplace_back(t, cost, ty, id);
edges.emplace_back(f, t, cost, ty, id);
}
bool used(edge<T> &e) {
return _used[e.id];
}
bool used(int id) {
return _used[id];
}
void del(edge<T> &e) {
_used[e.id] = _used[e.id ^ 1] = 1;
}
void del(int id) {
_used[id] = _used[id ^ 1] = 1;
}
};
template<class T> bool nibu(const graph<T> &g) {
UnionFind uf(g.n * 2);
for (auto &&e :g.edges)uf.unite(e.f, e.t + g.n), uf.unite(e.f + g.n, e.t);
return !uf.same(0, g.n);
}
template<class T> vector<T> dijkstra(const graph<T> &g, int s) {
assert(inc(0, s, g.n));
T initValue = MAX(T);
vector<T> dis(g.n, initValue);
priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T, int>>> q;
dis[s] = 0;
q.emplace(0, s);
while (q.size()) {
T nowc = q.top().F;
int i = q.top().S;
q.pop();
if (dis[i] != nowc)continue;
for (auto &&e : g.g[i]) {
int to = e.to;
T cost = nowc + e.cost;
if (dis[to] > cost) {
dis[to] = cost;
q.emplace(dis[to], to);
}
}
}
//たどり着かないなら-1
for (auto &&d :dis) if (d == initValue)d = -1;
return dis;
}
//機能拡張
template<typename T> void remove(vector<T> &v, unsigned int i) { v.erase(v.begin() + i); }
template<typename T> void remove(vector<T> &v, unsigned int s, unsigned int e) {
v.erase(v.begin() + s, v.begin() + e);
}
template<typename T> void removen(vector<T> &v, unsigned int s, unsigned int n) {
v.erase(v.begin() + s, v.begin() + s + n);
}
template<typename T> void erase(vector<T> &v, unsigned int i) { v.erase(v.begin() + i); }
template<typename T> void erase(vector<T> &v, unsigned int s, unsigned int e) {
v.erase(v.begin() + s, v.begin() + e);
}
template<typename T> void erasen(vector<T> &v, unsigned int s, unsigned int n) {
v.erase(v.begin() + s, v.begin() + s + n);
}
template<typename T> void insert(vector<T> &v, unsigned int i, T t) { v.insert(v.begin() + i, t); }
template<typename T> void insert(vector<T> &v, unsigned int i, vector<T> list) {
for (auto &&va :list)v.insert(v.begin() + i++, va);
}
template<typename T> void insert(vector<T> &v, unsigned int i, initializer_list<T> list) {
for (auto &&va :list)v.insert(v.begin() + i++, va);
}
int mod(int a, int m) {
return (a % m + m) % m;
}
ll ma = numeric_limits<ll>::min();
ll mi = numeric_limits<ll>::max();
int N, K, M, H, W, q, Q, r, cou;
vi A, B, C;
signed main() {
int a, b, c, d;
cin >> N >> a >> b >> c >> d;
setMod();
vvm(dp, 1010, 1010); //dp[i][j] i人未満で残りj人までした
dp[0][N] = 1;
rep(i, N + 1) {
rep(r, N + 1) {
dp[i + 1][r] += dp[i][r];
if (!(a <= i && i <= b))con;
mint comb = 1;
int nr = r;
for (int g = 1; nr - i >= 0; ++g) {
comb *= com(nr, i);
comb /= g;
if (c <= g && g <= d)dp[i + 1][nr - i] += dp[i][r] * comb;
nr -= i;
}
}//セグフォは関数内で要素のでかい配列を定義しているから
//todo idef DEBUGで、境界チェック付きのvectorを作りたい
//http://marycore.jp/prog/cpp/class-extension-methods/
//現状ifdef DEBUG が何故か動かないので出来ない
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define double long double
struct initon {
initon() {
cin.tie(0);
ios::sync_with_stdio(false);
cout.setf(ios::fixed);
cout.precision(16);
};
} hoee;
namespace std {
template<> class hash<std::pair<signed, signed>> {
public:
size_t operator()(const std::pair<signed, signed> &x) const {
return hash<ll>()(((ll) x.first << 32) + x.second);
}
};
template<> class hash<std::pair<ll, ll>> {
public:
size_t operator()(const std::pair<ll, ll> &x) const {
return hash<ll>()(((ll) x.first << 32) + x.second);
}
};
}
struct Tri {
int f, s, t;
Tri() {
f = -1, s = -1, t = -1;
}
Tri(int f, int s, int t) : f(f), s(s), t(t) {}
bool operator<(const Tri &r) const {
return f != r.f ? f < r.f : s != r.s ? s < r.s : t < r.t;
//return f != r.f ? f > r.f : s != r.s ? s > r.s : t > r.t; 大きい順
}
int operator[](int i) {
assert(i < 3);
switch (i) {
case 0:
return f;
break;
case 1:
return s;
break;
default:
return t;
break;
}
}
};
//別名
#define ull unsigned long long
#define vec vector
#define con continue
#define bre break
#define brk break
#define is ==
#define eq ==
#define no !=
#define ne !=
#define dif !=
#define df !=
#define rs resize
#define PQ priority_queue<ll, vector<ll>, greater<ll> >
using vi = vector<int>;
#define vvi(a, b, c) vec<vi> a(b,vi(c))
using vb = vector<bool>;
#define vvb(a, b, c) vec<vb> a(b,vb(c))
using vs = vector<string>;
#define vvs(a, b, c) vec<vs> a(b,vs(c))
using vl = vector<ll>;
#define vvl(a, b, c) vec<vl> a(b,vl(c))
using vc=vector<char>;
#define vvc(a, b, c) vec<vc> a(b,vc(c))
using P = pair<int, int>;
//using T = tuple<int, int, int>;
using vp = vector<P>;
#define vvp(a, b, c) vec<vp> a(b,vp(c))
using vt = vector<Tri>;
#define vvt(a, b, c) vec<vt> a(b,vt(c))
using dou = double;
using itn = int;
using str = string;
using bo= bool;
#define uset unordered_set
#define umap unordered_map
#define F first
#define S second
//定数
#define k4 10101
#define k5 101010
#define k6 1010101
#define k7 10101010
const int INF = (int) 1e9 + 100;
const ll LINF = (ll) 1e18 + 100;
const double EPS = 1e-9;
const int y4[] = {-1, 1, 0, 0};
const int x4[] = {0, 0, -1, 1};
const int y8[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int x8[] = {1, 0, -1, 0, 1, -1, 1, -1};
//配列
#define sz(a) (sizeof(a)/sizeof(a[0]))
//コンテナ
#define mp make_pair
#define pb push_back
#define pf push_front
#define eb emplace_back
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
template<class T> inline void sort(vector<T> &a) { sort(a.begin(), a.end()); };
template<class T> inline void rsort(vector<T> &a) { sort(a.begin(), a.end(), greater<T>()); };
template<class T> inline void sort(vector<T> &a, int len) { sort(a.begin(), a.begin() + len); };
template<class T> inline void rsort(vector<T> &a, int len) { sort(a.begin(), a.begin() + len, greater<T>()); };
//繰り返し
#define _overloadrep(_1, _2, _3, name, ...) name
# define _rep(i, n) for(int i = 0; i < n ; i++)
#define repi(i, m, n) for(int i = m; i < n ; i++)
#define rep(...) _overloadrep(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rer(i, n) for(int i = n; i >= 0 ; i--)
#define reri(i, m, n) for(int i = m; i >= n ; i--)
#define rer(...) _overloadrep(__VA_ARGS__,reri,_rer,)(__VA_ARGS__)
#define fora(a, b) for(auto&& a : b)
#define forr(a, b) for_each(map.rbegin(),map.rend(),[](auto&& a)
#define rea(a, b) for(auto&& a : b)
#define repa(a, b) for(auto&& a : b)
template<typename A, size_t N, typename T> void fill(A (&a)[N], const T &v) {
rep(i, N)a[i] = v;
}
template<typename A, size_t N, size_t O, typename T> void fill(A (&a)[N][O], const T &v) {
rep(i, N)rep(j, O)a[i][j] = v;
}
template<typename A, size_t N, size_t O, size_t P, typename T> void fill(A (&a)[N][O][P], const T &v) {
rep(i, N)rep(j, O)rep(k, P)a[i][j][k] = v;
}
template<typename A, size_t N, size_t O, size_t P, size_t Q, typename T> void fill(A (&a)[N][O][P][Q], const T &v) {
rep(i, N)rep(j, O)rep(k, P)rep(l, Q)a[i][j][k][l] = v;
}
template<typename A, size_t N, size_t O, size_t P, size_t Q, size_t R, typename T> void fill(A (&a)[N][O][P][Q][R], const T &v) {
rep(i, N)rep(j, O)rep(k, P)rep(l, Q)rep(m, R)a[i][j][k][l][m] = v;
}
template<typename A, size_t N, size_t O, size_t P, size_t Q, size_t R, size_t S, typename T> void fill(A (&a)[N][O][P][Q][R][S], const T &v) {
rep(i, N)rep(j, O)rep(k, P)rep(l, Q)rep(m, R)rep(n, S)a[i][j][k][l][m][n] = v;
}
template<class T, class U> void fill(vector<T> &a, U v) {
rep(i, a.size())a[i] = v;
}
template<class T, class U> void fill(vector<vector<T>> &a, U v) {
rep(i, a.size())rep(j, a[0].size())a[i][j] = v;
}
template<class T, class U> void fill(vector<vector<vector<T>>> &a, U v) {
rep(i, a.size())rep(j, a[0].size())rep(k, a[0][0].size())a[i][j][k] = v;
}
#define arcpy(a, b) memcpy(a,b,sizeof(b))
//入力
template<typename T = int> T in() {
T x;
cin >> x;
return (x);
}
string sin() { return in<string>(); }
double din() { return in<double>(); }
ll lin() { return in<ll>(); }
#define na(a, n) rep(i,n) cin >> a[i];
#define nad(a, n) rep(i,n) cin >> a[i], a[i]--;
#define na3(a, b, c, n) rep(i, n)cin >> a[i] >> b[i] >> c[i];
#define add2(a, b, n) rep(i, n)a.pb(in()),b.pb(in());
#define add2d(a, b, n) rep(i, n)a.pb(in()-1),b.pb(in()-1);
#define add3(a, b, c, n) rep(i, n)a.pb(in()),b.pb(in()),c.pb(in());
#define add3d(a, b, c, n) rep(i, n)a.pb(in()-1),b.pb(in()-1),c.pb(in());
#define na2(a, b, n) rep(i, n)cin >> a[i] >> b[i];
#define nt(a, h, w) rep(hi,h)rep(wi,w) cin >> a[hi][wi];
#define ntd(a, h, w) rep(hi,h)rep(wi,w) cin >> a[hi][wi], a[hi][wi]--;
#define ntp(a, h, w) fill(a,'#');rep(hi,1,h+1)rep(wi,1,w+1) cin >> a[hi][wi];
#define addAll(a, n) rep(i,n) a.pb(in());
#define addAlld(a, n) rep(i,n) a.pb(in()-1);
//出力
template<class T> void out(T x) {
if (typeid(x) == typeid(double))cout << fixed << setprecision(10) << x << endl;
else cout << x << endl;
}
//デバッグ
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';
// 境界チェック付きvector
namespace std_vector_bounds_checking {
using namespace std;
template<class T, class A = std::allocator<T>> struct vector : std::vector<T, A> {
using std::vector<T, A>::vector;
typename std::vector<T>::reference operator[](typename std::vector<T>::size_type n) {
return this->at(n);
}
};
}
//よく使うクラス、構造体
class UnionFind {
public:
vi par, rank, sizes;
int n, trees;
UnionFind(int n) : n(n), trees(n) {
par.resize(n), rank.resize(n), sizes.resize(n);
rep(i, n)par[i] = i, sizes[i] = 1;
}
int root(int x) {
if (par[x] == x)return x;
else return par[x] = root(par[x]);
}
void unite(int x, int y) {
x = root(x);
y = root(y);
if (x == y)return;
if (rank[x] < rank[y])swap(x, y);
trees--;
par[y] = x;
sizes[x] += sizes[y];
if (rank[x] == rank[y])rank[x]++;
}
bool same(int x, int y) { return root(x) == root(y); }
int size(int x) { return sizes[root(x)]; }
//順不同 umapなので
vec<vi> sets() {
vec<vi> res(trees);
umap<int, vi> map;
rep(i, n) map[root(i)].push_back(i);
int i = 0;
for (auto &&p:map) {
int r = p.F;
res[i].push_back(r);
for (auto &&v:p.S) {
if (r == v)continue;
res[i].push_back(v);
}
i++;
}
return res;
}
};
//MOD関連
ll MOD = (int) 1e9 + 7;
int mpow(int v, ll a) {
ll x = v, n = a, res = 1;
while (n) {
if (n & 1)res = (res * x) % MOD;
x = (x * x) % MOD;
n >>= 1;
}
return res;
}
class mint {
private:
ll v;
public:
static ll mod(ll a) { return (a % MOD + MOD) % MOD; }
mint(ll a = 0) { this->v = mod(a); };
mint(const mint &a) { v = a.v; }
mint operator+(const mint &a) { return mint(v + a.v); }
mint operator+(const ll a) { return mint(v + a % MOD); }
mint operator+(const signed a) { return mint(v + a % MOD); }
friend mint operator+(const ll a, const mint &b) { return mint(a % MOD + b.v); }
void operator+=(const mint &a) { v = (v + a.v) % MOD; }
void operator+=(const ll a) { v = mod(v + a % MOD); }
void operator+=(const signed a) { v = mod(v + a % MOD); }
friend void operator+=(ll &a, const mint &b) { a = mod(a % MOD + b.v); }
mint operator-(const mint &a) { return mint(v - a.v); }
mint operator-(const ll a) { return mint(v - a % MOD); }
mint operator-(const signed a) { return mint(v - a % MOD); }
friend mint operator-(const ll a, const mint &b) { return mint(a % MOD - b.v); }
void operator-=(const mint &a) { v = mod(v - a.v); }
void operator-=(const ll a) { v = mod(v - a % MOD); }
void operator-=(const signed a) { v = mod(v - a % MOD); }
friend void operator-=(ll &a, const mint &b) { a = mod(a % MOD - b.v); }
mint operator*(const mint &a) { return mint(v * a.v); }
mint operator*(const ll a) { return mint(v * (a % MOD)); }
mint operator*(const signed a) { return mint(v * (a % MOD)); }
friend mint operator*(const ll a, const mint &b) { return mint(a % MOD * b.v); }
void operator*=(const mint &a) { v = (v * a.v) % MOD; }
void operator*=(const ll a) { v = mod(v * (a % MOD)); }
void operator*=(const signed a) { v = mod(v * (a % MOD)); }
friend void operator*=(ll &a, const mint &b) { a = mod(a % MOD * b.v); }
mint operator/(const mint &a);
mint operator/(const ll a);
mint operator/(const signed a);
friend mint operator/(const ll a, const mint &b);
void operator/=(const mint &a);
void operator/=(const ll a);
void operator/=(const signed a);
friend void operator/=(ll &a, const mint &b);
mint operator^(const mint &a) { return mpow(v, a.v); };
mint operator^(const ll a) { return mpow(v, a); };
mint operator^(const signed a) { return mpow(v, a); };
friend mint operator^(const ll a, const mint &b) { return mpow(a, b.v); };
void operator^=(const mint &a) { v = mpow(v, a.v); }
void operator^=(const ll a) { v = mpow(v, a); }
void operator^=(const signed a) { v = mpow(v, a); }
//単項演算子
mint operator+() { return *this; }
mint operator++() {
v++;
return *this;
}
mint operator++(signed d) {
mint res = *this;
v++;
return res;
}
mint operator-() { return operator*(-1); }
mint operator--() {
v++;
return *this;
}
void operator--(signed d) {
mint res = *this;
v++;
}
bool operator==(mint &a) {
return v == a.v;
}
bool operator==(signed a) {
return v == a;
}
friend bool operator==(signed a, mint &b) {
return a == b.v;
}
bool operator!=(mint &a) {
return v != a.v;
}
bool operator!=(signed a) {
return v != a;
}
friend bool operator!=(signed a, mint &b) {
return a != b.v;
}
operator int() { return v; }
};
const int setModMax = 510000;
mint fac[setModMax], finv[setModMax], inv[setModMax];
void setMod() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < setModMax; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
mint minv(ll a) {
if (fac[0] == 0)setMod();
if (a < setModMax) return inv[a];
a %= MOD;
ll b = MOD, x = 1, y = 0;
while (b) {
ll t = a / b;
a -= t * b;
swap(a, b);
x -= t * y;
swap(x, y);
}
return (x % MOD + MOD) % MOD;
}
mint mint::operator/(const mint &a) { return mint(v * minv(a.v)); }
mint mint::operator/(const ll a) { return mint(v * minv(a)); }
mint mint::operator/(const signed a) { return mint(v * minv(a)); }
mint operator/(const ll a, const mint &b) { return mint(a % MOD * minv(b.v)); }
void mint::operator/=(const mint &a) { v = (v * minv(a.v)) % MOD; }
void mint::operator/=(const ll a) { v = mod(v * minv(a)); }
void mint::operator/=(const signed a) { v = mod(v * minv(a)); }
void operator/=(ll &a, const mint &b) { a = mint::mod(a % MOD * minv(b.v)); }
using vm=vector<mint>;
#define vvm(a, b, c) vec<vm> a(b,vm(c))
bool isPrime[4010101];
vi primes;
void setPrime() {
fill(isPrime, true);
isPrime[0] = isPrime[1] = false;
for (int i = 2; i <= sqrt(sz(isPrime)) + 5; ++i) {
if (!isPrime[i])continue;
for (int j = 2; i * j < sz(isPrime); ++j) {
isPrime[i * j] = false;
}
}
rep(i, sz(isPrime))if (isPrime[i])primes.pb(i);
}
mint com(ll n, ll r) {
if (n < r || n < 0 || r < 0)return 0;
if (fac[0] == 0)setMod();
return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}
//便利関数
bool equal(double a, double b) {
return fabs(a - b) < EPS;
}
ll reverse(ll a) {
ll res = 0;
while (a) {
res *= 10;
res += a % 10;
a /= 10;
}
return res;
}
ll ceil(ll a, ll b) {
return (a + b - 1) / b;
}
ll sqrt(ll a) {
ll res = (ll) std::sqrt(a);
while (res * res < a)res++;
return res;
}
double log(double e, double x) {
return log(x) / log(e);
}
ll sig(ll t) { return (1 + t) * t / 2; }
ll sig(ll s, ll t) { return (s + t) * (t - s + 1) / 2; }
vi divisors(int v) {
vi res;
for (int i = 1; i <= sqrt(v); ++i) {
if (v % i == 0) {
res.pb(i);
if (i != v / i)res.pb(v / i);
}
}
return res;
}
vi factorization(int v) {
int tv = v;
vi res;
if (!isPrime[2])setPrime();
for (auto &&p :primes) {
if (v % p == 0)res.push_back(p);
while (v % p == 0) {
v /= p;
}
if (v == 1 || p * p > tv)break;
}
if (v > 1)res.pb(v);
return res;
}
unordered_map<int, int> factorizationMap(int v) {
int tv = v;
unordered_map<int, int> res;
if (!isPrime[2])setPrime();
for (auto &&p :primes) {
while (v % p == 0) {
res[p]++;
v /= p;
}
if (v == 1 || p * p > tv)break;
}
if (v > 1)res[v]++;
return res;
}
int get(int a, int keta) {
a /= (int) pow(10, keta);
return a % 10;
}
//変換系
template<class T, class U> vector<U> keys(map<T, U> a) {
vector<U> res;
for (auto &&k :a)res.pb(k.F);
return res;
}
template<class T, class U> vector<U> keys(umap<T, U> a) {
vector<U> res;
for (auto &&k :a)res.pb(k.F);
return res;
}
template<class T, class U> vector<T> values(map<T, U> a) {
vector<T> res;
for (auto &&k :a)res.pb(k.S);
return res;
}
template<class T, class U> vector<T> values(umap<T, U> a) {
vector<T> res;
for (auto &&k :a)res.pb(k.S);
return res;
}
vi list(int a) {
vi res;
while (a) {
res.insert(res.begin(), a % 10);
a /= 10;
}
return res;
}
template<class T, class U> bool chmax(T &a, const U &b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template<class T, class U> bool chmin(T &a, const U &b) {
if (b < a) {
a = b;
return true;
}
return false;
}
template<class T> T min(T a, signed b) {
return a < b ? a : b;
}
template<class T> T max(T a, signed b) {
return a < b ? b : a;
}
template<class T> T min(vector<T> a) {
return *min_element(all(a));
}
template<class T> T max(vector<T> a) {
return *max_element(all(a));
}
template<class T> T min(T a[]) {
T res = a[0];
rep(i, sz(a))chmin(res, a[i]);
return res;
}
template<class T> T max(T a[]) {
T res = a[0];
rep(i, sz(a))chmax(res, a[i]);
return res;
}
template<class T> T sum(vector<T> &v, int len = -1) {
if (len == -1)len = v.size();
T res = 0;
rep(i, min((int) len, (int) v.size()))res += v[i];
return res;
}
///要素が0の時、返り値は0か1か
template<class T> T mul(vector<T> &v, int len = -1) {
if (len == -1)len = v.size();
T res = 1;
rep(i, min((int) len, (int) v.size()))res *= v[i];
return res;
}
void clear(PQ &q) {
while (q.size())q.pop();
}
template<class T> void clear(queue<T> &q) {
while (q.size())q.pop();
}
template<class T> vector<T> ruiv(vector<T> &a) {
vector<T> res(a.size() + 1);
rep(i, a.size())res[i + 1] = res[i] + a[i];
return res;
}
template<class T> void plus(vector<T> &a, T v = 1) {
for (auto &&u :a)u += v;
}
template<class T> void minu(vector<T> &a, T v = 1) {
for (auto &&u :a)u -= v;
}
template<class T> void minus(vector<T> &a, T v = 1) {
for (auto &&u :a)u -= v;
}
inline bool inside(int y, int x, int H, int W) { return y >= 0 && x >= 0 && y < H && x < W; }
ll u(ll a) { return a < 0 ? 0 : a; }
#define inc(s, x, t) s<=x&&x<t
#define MIN(a) numeric_limits<a>::min()
#define MAX(a) numeric_limits<a>::max()
template<class T> T min(vector<vector<T>> &a) {
T res = MAX(T);
rep(i, a.size())chmin(res, *min_element(all(a[i])));
return res;
}
template<class T> T max(vector<vector<T>> &a) {
T res = MIN(T);
rep(i, a.size())chmax(res, *max_element(all(a[i])));
return res;
}
bool bget(ll m, int keta) {
return (m >> keta) & 1;
}
int bget(ll m, int keta, int sinsuu) {
m /= (ll) pow(sinsuu, keta);
return m % sinsuu;
}
inline ll bit(int n) {
return (1LL << (n));
}
inline ll bit(int n, int sinsuu) {
return (ll) pow(sinsuu, n);
}
int bcou(ll m) {
return __builtin_popcount(m & 0xFFFFFFFF) + __builtin_popcount(m >> 32);
}
//初期化は0を渡す
ll nextComb(ll &mask, int n, int r) {
if (!mask)return mask = (1LL << r) - 1;
ll x = mask & -mask; //最下位の1
ll y = mask + x; //連続した下の1を繰り上がらせる
ll res = ((mask & ~y) / x >> 1) | y;
if (bget(res, n))return mask = 0;
else return mask = res;
}
//n桁以下でビットがr個立っているもののvectorを返す
vl bitCombList(int n, int r) {
vl res;
int m = 0;
while (nextComb(m, n, r)) {
res.pb(m);
}
return res;
}
int ctoi(char c) {
if ('A' <= c && c <= 'Z')return c - 'A';
return c - 'a' + 26;
}
char itoc(int i) {
if (i < 26)return 'A' + i;
return 'a' + i - 26;
}
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
void compress(vi &a) {
vi b;
int len = a.size();
for (int i = 0; i < len; ++i) {
b.push_back(a[i]);
}
sort(b);
UNIQUE(b);
for (int i = 0; i < len; ++i) {
a[i] = lower_bound(all(b), a[i]) - b.begin();
}
}
void compress(int a[], int len) {
vi b;
for (int i = 0; i < len; ++i) {
b.push_back(a[i]);
}
sort(b);
UNIQUE(b);
for (int i = 0; i < len; ++i) {
a[i] = lower_bound(all(b), a[i]) - b.begin();
}
}
//要素が見つからなかったときに困る
#define lowerIndex(a, v) (lower_bound(a,v)-a.begin())
#define lowerBound(a, v) (*lower_bound(all(a),v))
#define upperIndex(a, v) (upper_bound(a,v)-a.begin())
#define upperBound(a, v) (*upper_bound(all(a),v))
#define ans(a) cout<<a<<endl;continue;
#define poll(a) q.front();q.pop()
#define dpoll(a) q.front();q.pop_front()
#define pollLast(a) q.back();q.pop_back()
#define pollBack(a) q.back();q.pop_back()
template<class T> inline void fin(T s) { cout << s << endl, exit(0); }
template<class T> struct edge {
int from, to;
T cost;
int id;
int type;
edge(int f, int t, T c = 1, int id = -1, int ty = -1) : from(f), to(t), cost(c), id(id), type(ty) {}
bool operator<(const edge &b) const {
return cost < b.cost;
}
bool operator>(const edge &b) const {
return cost > b.cost;
}
};
template<typename T> class graph {
protected:
vector<bool> _used;
public :
vector<vector<edge<T>>> g;
vector<edge<T>> edges;
int n;
graph(int n) : n(n) {
g.resize(n);
_used.resize(n);
}
void clear() {
g.clear();
edges.clear();
}
void resize(int n) {
this->n = n;
g.resize(n);
_used.resize(n);
}
bool isleaf(int v, int r) {
return g[v].size() == 1 && g[v][0].to == r;
}
T operator[](int i) {
return g[i];
}
virtual void add(int from, int to, T cost, int ty) = 0;
virtual bool used(edge<T> &e) = 0;
virtual bool used(int id) = 0;
virtual void del(edge<T> &e) = 0;
virtual void del(int id) = 0;
};
template<class T=int> class undigraph : public graph<T> {
public:
using graph<T>::g;
using graph<T>::n;
using graph<T>::edges;
using graph<T>::_used;
undigraph(int n) : graph<T>(n) {
}
void add(int f, int t, T cost = 1, int ty = -1) {
assert(0 <= f && f < n && 0 <= t && t < n);
int id = edges.size();
g[f].emplace_back(f, t, cost, id, ty);
g[t].emplace_back(t, f, cost, id + 1, ty);
edges.emplace_back(f, t, cost, id, ty);
edges.emplace_back(t, f, cost, id + 1, ty);
}
void add(edge<T> &e) {
int f = e.from, t = e.to, ty = e.type;
T cost = e.cost;
add(f, t, cost, ty);
}
bool used(edge<T> &e) {
return _used[e.id];
}
bool used(int id) {
return _used[id];
}
void del(edge<T> &e) {
_used[e.id] = _used[e.id ^ 1] = 1;
}
void del(int id) {
_used[id] = _used[id ^ 1] = 1;
}
};
template<typename T =ll> class digraph : public graph<T> {
public:
using graph<T>::g;
using graph<T>::n;
using graph<T>::edges;
using graph<T>::_used;
digraph(int n) : graph<T>(n) {
}
void add(int f, int t, T cost = 1, int ty = -1) {
assert(0 <= f && f < n && 0 <= t && t < n);
int id = edges.size();
g[f].emplace_back(t, cost, ty, id);
edges.emplace_back(f, t, cost, ty, id);
}
bool used(edge<T> &e) {
return _used[e.id];
}
bool used(int id) {
return _used[id];
}
void del(edge<T> &e) {
_used[e.id] = _used[e.id ^ 1] = 1;
}
void del(int id) {
_used[id] = _used[id ^ 1] = 1;
}
};
template<class T> bool nibu(const graph<T> &g) {
UnionFind uf(g.n * 2);
for (auto &&e :g.edges)uf.unite(e.f, e.t + g.n), uf.unite(e.f + g.n, e.t);
return !uf.same(0, g.n);
}
template<class T> vector<T> dijkstra(const graph<T> &g, int s) {
assert(inc(0, s, g.n));
T initValue = MAX(T);
vector<T> dis(g.n, initValue);
priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T, int>>> q;
dis[s] = 0;
q.emplace(0, s);
while (q.size()) {
T nowc = q.top().F;
int i = q.top().S;
q.pop();
if (dis[i] != nowc)continue;
for (auto &&e : g.g[i]) {
int to = e.to;
T cost = nowc + e.cost;
if (dis[to] > cost) {
dis[to] = cost;
q.emplace(dis[to], to);
}
}
}
//たどり着かないなら-1
for (auto &&d :dis) if (d == initValue)d = -1;
return dis;
}
//機能拡張
template<typename T> void remove(vector<T> &v, unsigned int i) { v.erase(v.begin() + i); }
template<typename T> void remove(vector<T> &v, unsigned int s, unsigned int e) {
v.erase(v.begin() + s, v.begin() + e);
}
template<typename T> void removen(vector<T> &v, unsigned int s, unsigned int n) {
v.erase(v.begin() + s, v.begin() + s + n);
}
template<typename T> void erase(vector<T> &v, unsigned int i) { v.erase(v.begin() + i); }
template<typename T> void erase(vector<T> &v, unsigned int s, unsigned int e) {
v.erase(v.begin() + s, v.begin() + e);
}
template<typename T> void erasen(vector<T> &v, unsigned int s, unsigned int n) {
v.erase(v.begin() + s, v.begin() + s + n);
}
template<typename T> void insert(vector<T> &v, unsigned int i, T t) { v.insert(v.begin() + i, t); }
template<typename T> void insert(vector<T> &v, unsigned int i, vector<T> list) {
for (auto &&va :list)v.insert(v.begin() + i++, va);
}
template<typename T> void insert(vector<T> &v, unsigned int i, initializer_list<T> list) {
for (auto &&va :list)v.insert(v.begin() + i++, va);
}
int mod(int a, int m) {
return (a % m + m) % m;
}
ll ma = numeric_limits<ll>::min();
ll mi = numeric_limits<ll>::max();
int N, K, M, H, W, q, Q, r, cou;
vi A, B, C;
signed main() {
int a, b, c, d;
cin >> N >> a >> b >> c >> d;
setMod();
vvm(dp, 1010, 1010); //dp[i][j] i人未満で残りj人までした
dp[0][N] = 1;
rep(i, N + 1) {
rep(r, N + 1) {
dp[i + 1][r] += dp[i][r];
if (!(a <= i && i <= b))con;
mint comb = 1;
int nr = r;
for (int g = 1; nr - i >= 0; ++g) {
comb *= com(nr, i);
comb /= g;
if (c <= g && g <= d)dp[i + 1][nr - i] += dp[i][r] * comb;
nr -= i;
}
}
}
cout << dp[N + 1][0] << endl;
return 0;
}
}
cout << dp[N + 1][0] << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:891:1: error: 'namespace' definition is not allowed here
891 | namespace std {
| ^~~~~~~~~
a.cc:993:1: error: a template declaration cannot appear at block scope
993 | template<class T> inline void sort(vector<T> &a) { sort(a.begin(), a.end()); };
| ^~~~~~~~
a.cc:994:1: error: a template declaration cannot appear at block scope
994 | template<class T> inline void rsort(vector<T> &a) { sort(a.begin(), a.end(), greater<T>()); };
| ^~~~~~~~
a.cc:995:1: error: a template declaration cannot appear at block scope
995 | template<class T> inline void sort(vector<T> &a, int len) { sort(a.begin(), a.begin() + len); };
| ^~~~~~~~
a.cc:996:1: error: a template declaration cannot appear at block scope
996 | template<class T> inline void rsort(vector<T> &a, int len) { sort(a.begin(), a.begin() + len, greater<T>()); };
| ^~~~~~~~
a.cc:1012:1: error: a template declaration cannot appear at block scope
1012 | template<typename A, size_t N, typename T> void fill(A (&a)[N], const T &v) {
| ^~~~~~~~
a.cc:1018:1: error: a template declaration cannot appear at block scope
1018 | template<typename A, size_t N, size_t O, size_t P, typename T> void fill(A (&a)[N][O][P], const T &v) {
| ^~~~~~~~
a.cc:1024:1: error: a template declaration cannot appear at block scope
1024 | template<typename A, size_t N, size_t O, size_t P, size_t Q, size_t R, typename T> void fill(A (&a)[N][O][P][Q][R], const T &v) {
| ^~~~~~~~
a.cc:1030:1: error: a template declaration cannot appear at block scope
1030 | template<class T, class U> void fill(vector<T> &a, U v) {
| ^~~~~~~~
a.cc:1036:1: error: a template declaration cannot appear at block scope
1036 | template<class T, class U> void fill(vector<vector<vector<T>>> &a, U v) {
| ^~~~~~~~
a.cc:1048:11: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
1048 | string sin() { return in<string>(); }
| ^~
a.cc:1048:11: note: remove parentheses to default-initialize a variable
1048 | string sin() { return in<string>(); }
| ^~
| --
a.cc:1048:14: error: a function-definition is not allowed here before '{' token
1048 | string sin() { return in<string>(); }
| ^
a.cc:1049:11: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
1049 | double din() { return in<double>(); }
| ^~
a.cc:1049:11: note: remove parentheses to default-initialize a variable
1049 | double din() { return in<double>(); }
| ^~
| --
a.cc:1049:11: note: or replace parentheses with braces to value-initialize a variable
a.cc:1049:14: error: a function-definition is not allowed here before '{' token
1049 | double din() { return in<double>(); }
| ^
a.cc:1050:7: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
1050 | ll lin() { return in<ll>(); }
| ^~
a.cc:1050:7: note: remove parentheses to default-initialize a variable
1050 | ll lin() { return in<ll>(); }
| ^~
| --
a.cc:1050:7: note: or replace parentheses with braces to value-initialize a variable
a.cc:1050:10: error: a function-definition is not allowed here before '{' token
1050 | ll lin() { return in<ll>(); }
| ^
a.cc:1070:1: error: a template declaration cannot appear at block scope
1070 | template<class T> void out(T x) {
| ^~~~~~~~
a.cc:1132:23: error: a function-definition is not allowed here before '{' token
1132 | int mpow(int v, ll a) {
| ^
a.cc:1152:17: error: cannot define friend function 'operator+' in a local class definition
1152 | friend mint operator+(const ll a, const mint &b) { return mint(a % MOD + b.v); }
| ^~~~~~~~
a.cc:1152:17: error: 'main()::mint main()::mint::operator+(long long int, const main()::mint&)' must have either zero or one argument
a.cc:1156:17: error: cannot define friend function 'operator+=' in a local class definition
1156 | friend void operator+=(ll &a, const mint &b) { a = mod(a % MOD + b.v); }
| ^~~~~~~~
a.cc:1156:17: error: 'void main()::mint::operator+=(long long int&, const main()::mint&)' must have exactly one argument
a.cc:1160:17: error: cannot define friend function 'operator-' in a local class definition
1160 | friend mint operator-(const ll a, const mint &b) { return mint(a % MOD - b.v); }
| ^~~~~~~~
a.cc:1160:17: error: 'main()::mint main()::mint::operator-(long long int, const main()::mint&)' must have either zero or one argument
a.cc:1164:17: error: cannot define friend function 'operator-=' in a local class definition
1164 | friend void operator-=(ll &a, const mint &b) { a = mod(a % MOD - b.v); }
| ^~~~~~~~
a.cc:1164:17: error: 'void main()::mint::operator-=(long long int&, const main()::mint&)' must have exactly one argument
a.cc:1168:17: error: cannot define friend function 'operator*' in a local class definition
1168 | friend mint operator*(const ll a, const mint &b) { return mint(a % MOD * b.v); }
| ^~~~~~~~
a.cc:1168:17: error: 'main()::mint main()::mint::operator*(long long int, const main()::mint&)' must have either zero or one argument
a.cc:1172:17: error: cannot define friend function 'operator*=' in a local class definition
1172 | friend void operator*=(ll &a, const mint &b) { a = mod(a % MOD * b.v); }
| ^~~~~~~~
a.cc:1172:17: error: 'void main()::mint::operator*=(long long int&, const main()::mint&)' must have exactly one argument
a.cc:1176:17: error: friend declaration 'main()::mint operator/(long long int, const main()::mint&)' in local class without prior local declaration
1176 | friend mint operator/(const ll a, const mint &b);
| ^~~~~~~~
a.cc:1180:17: error: friend declaration 'void operator/=(long long int&, const main()::mint&)' in local class without prior local declaration
1180 | friend void operator/=(ll &a, const mint &b);
| ^~~~~~~~
a.cc:1184:17: error: cannot define friend function 'operator^' in a local class definition
1184 | friend mint operator^(const ll a, const mint &b) { return mpow(a, b.v); };
| ^~~~~~~~
a.cc:1184:17: error: 'main()::mint main()::mint::operator^(long long int, const main()::mint&)' must have exactly one argument
a.cc:1215:17: error: cannot define friend function 'operator==' in a local class definition
1215 | friend bool operator==(signed a, mint &b) {
| ^~~~~~~~
a.cc:1215:17: error: 'bool main()::mint::operator==(int, main()::mint&)' must have exactly one argument
a.cc:1224:17: error: cannot define friend function 'operator!=' in a local class definition
1224 | friend bool operator!=(signed a, mint &b) {
| ^~~~~~~~
a.cc:1224:17: error: 'bool main()::mint::operator!=(int, main()::mint&)' must have exactly one argument
a.cc: In static member function 'static long long int main()::mint::mod(long long int)':
a.cc:1146:39: error: use of local variable with automatic storage from containing function
1146 | static ll mod(ll a) { return (a % MOD + MOD) % MOD; }
| ^~~
a.cc:1131:4: note: 'long long int MOD' declared here
1131 | ll MOD = (int) 1e9 + 7;
| ^~~
a.cc:1146:45: error: use of local variable with automatic storage from containing function
1146 | static ll mod(ll a) { return (a % MOD + MOD) % MOD; }
| ^~~
a.cc:1131:4: note: 'long long int MOD' declared here
1131 | ll MOD = (int) 1e9 + 7;
| ^~~
a.cc:1146:52: error: use of local variable with automatic storage from containing function
1146 | static ll mod(ll a) { return (a % MOD + MOD) % MOD; }
| ^~~
a.cc:1131:4: note: 'long long int MOD' declared here
1131 | ll MOD = (int) 1e9 + 7;
| ^~~
a.cc: In member function 'main()::mint main()::mint::operator+(long long int)':
a.cc:1150:54: error: use of local variable with automatic storage from containing function
1150 | mint operator+(const ll a) { return mint(v + a % MOD); }
| ^~~
a.cc:1131:4: note: 'long long int MOD' declared here
1131 | ll MOD = (int) 1e9 + 7;
| ^~~
a.cc: In member function 'main()::mint main()::mint::operator+(int)':
a.cc:1151:58: error: use of local variable with automatic storage from containing function
1151 | mint operator+(const signed a) { return mint(v + a % MOD); }
| ^~~
a.cc:1131:4: note: 'long long int MOD' declared here
1131 | ll MOD = (int) 1e9 + 7;
| ^~~
a.cc: In member function 'void main()::mint::operator+=(const main()::mint&)':
a.cc:1153:54: error: use of local variable with automatic storage from containing function
1153 | void operator+=(const mint &a) { v = (v + a.v) % MOD; }
| ^~~
a.cc:1131:4: note: 'long long int MOD' declared here
1131 | ll MOD = (int) 1e9 + 7;
| ^~~
a.cc: In member function 'void main()::mint::operator+=(long long int)':
a.cc:1154:51: error: use of local variable with automatic storage from containing function
1154 | void operator+=(const ll a) { v = mod(v + a % MOD); }
| ^~~
a.cc:1131:4: note: 'long long int MOD' declared here
1131 | ll MOD = (int) 1e9 + 7;
| ^~~
a.cc: In member function 'void main()::mint::operator+=(int)':
a.cc:1155:55: error: use of local variable with automatic storage from containing function
1155 | void operator+=(const signed a) { v = mod(v + a % MOD); }
| ^~~
a.cc:1131:4: note: 'long long int MOD' declared here
1131 | ll MOD = (int) 1e9 + 7;
| ^~~
a.cc: In member function 'main()::mint main()::mint::operator-(long long int)':
a.cc:1158:54: error: use of local v |
s471205951 | p03832 | C++ | #include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <cassert>
#include <vector>
//#include <array>
//#include <set>
//#include <map>
//#include <unordered_set>
//#include <unordered_map>
//#include <stack>
//#include <queue>
using ll = long long;
using namespace std;
#include "Modulo.h"
#define MOD 1000000007
unsigned int mod;
std::vector<unsigned int> fact_mod;
std::vector<unsigned int> rev_fact_mod;
using namespace std;
template<typename Tint>
Tint gcd(Tint a, Tint b) {
// O(log max(a,b))
return b != 0 ? gcd(b, a % b) : a;
}
template<typename Tint>
Tint lcm(Tint a, Tint b) {
return a / gcd(a, b) * b;
}
// a x + b y = gcd(a, b)
template<typename Tint>
Tint extgcd(Tint a, Tint b, Tint &x, Tint &y) {
// O(log max(a,b))
Tint g = a; x = 1; y = 0;
if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
return g;
}
void set_mod(const int m) {
mod = m;
}
template<typename Tint>
Tint inv_mod(Tint a) {
Tint x, y;
if (extgcd(a, mod, x, y) == 1)
return (x + mod) % mod;
else // unsolvable
return 0;
}
unsigned int pow_mod(const unsigned long long x, const unsigned int k) { //x^k (mod mod)
if (k == 0) return 1;
if (k % 2 == 0) return pow_mod(x*x % mod, k / 2);
else return x * pow_mod(x, k - 1) % mod;
}
std::vector<unsigned int> set_fact_mod(unsigned int n) {
fact_mod = vector<unsigned int>(n + 1);
fact_mod[0] = 1;
for (unsigned int i = 1; i <= n; i++)
{
fact_mod[i] = (long long)fact_mod[i - 1] * i % mod;
}
return fact_mod;
}
std::vector<unsigned int> set_rev_fact_mod(unsigned int n) {
rev_fact_mod = vector<unsigned int>(n + 1);
rev_fact_mod[n] = pow_mod(fact_mod[n], mod - 2);
for (int i = n - 1; i >= 0; i--)
{
rev_fact_mod[i] = (long long)rev_fact_mod[i + 1] * (i + 1) % mod;
}
return rev_fact_mod;
}
int main() {
unsigned int n, a, b, c, d;
cin >> n >> a >> b >> c >> d;
set_mod(MOD);
set_fact_mod(n);
set_rev_fact_mod(n);
vector<unsigned int>dp(n + 1, 0);
dp[0] = 1;
for (unsigned int tmpb = a; tmpb <= b; tmpb++)
{
for (unsigned int tmpn = n; tmpn >= 1; tmpn--)
{
unsigned int sum_tmpb_tmpn = 0;
for (unsigned int tmpk = c; tmpk <= min(tmpn / tmpb, d); tmpk++)
{
unsigned int tmprest = tmpn - tmpb * tmpk;
ll cal;
ll comb_tmpb = fact_mod[tmpn];
comb_tmpb *= pow_mod(rev_fact_mod[tmpb], tmpk);
comb_tmpb %= MOD;
comb_tmpb *= rev_fact_mod[tmprest];
comb_tmpb %= MOD;
comb_tmpb *= rev_fact_mod[tmpk];
comb_tmpb %= MOD;
cal = dp[tmprest] * comb_tmpb;
cal %= MOD;
cal += sum_tmpb_tmpn;
cal %= MOD;
sum_tmpb_tmpn = cal;
}
dp[tmpn] = (dp[tmpn] + sum_tmpb_tmpn) % MOD;
}
}
cout << dp[n] << endl;
return 0;
} | a.cc:17:10: fatal error: Modulo.h: No such file or directory
17 | #include "Modulo.h"
| ^~~~~~~~~~
compilation terminated.
|
s454145100 | p03832 | C++ | #include<iostream>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
ll fact[1500];
ll invfact[1500];
inline ll take_mod(ll a){
return (a % mod + mod) % mod;
}
inline ll add(ll a, ll b){
return take_mod(a+b);
}
inline ll sub(ll a, ll b){
return take_mod(a-b);
}
inline ll mul(ll a, ll b){
a = take_mod(a);
b = take_mod(b);
if (b == 0) return 0;
ll res = mul(add(a, a), b >> 1);
if(b & 1) res = add(res, a);
return res;
}
inline ll pow(ll x, ll n){
ll res = 1LL;
while(n > 0){
if(n & 1) res = mul(res, x);
x = mul(x, x);
n >>= 1;
}
return res;
}
ll mod_inv(ll x){
return pow(x, mod-2);
}
// nは上限
void make_fact(ll n){
fact[0] = 1;
ll res = 1;
for(int i = 1; i <= n; i++){
fact[i] = res;
res = mul(res, i+1);
}
}
// nは上限
void make_invfact(ll n){
invfact[0] = 1;
invfact[n] = mod_inv(fact[n]);
for(int i = n-1; i >= 1; i--){
invfact[i] = mul(invfact[i + 1], i + 1);
}
}
ll comb(ll n, ll k){
return mul(mul(fact[n], invfact[n-k]), invfact[k]);
}
ll dp[1010][1010];
ll f()
int main(){
int N, A, B, C, D;
cin >> N >> A >> B >> C >> D;
make_fact(N+10);
make_invfact(N+10);
for(int i = 0; i < 1010; i++){
for(int j = 0; j < 1010; j++){
dp[i][j] = 0;
}
}
dp[0][A-1] = 1;
for(int i = 0; i <= N; i++){
for(int j = A; j <= B; j++){
ll c = 1LL;
dp[i][j] = add(dp[i][j], dp[i][j-1]);
for(int k = 1; k <= min((N-i)/j, D); k++){
c = mul(c, comb(N-i-j*(k-1), j));
if(k < C) continue;
ll x = mul(dp[i][j-1], mul(c, invfact[k]));
dp[i+j*k][j] = add(dp[i+j*k][j], x);
}
}
}
cout << dp[N][B] << endl;
return 0;
}
| a.cc:77:1: error: expected initializer before 'int'
77 | int main(){
| ^~~
|
s598437920 | p03832 | C++ | #include<iostream>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
ll fact[1500];
ll invfact[1500];
inline ll take_mod(ll a){
return (a % mod + mod) % mod;
}
inline ll add(ll a, ll b){
return take_mod(a+b);
}
inline ll sub(ll a, ll b){
return take_mod(a-b);
}
inline ll mul(ll a, ll b){
a = take_mod(a);
b = take_mod(b);
if (b == 0) return 0;
ll res = mul(add(a, a), b >> 1);
if(b & 1) res = add(res, a);
return res;
}
inline ll pow(ll x, ll n){
ll res = 1LL;
while(n > 0){
if(n & 1) res = mul(res, x);
x = mul(x, x);
n >>= 1;
}
return res;
}
ll mod_inv(ll x){
return pow(x, mod-2);
}
// nは上限
void make_fact(ll n){
fact[0] = 1;
ll res = 1;
for(int i = 1; i <= n; i++){
fact[i] = res;
res = mul(res, i+1);
}
}
// nは上限
void make_invfact(ll n){
invfact[0] = 1;
invfact[n] = mod_inv(fact[n]);
for(int i = n-1; i >= 1; i--){
invfact[i] = mul(invfact[i + 1], i + 1);
}
}
ll comb(ll n, ll k){
return mul(mul(fact[n], invfact[n-k]), invfact[k]);
}
ll dp[1010][1010];
ll f()
int main(){
int N, A, B, C, D;
cin >> N >> A >> B >> C >> D;
make_fact(N+10);
make_invfact(N+10);
for(int i = 0; i < 1010; i++){
for(int j = 0; j < 1010; j++){
dp[i][j] = 0;
}
}
dp[0][A-1] = 1;
for(int i = 0; i <= N; i++){
for(int j = A; j <= B; j++){
ll c = 1LL;
dp[i][j] = add(dp[i][j], dp[i][j-1]);
for(int k = 1; k <= min((N-i)/j, D); k++){
c = mul(c, comb(N-i-j*(k-1), j));
if(k < C) continue;
ll x = mul(dp[i][j-1], mul(c, invfact[k]));
dp[i+j*k][j] = add(dp[i+j*k][j], x);
}
}
}
cout << dp[N][B] << endl;
return 0;
}
| a.cc:77:1: error: expected initializer before 'int'
77 | int main(){
| ^~~
|
s342440434 | p03832 | C++ | #include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
using namespace std;
#define mod 1000000007
int a, b, c, d;
long long int fact[1001];
long long int comb[1001][1001];
long long int powrev[1001];
vector<vector<long long int> > result(1001, vector<long long int>(1001, -1));
// result[i][j] : i人でグループを作る。最大のグループの人数がj人のとき、グループ分けが何通りあるか
long long int getpow(long long int n, long long int k)
{
if(k == 0) return 1;
long long int tmp = getpow(n, k / 2);
if(k % 2 == 0) return (tmp * tmp) % mod;
else return (((tmp * tmp) % mod) * n) % mod;
}
long long int solve(int n, int k)
{
if(result[n][k] >= 0) return result[n][k];
if(n == 0) return result[n][k] = 1;
if(k < a) return result[n][k] = 0;
result[n][k] = solve(n, k - 1);
long long int tmp = 1;
for(int i = 1; i <= c - 1; i++){
if((i - 1) * k > n) return;
tmp *= (comb[n - (i - 1) * k][k] * powrev[i]) % mod;
tmp %= mod;
}
for(int i = c; i <= d; i++){
if(k * i > n) break;
tmp *= (comb[n - (i - 1) * k][k] * powrev[i]) % mod;
tmp %= mod;
result[n][k] += (tmp * solve(n - k * i, k - 1)) % mod;
result[n][k] %= mod;
}
// cout << n << " " << k << " " << result[n][k] << endl;
return result[n][k];
}
int main()
{
int n;
cin >> n >> a >> b >> c >> d;
comb[0][0] = 1;
comb[1][0] = 1;
comb[1][1] = 1;
fact[0] = 1;
fact[1] = 1;
powrev[0] = 1;
powrev[1] = 1;
for(int i = 2; i <= n; i++){
fact[i] = (fact[i - 1] * i) % mod;
powrev[i] = getpow(i, mod - 2);
for(int j = 0; j <= i; j++){
comb[i][j] = (comb[i - 1][j - 1] + comb[i - 1][j]) % mod;
}
}
cout << solve(n, b) << endl;
} | a.cc: In function 'long long int solve(int, int)':
a.cc:46:37: error: return-statement with no value, in function returning 'long long int' [-fpermissive]
46 | if((i - 1) * k > n) return;
| ^~~~~~
|
s782112719 | p03832 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
const ll linf = 1e18;
const double eps = 1e-12;
const double pi = acos(-1);
template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
each(x,vec) is >> x;
return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
rep(i,vec.size()) {
if (i) os << " ";
os << vec[i];
}
return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
rep(i,vec.size()) {
if (i) os << endl;
os << vec[i];
}
return os;
}
const ll mod = 1e9+7;
ll mul(ll a, ll b) {
return a * b % mod;
}
ll mul(initializer_list<ll> t) {
ll res = 1;
each(v, t) res = mul(res, v);
return res;
}
ll add(ll a, ll b) {
return (a + b) % mod;
}
ll add(initializer_list<ll> t) {
ll res = 0;
each(v, t) res = add(res, v);
return res;
}
ll sub(ll a, ll b) {
return (a - b + mod) % mod;
}
ll sub(initializer_list<ll> t) {
auto it = t.begin();
ll res = *(it++);
while (it != t.end()) {
res = sub(res, *(it++));
}
return res;
}
ll power(ll x, ll n) {
ll res = 1;
for (ll i = 1; i <= n; i <<= 1) {
if (i & n) res = mul(res, x);
x = mul(x, x);
}
return res;
}
ll inv(ll n) {
return power(n, mod-2);
}
ll divi(ll a, ll b) {
return mul(a, inv(b));
}
ll divi(initializer_list<ll> t) {
auto it = t.begin();
ll res = *(it++);
while (it != t.end()) {
res = divi(res, *(it++));
}
return res;
}
vector<ll> fact;
void init_fact(ll n) {
fact.assign(n+1, 1);
FOR(i, 1, fact.size()) {
fact[i] = mul(fact[i-1], i);
}
}
ll comb(ll n, ll r) {
if (r < 0) return 0;
if (r > n) return 0;
return divi(fact[n], mul(fact[r], fact[n-r]));
}
using Row = vector<ll>;
using Matrix = vector<Row>;
Matrix E(ll n) {
Matrix res(n, Row(n, 0));
rep(i, n) res[i][i] = 1;
return res;
}
Matrix mul(const Matrix& A, const Matrix& B) {
const ll n = A.size(), m = A[0].size(), l = B[0].size();
assert(m == B.size());
Matrix res(n, Row(l, 0));
rep(i, n) rep(j, m) rep(k, l) {
res[i][k] = add(res[i][k], mul(A[i][j], B[j][k]));
}
return res;
}
Matrix power(Matrix A, ll n) {
assert(A.size() == A[0].size());
Matrix res = E(A.size());
for (ll i = 1; i <= n; i <<= 1) {
if (i & n) res = mul(res, A);
A = mul(A, A);
}
return res;
}
void gen_fact_result(ll d, ll num) {
ll x = 1;
cout << "#define FACT";
cout << "vector<P> facts = {";
rep(i, d*(num-1)+1) {
if (i % d == 0) {
cout << "{" << i << "," << x << "},";
}
x = mul(x, i+1);
}
cout << "};";
}
#define FACT
vector<P> facts = {{0,1},{10000000,682498929},{20000000,491101308},{30000000,76479948},{40000000,723816384},{50000000,67347853},{60000000,27368307},{70000000,625544428},{80000000,199888908},{90000000,888050723},{100000000,927880474},{110000000,281863274},{120000000,661224977},{130000000,623534362},{140000000,970055531},{150000000,261384175},{160000000,195888993},{170000000,66404266},{180000000,547665832},{190000000,109838563},{200000000,933245637},{210000000,724691727},{220000000,368925948},{230000000,268838846},{240000000,136026497},{250000000,112390913},{260000000,135498044},{270000000,217544623},{280000000,419363534},{290000000,500780548},{300000000,668123525},{310000000,128487469},{320000000,30977140},{330000000,522049725},{340000000,309058615},{350000000,386027524},{360000000,189239124},{370000000,148528617},{380000000,940567523},{390000000,917084264},{400000000,429277690},{410000000,996164327},{420000000,358655417},{430000000,568392357},{440000000,780072518},{450000000,462639908},{460000000,275105629},{470000000,909210595},{480000000,99199382},{490000000,703397904},{500000000,733333339},{510000000,97830135},{520000000,608823837},{530000000,256141983},{540000000,141827977},{550000000,696628828},{560000000,637939935},{570000000,811575797},{580000000,848924691},{590000000,131772368},{600000000,724464507},{610000000,272814771},{620000000,326159309},{630000000,456152084},{640000000,903466878},{650000000,92255682},{660000000,769795511},{670000000,373745190},{680000000,606241871},{690000000,825871994},{700000000,957939114},{710000000,435887178},{720000000,852304035},{730000000,663307737},{740000000,375297772},{750000000,217598709},{760000000,624148346},{770000000,671734977},{780000000,624500515},{790000000,748510389},{800000000,203191898},{810000000,423951674},{820000000,629786193},{830000000,672850561},{840000000,814362881},{850000000,823845496},{860000000,116667533},{870000000,256473217},{880000000,627655552},{890000000,245795606},{900000000,586445753},{910000000,172114298},{920000000,193781724},{930000000,778983779},{940000000,83868974},{950000000,315103615},{960000000,965785236},{970000000,492741665},{980000000,377329025},{990000000,847549272},};
#ifdef FACT
ll bigfact(ll n) {
if (n >= mod) return 0;
auto it = upper_bound(all(facts), P(n, linf));
assert(it != facts.begin());
--it;
ll s = it->first;
ll res = it->second;
rep(i, s+1, n+1) {
res = mul(res, i);
}
return res;
}
#endif
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
init_fact(1e5);
ll n, A, B, C, D; cin >> n >> A >> B >> C >> D;
vector<vector<ll>> dp(n+1, vector<ll>(n+1, 0));
dp[0][0] = 1;
rep(i, n+1) {
rep(j, n+1) {
rep(k, C, D+1) {
if (A <= i && i <= B) {
if (j - k * i >= 0) {
dp[i][j] = add(dp[i][j], divi(dp[i-1][j-k*i], mul(fact[k], power(fact[i], k))));
}
}
}
}
rep(i, 1, n+1) {
dp[i][j] = add(dp[i][j], dp[i-1][j]);
}
}
ll ans = mul(dp[n][n], fact[n]);
cout << ans << endl;
}
| a.cc: In function 'int main()':
a.cc:182:19: error: 'j' was not declared in this scope
182 | dp[i][j] = add(dp[i][j], dp[i-1][j]);
| ^
|
s014658708 | p03832 | C++ | #include <iostream>
#include <vector>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
ll power(const ll p,const int n)
{
if(n==0){return 1;}
if(n%2==1){power(p,n-1)*p%MOD;}
else{const ll pp =power(p,n/2);
return pp*pp%MOD;}
}
int main()
{
int N,A,B,C,D;
cin>>N>>A>>B>>C>>D;
vector<ll> fact(N+1,1);
vector<ll> inv(N+1,1);
vector<ll> invfact(N+1,1);
for(int i =2;i<=N;i++){
fact[i]=fact[i-1]*i%MOD;
inv[i]=power(i,MOD-2);
invfact[i]=invfact[i-1]*inv[i]%MOD;
}
auto get =[&](const int i,const int l){
return fact[i]*invfact[i-l]%MOD;
};
vector<ll> dp(N+1,0)
dp[0]=1;
for(int i = A; i <= B; i++){
auto tmp = dp;
for(int j = 0; j <=N; j++){
if(dp[j] == 0){continue;}
ll mul=1;
ll di=1;
for(int k = C;k <= D; k++){
const ll rest =N-j-k*i;
if(rest<0){break;}
(mul*=get(rest,i))%=MOD;
(di*=inv[k-C+1])%=MOD;
(tmp[j+k*i]+=mul*di%MOD)%=MOD;
}
}
dp=tmp;
}
cout << dp[N]<< endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:30:3: error: expected ',' or ';' before 'dp'
30 | dp[0]=1;
| ^~
a.cc: In function 'll power(ll, int)':
a.cc:12:1: warning: control reaches end of non-void function [-Wreturn-type]
12 | }
| ^
|
s390606241 | p03832 | C++ | #include <iostream>
#include <vector>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
ll power(const ll p,const int n)
{
if(n==0){return 1;}
if(n%2==1){power(p,n-1)*p%MOD;}
else{const ll pp =power(p,n/2);
return pp*pp%MOD;}
}
int main()
{
int N,A,B,C,D;
cin>>N>>A>>B>>C>>D;
vector<ll> fact(N+1,1);
vector<ll> inv(N+1,1);
vector<ll> invfact(N+1,1);
for(int i =2;i<=N;i++){
fact[i]=fact[i-1]*i%MOD;
inv[i]=power(i,MOD-2);
invfact[i]=invfact[i-1]*inv[i]%MOD;
}
auto=get(const int i,const int l){
return fact[i]*invfact[i-l]%MOD;
};
vector<ll> dp(N+1,0)
dp[0]=1;
for(int i = A; i <= B; i++){
auto tmp = dp;
for(int j = 0; j <=N; j++){
if(dp[j] == 0){continue;}
ll mul=1;
ll di=1;
for(int k = C;k <= D; k++){
const ll rest =N-j-k*i;
if(rest<0){break;}
(mul*=get(rest,i))%=MOD;
(di*=inv[k-C+1])%=MOD;
(tmp[j+k*i]+=mul*di%MOD)%=MOD;
}
}
dp=tmp;
}
cout << dp[N]<< endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:26:7: error: expected unqualified-id before '=' token
26 | auto=get(const int i,const int l){
| ^
a.cc:30:3: error: expected ',' or ';' before 'dp'
30 | dp[0]=1;
| ^~
a.cc:40:18: error: no matching function for call to 'get(const ll&, int&)'
40 | (mul*=get(rest,i))%=MOD;
| ~~~^~~~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_pair.h:1250:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(pair<_Tp1, _Tp2>&)'
1250 | get(pair<_Tp1, _Tp2>& __in) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1250:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_pair.h:1255:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(pair<_Tp1, _Tp2>&&)'
1255 | get(pair<_Tp1, _Tp2>&& __in) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1255:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_pair.h:1260:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(const pair<_Tp1, _Tp2>&)'
1260 | get(const pair<_Tp1, _Tp2>& __in) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1260:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_pair.h:1265:5: note: candidate: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(const pair<_Tp1, _Tp2>&&)'
1265 | get(const pair<_Tp1, _Tp2>&& __in) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1265:5: note: candidate expects 1 argument, 2 provided
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
from /usr/include/c++/14/string:68:
/usr/include/c++/14/tuple:2445:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >& std::get(tuple<_Elements ...>&)'
2445 | get(tuple<_Elements...>& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2445:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/tuple:2451:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >& std::get(const tuple<_Elements ...>&)'
2451 | get(const tuple<_Elements...>& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2451:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/tuple:2457:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >&& std::get(tuple<_Elements ...>&&)'
2457 | get(tuple<_Elements...>&& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2457:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/tuple:2466:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >&& std::get(const tuple<_Elements ...>&&)'
2466 | get(const tuple<_Elements...>&& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2466:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_pair.h:138:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr _Tp& std::get(array<_Tp, _Nm>&)'
138 | get(array<_Tp, _Nm>&) noexcept;
| ^~~
/usr/include/c++/14/bits/stl_pair.h:138:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_pair.h:142:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr _Tp&& std::get(array<_Tp, _Nm>&&)'
142 | get(array<_Tp, _Nm>&&) noexcept;
| ^~~
/usr/include/c++/14/bits/stl_pair.h:142:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_pair.h:146:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr const _Tp& std::get(const array<_Tp, _Nm>&)'
146 | get(const array<_Tp, _Nm>&) noexcept;
| ^~~
/usr/include/c++/14/bits/stl_pair.h:146:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_pair.h:150:5: note: candidate: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr const _Tp&& std::get(const array<_Tp, _Nm>&&)'
150 | get(const array<_Tp, _Nm>&&) noexcept;
| ^~~
/usr/include/c++/14/bits/stl_pair.h:150:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_pair.h:1272:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp& std::get(pair<_T1, _T2>&)'
1272 | get(pair<_Tp, _Up>& __p) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1272:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_pair.h:1277:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp& std::get(const pair<_T1, _T2>&)'
1277 | get(const pair<_Tp, _Up>& __p) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1277:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_pair.h:1282:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp&& std::get(pair<_T1, _T2>&&)'
1282 | get(pair<_Tp, _Up>&& __p) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1282:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_pair.h:1287:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp&& std::get(const pair<_T1, _T2>&&)'
1287 | get(const pair<_Tp, _Up>&& __p) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1287:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_pair.h:1292:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp& std::get(pair<_Up, _Tp>&)'
1292 | get(pair<_Up, _Tp>& __p) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1292:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_pair.h:1297:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp& std::get(const pair<_Up, _Tp>&)'
1297 | get(const pair<_Up, _Tp>& __p) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1297:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_pair.h:1302:5: note: candidate: 'template<class _Tp, class _Up> constexpr _Tp&& std::get(pair<_Up, _Tp>&&)'
1302 | get(pair<_Up, _Tp>&& __p) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1302:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_pair.h:1307:5: note: candidate: 'template<class _Tp, class _Up> constexpr const _Tp&& std::get(const pair<_Up, _Tp>&&)'
1307 | get(const pair<_Up, _Tp>&& __p) noexcept
| ^~~
/usr/include/c++/14/bits/stl_pair.h:1307:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/tuple:2476:5: note: candidate: 'template<long unsigned int __i, class ... _Elements> constexpr std::__enable_if_t<(__i >= sizeof... (_Types))> std::get(const tuple<_Elements ...>&)' (deleted)
2476 | get(const tuple<_Elements...>&) = delete;
| ^~~
/usr/include/c++/14/tuple:2476:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/tuple:2483:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr _Tp& std::get(tuple<_Elements ...>&)'
2483 | get(tuple<_Types...>& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2483:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/tuple:2494:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr _Tp&& std::get(tuple<_Elements ...>&&)'
2494 | get(tuple<_Types...>&& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2494:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/tuple:2505:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr const _Tp& std::get(const tuple<_Elements ...>&)'
2505 | get(const tuple<_Types...>& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2505:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/tuple:2517:5: note: candidate: 'template<class _Tp, class ... _Types> constexpr const _Tp&& std::get(const tuple<_Elements ...>&&)'
2517 | get(const tuple<_Types...>&& __t) noexcept
| ^~~
/usr/include/c++/14/tuple:2517:5: note: candidate expects 1 argument, 2 provided
a.cc: In function 'll power(ll, int)':
a.cc:12:1: warning: control reaches end of non-void function [-Wreturn-type]
12 | }
| ^
|
s158968008 | p03832 | C++ | #include <bits/stdc++.h>
#define INF 1 << 29
typedef long long int ll;
using namespace std;
#define REP(i,n) for(ll i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(ll i=(k);i<(int)(n);i++)
ll n,a,b,c,d;
ll mod = 1e9 + 7;
ll fac[1005];
ll invf[1005];
ll dp[1005][1005];
ll f(ll a,ll x){//a^x
ll res = 1;
while(x > 0){
if(x&1) res = res * a % mod;
a = a * a % mod;
x >>= 1;
}
return res;
}
ll inv(ll x){
return f(x,mod-2);
}
ll P(ll n, ll r){
return fac[n] * invf[n-r] % mod;
}
int main(){
cin >> n>>a>>b>>c>>d;
fac[0] = 1;
invf[0] = 1;
FOR(i,1,n+1){
fac[i] = i * fac[i-1] % mod;
invf[i] = inv(fac[i]);
}
dp[a-1][0] = 1;
FOR(i,a,b+1){
REP(j,n+1){
dp[i][j] = dp[i-1][j];
ll fac_i_k = f(fac[i],c);
FOR(k,c,min(d+1,j/i+1)){
ll x = k*i;
dp[i][j] = (dp[i][j] + dp[i-1][j-x] * P(n-j+x,x) % mod;// * inv(fac_i_k*fac[k] % mod) % mod) % mod;
fac_i_k = fac_i_k * fac[i] % mod;
}
}
}
cout << dp[b][n] % mod << endl;
}
/*
ll n,a,b,c,d;
ll C[1010][1010] = {{0}};
ll ans = 0;
ll mod = 1e9 + 7;
ll dp[1010][1010] ={{0}};
ll fact[1010];
void gen_C(){
C[1][0] = 1;
C[1][1] = 1;
FOR(i,2,1010){
C[i][0] = 1;
C[i][i] = 1;
FOR(j,2,i){
C[i][j] = C[i-1][j-1]+C[i-1][j];
C[i][j] %= mod;
}
}
}
void gen_fact_mod(){
fact[0] = 1;
fact[1] = 1;
FOR(i,2,1010){
ll now = 1;
ll ans = 1;
ll p = mod -1;
while(p>0){
now *= now;
now %= mod;
if(p%2==1){
ans *= now;
ans %= mod;
}
p/=2;
}
fact[i] = (fact[i-1]*ans)%mod;
}
}
dp[k][n] n人をk人以下のグループに分ける
dp[1][1] = 1;
dp[i][j] = j人をi人以下のグループに分ける人数
= dp[i-1][j-i*k] * f(i,j,k)
f(i,j,k) j人中i人グループがk個あった時の通り数
j-i*k人は使われているのでn-(j-i*k)=n-j+i*k人中何通りグループ分けが存在するかを調べればいい
f(i,j,k) = (n-j+i*k)P(i*k)/(i!)^k/k!
= Pi(1<=l<=k) (n-j+i*l)C(i)/k!
int main(){
cin >>n>>a>>b>>c>>d;
gen_C();
gen_fact_mod();
FOR(i,c,d+1){//a人の時のグループの分け方
ll tmp = 1;
if(a*i>n) break;
REP(j,i){
tmp *= C[n-i*a][a];
tmp %= mod;
}
tmp %= mod;
dp[a][a*i] = (tmp * fact[i])%mod;
}
FOR(i,a+1,b+1){//i人以下のグループで分ける時
REP(j,n){
dp[i][j] = dp[i-1][j];
ll tmp =1;
ll ans = 0;
if(n-j+i*c<0||n-j+i*c>n) break;
REP(k,c){
tmp *= C[n-j+i*k][i];
tmp %= mod;
}
tmp %= mod;
tmp = (tmp * fact[c])%mod;
ans += (tmp * dp[i-1][j-i*c])%mod;
FOR(k,c+1,min(i/j,d)){
tmp *= k-1;
tmp %= mod;
tmp += C[n-j+i*k][i];
tmp %= mod;
tmp = (tmp * fact[k]) %mod;
ans += (tmp* dp[i-1][j-i*k]) % mod;
}
}
}
cout << dp[n][n]<<endl;
}
*/
| a.cc: In function 'int main()':
a.cc:50:63: error: expected ')' before ';' token
50 | dp[i][j] = (dp[i][j] + dp[i-1][j-x] * P(n-j+x,x) % mod;// * inv(fac_i_k*fac[k] % mod) % mod) % mod;
| ~ ^
| )
|
s576615629 | p03832 | C++ | //package com.company;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
public class Main {
static long TIME_START, TIME_END;
public static void main(String[] args) throws IOException {
MyScanner sc = new MyScanner(System.in);
// MyScanner sc = new MyScanner(new FileInputStream("Test.in"));
PrintWriter pw = new PrintWriter(System.out);
// PrintWriter pw = new PrintWriter(new FileOutputStream("Test.out"));
TIME_START = System.currentTimeMillis();
Task.solve(sc, pw);
TIME_END = System.currentTimeMillis();
// pw.println("Time used: " + (TIME_END - TIME_START) + ".");
pw.close();
}
public static class Task {
static final int MOD = 1000000007;
static long[][] dp;
static long[] fact;
static long[] invfact;
static int N, A, B, C, D;
public static void solve(MyScanner sc, PrintWriter pw) throws IOException {
N = sc.nextInt();
A = sc.nextInt();
B = sc.nextInt();
C = sc.nextInt();
D = sc.nextInt();
precompute();
dp = new long[2][N + 1];
dp[(A - 1) % 2][0] = 1;
for (int i = A; i <= B; i++) {
int cutI = i % 2;
int prevI = (i - 1) % 2;
for (int j = C; j <= D; j++) {
int count = i * j;
if (count > N) break;
long subChoose = fact[count] * pow(invfact[i], j) % MOD * invfact[j] % MOD;
for (int k = count; k <= N; k++) {
long choose = fact[k] * invfact[count] % MOD * invfact[k - count] % MOD;
long add = dp[prevI][k - count] * subChoose % MOD * choose % MOD;
dp[cutI][k] += add;
if (dp[cutI][k] >= MOD) dp[cutI][k] -= MOD;
}
}
for (int j = 0; j <= N; j++) {
dp[cutI][j] += dp[prevI][j];
if (dp[cutI][j] >= MOD) dp[cutI][j] -= MOD;
}
Arrays.fill(dp[prevI], 0);
}
pw.println(dp[B % 2][N]);
}
public static long pow(long a, int b) {
if (b == 0) return 1;
if ((b & 1) == 0) return pow(a * a % MOD, b >> 1);
return (a * pow(a * a % MOD, b >> 1) % MOD);
}
public static void precompute(){
fact = new long[1001];
invfact = new long[1001];
fact[0] = 1; invfact[0] = (int)pow(1, MOD - 2);
for (int i = 1; i < 1001; i++) {
fact[i] = i * fact[i - 1];
fact[i] %= MOD;
invfact[i] = (int) pow(fact[i], MOD - 2);
}
}
}
static class MyScanner {
StringTokenizer st;
BufferedReader br;
public MyScanner(InputStream s){ br = new BufferedReader(new InputStreamReader(s));}
public MyScanner(FileReader s) throws FileNotFoundException {br = new BufferedReader(s);}
public String next() throws IOException
{
while (st == null || !st.hasMoreTokens())
st = new StringTokenizer(br.readLine());
return st.nextToken();
}
public int nextInt() throws IOException {return Integer.parseInt(next());}
public long nextLong() throws IOException {return Long.parseLong(next());}
public String nextLine() throws IOException {return br.readLine();}
public double nextDouble() throws IOException { return Double.parseDouble(next()); }
public boolean ready() throws IOException {return br.ready();}
}
}
| a.cc:3:1: error: 'import' does not name a type
3 | import java.io.*;
| ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
4 | import java.lang.reflect.Array;
| ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: 'import' does not name a type
5 | import java.math.BigInteger;
| ^~~~~~
a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:6:1: error: 'import' does not name a type
6 | import java.util.*;
| ^~~~~~
a.cc:6:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:8:1: error: expected unqualified-id before 'public'
8 | public class Main {
| ^~~~~~
|
s798345101 | p03832 | C++ | //package com.company;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
public class Main {
static long TIME_START, TIME_END;
public static void main(String[] args) throws IOException {
MyScanner sc = new MyScanner(System.in);
// MyScanner sc = new MyScanner(new FileInputStream("Test.in"));
PrintWriter pw = new PrintWriter(System.out);
// PrintWriter pw = new PrintWriter(new FileOutputStream("Test.out"));
TIME_START = System.currentTimeMillis();
Task.solve(sc, pw);
TIME_END = System.currentTimeMillis();
// pw.println("Time used: " + (TIME_END - TIME_START) + ".");
pw.close();
}
public static class Task {
static final int MOD = 1000000007;
static long[][] dp;
static long[] fact;
static long[] invfact;
static int N, A, B, C, D;
public static void solve(MyScanner sc, PrintWriter pw) throws IOException {
N = sc.nextInt();
A = sc.nextInt();
B = sc.nextInt();
C = sc.nextInt();
D = sc.nextInt();
precompute();
dp = new long[2][N + 1];
dp[(A - 1) % 2][0] = 1;
for (int i = A; i <= B; i++) {
int cutI = i % 2;
int prevI = (i - 1) % 2;
for (int j = C; j <= D; j++) {
int count = i * j;
if (count > N) break;
long subChoose = fact[count] * pow(invfact[i], j) % MOD * invfact[j] % MOD;
for (int k = count; k <= N; k++) {
long choose = fact[k] * invfact[count] % MOD * invfact[k - count] % MOD;
long add = dp[prevI][k - count] * subChoose % MOD * choose % MOD;
dp[cutI][k] += add;
if (dp[cutI][k] >= MOD) dp[cutI][k] -= MOD;
}
}
for (int j = 0; j <= N; j++) {
dp[cutI][j] += dp[prevI][j];
if (dp[cutI][j] >= MOD) dp[cutI][j] -= MOD;
}
Arrays.fill(dp[prevI], 0);
}
pw.println(dp[B % 2][N]);
}
public static long pow(long a, int b) {
if (b == 0) return 1;
if ((b & 1) == 0) return pow(a * a % MOD, b >> 1);
return (a * pow(a * a % MOD, b >> 1) % MOD);
}
public static void precompute(){
fact = new long[1001];
invfact = new long[1001];
fact[0] = 1; invfact[0] = (int)pow(1, MOD - 2);
for (int i = 1; i < 1001; i++) {
fact[i] = i * fact[i - 1];
fact[i] %= MOD;
invfact[i] = (int) pow(fact[i], MOD - 2);
}
}
}
static class MyScanner {
StringTokenizer st;
BufferedReader br;
public MyScanner(InputStream s){ br = new BufferedReader(new InputStreamReader(s));}
public MyScanner(FileReader s) throws FileNotFoundException {br = new BufferedReader(s);}
public String next() throws IOException
{
while (st == null || !st.hasMoreTokens())
st = new StringTokenizer(br.readLine());
return st.nextToken();
}
public int nextInt() throws IOException {return Integer.parseInt(next());}
public long nextLong() throws IOException {return Long.parseLong(next());}
public String nextLine() throws IOException {return br.readLine();}
public double nextDouble() throws IOException { return Double.parseDouble(next()); }
public boolean ready() throws IOException {return br.ready();}
}
}
| a.cc:3:1: error: 'import' does not name a type
3 | import java.io.*;
| ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
4 | import java.lang.reflect.Array;
| ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: 'import' does not name a type
5 | import java.math.BigInteger;
| ^~~~~~
a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:6:1: error: 'import' does not name a type
6 | import java.util.*;
| ^~~~~~
a.cc:6:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:8:1: error: expected unqualified-id before 'public'
8 | public class Main {
| ^~~~~~
|
s041170916 | p03832 | C++ | //package com.company;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
public class Main {
static long TIME_START, TIME_END;
public static void main(String[] args) throws IOException {
MyScanner sc = new MyScanner(System.in);
// MyScanner sc = new MyScanner(new FileInputStream("Test.in"));
PrintWriter pw = new PrintWriter(System.out);
// PrintWriter pw = new PrintWriter(new FileOutputStream("Test.out"));
TIME_START = System.currentTimeMillis();
Task.solve(sc, pw);
TIME_END = System.currentTimeMillis();
// pw.println("Time used: " + (TIME_END - TIME_START) + ".");
pw.close();
}
public static class Task {
static final int MOD = 1000000007;
static long[][] dp;
static long[] fact;
static long[] invfact;
static int N, A, B, C, D;
public static void solve(MyScanner sc, PrintWriter pw) throws IOException {
N = sc.nextInt();
A = sc.nextInt();
B = sc.nextInt();
C = sc.nextInt();
D = sc.nextInt();
precompute();
dp = new long[2][N + 1];
dp[(A - 1) % 2][0] = 1;
for (int i = A; i <= B; i++) {
int cutI = i % 2;
int prevI = (i - 1) % 2;
for (int j = C; j <= D; j++) {
int count = i * j;
if (count > N) break;
long subChoose = fact[count] * pow(invfact[i], j) % MOD * invfact[j] % MOD;
for (int k = count; k <= N; k++) {
long choose = fact[k] * invfact[count] % MOD * invfact[k - count] % MOD;
long add = dp[prevI][k - count] * subChoose % MOD * choose % MOD;
dp[cutI][k] += add;
if (dp[cutI][k] >= MOD) dp[cutI][k] -= MOD;
}
}
for (int j = 0; j <= N; j++) {
dp[cutI][j] += dp[prevI][j];
if (dp[cutI][j] >= MOD) dp[cutI][j] -= MOD;
}
Arrays.fill(dp[prevI], 0);
}
pw.println(dp[B % 2][N]);
}
public static long pow(long a, int b) {
if (b == 0) return 1;
if ((b & 1) == 0) return pow(a * a % MOD, b >> 1);
return (a * pow(a * a % MOD, b >> 1) % MOD);
}
public static void precompute(){
fact = new long[1001];
invfact = new long[1001];
fact[0] = 1; invfact[0] = (int)pow(1, MOD - 2);
for (int i = 1; i < 1001; i++) {
fact[i] = i * fact[i - 1];
fact[i] %= MOD;
invfact[i] = (int) pow(fact[i], MOD - 2);
}
}
}
static class MyScanner {
StringTokenizer st;
BufferedReader br;
public MyScanner(InputStream s){ br = new BufferedReader(new InputStreamReader(s));}
public MyScanner(FileReader s) throws FileNotFoundException {br = new BufferedReader(s);}
public String next() throws IOException
{
while (st == null || !st.hasMoreTokens())
st = new StringTokenizer(br.readLine());
return st.nextToken();
}
public int nextInt() throws IOException {return Integer.parseInt(next());}
public long nextLong() throws IOException {return Long.parseLong(next());}
public String nextLine() throws IOException {return br.readLine();}
public double nextDouble() throws IOException { return Double.parseDouble(next()); }
public boolean ready() throws IOException {return br.ready();}
}
}
| a.cc:3:1: error: 'import' does not name a type
3 | import java.io.*;
| ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
4 | import java.lang.reflect.Array;
| ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: 'import' does not name a type
5 | import java.math.BigInteger;
| ^~~~~~
a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:6:1: error: 'import' does not name a type
6 | import java.util.*;
| ^~~~~~
a.cc:6:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:8:1: error: expected unqualified-id before 'public'
8 | public class Main {
| ^~~~~~
|
s437609837 | p03832 | C | /*
cat <<EOF >mistaken-paste
*/
#pragma GCC diagnostic ignored "-Wincompatible-pointer-types"
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <time.h>
#define BIG 2000000007
#define VERYBIG 200000000000007LL
#define MOD 1000000007
typedef uint64_t ull;
typedef int64_t sll;
#define N_MAX 2000
#define M_MAX 200000
typedef struct {
int32_t a;
int32_t b;
} hw;
typedef struct {
sll a;
sll b;
} hwll;
typedef struct {
hwll a;
hwll b;
} linell;
typedef struct {
ull s;
ull t;
int32_t c;
} struct_a;
typedef struct {
int32_t from;
int32_t to;
sll cost;
} struct_b;
ull n, m;
ull h, w;
ull k;
ull q;
ull vua, vub, vuc, vud, vue, vuf;
sll vsa, vsb, vsc, vsd, vse, vsf;
long double vra, vrb, vrc;
double vda, vdb, vdc;
size_t slen;
size_t tlen;
char ch, dh;
ull umin (ull x, ull y) {
return (x < y) ? x : y;
}
ull umax (ull x, ull y) {
return (x > y) ? x : y;
}
sll smin (sll x, sll y) {
return (x < y) ? x : y;
}
sll smax (sll x, sll y) {
return (x > y) ? x : y;
}
ull dp[N_MAX + 1];
ull amazing[N_MAX + 100];
ull npkdp[N_MAX + 1][N_MAX + 1];
ull division[N_MAX + 1][N_MAX + 1];
ull npk (ull n, ull k) {
return divide(amazing[n], amazing[n - k], MOD);
}
ull grouping (sll whole, sll members, sll parts) {
// whole_P_(mem*par)/(members!)^parts / parts!
if (!division[members][parts]) {
division[members][parts] = (bitpow(amazing[members], parts, MOD) * amazing[parts]) % MOD;
}
return divide(npk(whole, members * parts), division[members][parts], MOD);
}
ull solve () {
sll i, j, ki;
// ull result = 0;
sll result = 0;
// double result = 0;
ull maybe = 0;
// sll maybe = 0;
ull sum = 0;
// sll sum = 0;
ull item;
ull *dpcell;
time_t start = time(NULL);
amazing[0] = 1;
for (i = 1; i <= n; i++) {
amazing[i] = (amazing[i - 1] * i) % MOD;
}
// printf("%u...\n", time(NULL) - start);
sll latest = n;
dp[n] = 1;
for (i = vua; i <= vub; i++) {
latest = smax(latest - i * vud, 0);
for (j = latest; j + i * vuc <= n; j++) {
for (ki = vuc; ki <= vud; ki++) {
sll xi = j + i * ki;
if (xi > n) break;
if (!dp[xi]) continue;
dp[j] += dp[xi] * grouping(xi, i, ki);
dp[j] %= MOD;
}
// printf("[%lld]; %llu\n", j, dp[j]);
}
// if (i <= 50 || i % 50 == 0) {
// printf("(time: %u) ", time(NULL) - start);
// printf("%lld... [0]:%llu\n", i, dp[0]);
// fflush(stdout);
// }
}
result = dp[0];
printf("%llu\n", result);
return 0;
}
int32_t main (void) {
int32_t i, j;
int32_t x, y;
scanf("%llu", &n, &m);
scanf("%llu%llu%llu%llu", &vua, &vub, &vuc, &vud, &vue, &vuf);
solve();
return 0;
}
| main.c: In function 'npk':
main.c:87:16: error: implicit declaration of function 'divide' [-Wimplicit-function-declaration]
87 | return divide(amazing[n], amazing[n - k], MOD);
| ^~~~~~
main.c: In function 'grouping':
main.c:93:45: error: implicit declaration of function 'bitpow' [-Wimplicit-function-declaration]
93 | division[members][parts] = (bitpow(amazing[members], parts, MOD) * amazing[parts]) % MOD;
| ^~~~~~
|
s001125261 | p03832 | C | /*
cat <<EOF >mistaken-paste
*/
#pragma GCC diagnostic ignored "-Wincompatible-pointer-types"
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <time.h>
#define BIG 2000000007
#define VERYBIG 200000000000007LL
#define MOD 1000000007
typedef uint64_t ull;
typedef int64_t sll;
#define N_MAX 200000
#define M_MAX 200000
#ifdef __cplusplus
#include <queue>
#include <stack>
// #include <tuple>
#include <set>
// using namespace std; // HELL
using std::queue;
using std::priority_queue;
using std::stack;
// using std::tuple;
using std::set;
using std::vector;
using std::greater;
using std::pair;
typedef priority_queue<ull, vector<ull>, greater<ull> > upque123;
typedef priority_queue<ull, vector<ull> > upque321;
typedef priority_queue<sll, vector<sll>, greater<sll> > spque123;
typedef priority_queue<sll, vector<sll> > spque321;
#endif
typedef struct {
int32_t a;
int32_t b;
} hw;
typedef struct {
sll a;
sll b;
} hwll;
typedef struct {
hwll a;
hwll b;
} linell;
typedef struct {
ull s;
ull t;
int32_t c;
} struct_a;
typedef struct {
int32_t from;
int32_t to;
sll cost;
} struct_b;
const hw vector8[8] = {
{-1, -1},
{-1, 0},
{-1, +1},
{ 0, -1},
{ 0, +1},
{+1, -1},
{+1, 0},
{+1, +1}
};
ull n, m;
ull h, w;
ull k;
ull q;
ull vua, vub, vuc, vud, vue, vuf;
sll vsa, vsb, vsc, vsd, vse, vsf;
long double vra, vrb, vrc;
double vda, vdb, vdc;
size_t slen;
size_t tlen;
char ch, dh;
void swap_adj (ull *a, ull *b) {
if (*a != *b) {
ull tmp = *b;
*b = *a;
*a = tmp;
}
return;
}
int32_t digits (ull x) {
int32_t i = 1;
while (x >= 10) {
x /= 10;
i++;
}
return i;
}
ull umin (ull x, ull y) {
return (x < y) ? x : y;
}
ull umax (ull x, ull y) {
return (x > y) ? x : y;
}
sll smin (sll x, sll y) {
return (x < y) ? x : y;
}
sll smax (sll x, sll y) {
return (x > y) ? x : y;
}
ull gcd (ull x, ull y) {
if (x < y) {
return gcd(y, x);
} else if (y == 0) {
return x;
} else {
return gcd(y, x % y);
}
}
ull bitpow (ull a, ull x, ull modulo) {
ull result = 1;
while (x) {
if (x & 1) {
result *= a;
result %= modulo;
}
x /= 2;
a = (a * a) % modulo;
}
return result;
}
ull divide (ull a, ull b, ull modulo) {
return (a * bitpow(b, modulo - 2, modulo)) % modulo;
}
ull ullabs (ull a, ull b) {
if (a >= b) {
return a - b;
} else {
return b - a;
}
}
sll sllabs (sll a, sll b) {
if (a >= b) {
return a - b;
} else {
return b - a;
}
}
sll nibutanlobo (bool (*func)(sll arg), sll ok, sll ng) {
while (sllabs(ok, ng) > 1) {
sll med = (ok + ng) / 2;
if (func(med)) {
ok = med;
} else {
ng = med;
}
// printf("debug: [%lld %lld)\n", ok, ng);
}
if (!func(ok)) return ok * 2 - ng;
return ok;
}
void printUquotient (ull left, ull right) {
const int32_t digits = 20;
printf("%llu.", left / right);
left %= right;
for (int32_t i = 0; i < digits; i++) {
left *= 10;
printf("%1d", left / right);
left %= right;
}
puts("");
return;
}
void printSquotient (sll left, sll right) {
if (left * right < 0) putchar('-');
printUquotient(sllabs(left, 0), sllabs(right, 0));
return;
}
int bitcount (ull n) {
int result = 0;
while (n) {
if (n & 1) result++;
n /= 2;
}
return result;
}
#ifdef __cplusplus
typedef struct {
int32_t to;
sll cost;
} edge;
typedef pair<sll, int32_t> P;
std::vector<edge> g[N_MAX];
void dijk_init (ull n, struct_b arr[]) {
edge x;
for (int32_t i = 0; i < n; i++) {
x.to = arr[i].to;
x.cost = arr[i].cost;
g[arr[i].from].push_back(x);
}
}
bool dijkstra (int s, sll distance[]) {
priority_queue<P, std::vector<P>, greater<P> > que; // (最短距離, 頂点番号)
que.push(P(distance[s], s));
bool ischanged = false;
while (!que.empty()) {
P p = que.top();
que.pop();
sll v = p.second;
if (distance[v] < p.first) continue;
int32_t maxsize = g[v].size();
for (int32_t i = 0; i < maxsize; i++) {
edge e = g[v][i];
if (distance[e.to] > distance[v] + e.cost) {
distance[e.to] = distance[v] + e.cost;
ischanged = true;
que.push(P(distance[e.to], e.to));
}
}
}
return ischanged;
}
#endif
sll dist[N_MAX];
struct_b path[M_MAX * 2];
ull a[N_MAX];
// ull a[M_MAX];
// sll a[N_MAX];
// ull a[N_MAX][N_MAX];
// ull a[M_MAX][M_MAX];
// sll a[N_MAX][N_MAX];
ull b[N_MAX];
// ull b[M_MAX];
// sll b[N_MAX];
// ull c[N_MAX];
sll c[M_MAX];
// char c[N_MAX];
// char s[N_MAX + 1];
// char s[N_MAX + 1][N_MAX + 1];
// char s[N_MAX + 1][M_MAX + 1];
// char t[N_MAX + 1];
// ull alphabets[26];
// ull blphabets[26];
// char alphabets[26];
// ull dp[N_MAX + 1];
// sll dp[N_MAX + 1];
// ull dp[N_MAX + 1][N_MAX + 1];
// sll dp[N_MAX + 1][N_MAX + 1];
// bool dp[N_MAX + 1];
// bool dp[N_MAX + 1][N_MAX + 1];
// hwll arr[N_MAX];
hwll arr[M_MAX];
// hwll brr[M_MAX];
ull dp[N_MAX + 1];
ull amazing[N_MAX + 100];
ull npkdp[N_MAX + 1][N_MAX + 1];
ull division[N_MAX + 1][N_MAX + 1];
double distance (sll x1, sll y1, sll x2, sll y2) {
double xdist2, ydist2, origindist, dist;
xdist2 = (x1 - x2) * (x1 - x2);
ydist2 = (y1 - y2) * (y1 - y2);
return sqrt(xdist2 + ydist2);
}
int32_t pullcomp (const void *left, const void *right) {
ull l = *(ull*)left;
ull r = *(ull*)right;
if (l < r) {
return -1;
}
if (l > r) {
return +1;
}
return 0;
}
int32_t phwllABcomp (const void *left, const void *right) {
hwll l = *(hwll*)left;
hwll r = *(hwll*)right;
if (l.a < r.a) {
return -1;
}
if (l.a > r.a) {
return +1;
}
if (l.b < r.b) {
return -1;
}
if (l.b > r.b) {
return +1;
}
return 0;
}
ull npk (ull n, ull k) {
return divide(amazing[n], amazing[n - k], MOD);
}
ull grouping (sll whole, sll members, sll parts) {
// whole_P_(mem*par)/(members!)^parts / parts!
if (!division[members][parts]) {
division[members][parts] = (bitpow(amazing[members], parts, MOD) * amazing[parts]) % MOD;
}
return divide(npk(whole, members * parts), division[members][parts], MOD);
}
ull solve () {
sll i, j, ki;
// ull result = 0;
sll result = 0;
// double result = 0;
ull maybe = 0;
// sll maybe = 0;
ull sum = 0;
// sll sum = 0;
ull item;
ull *dpcell;
amazing[0] = 1;
for (i = 1; i <= n; i++) {
amazing[i] = (amazing[i - 1] * i) % MOD;
}
sll latest = n;
dp[n] = 1;
for (i = vua; i <= vub; i++) {
latest = smax(latest - i * vud, 0);
for (j = latest; j <= n - i * vuc; j++) {
for (ki = vuc; ki <= vud; ki++) {
sll xi = j + i * ki;
if (xi > n) break;
if (!dp[xi]) continue;
dp[j] += dp[xi] * grouping(xi, i, ki);
dp[j] %= MOD;
}
// printf("[%lld]; %llu\n", j, dp[j]);
}
// if (i <= 50 || i % 50 == 0) {
// printf("%lld... [0]:%llu\n", i, dp[0]);
// fflush(stdout);
// }
}
result = dp[0];
// for (i = 0; i < n; i++) {
// a[i] = arr[i].a;
// b[i] = arr[i].b;
// }
// qsort(a, n, sizeof(ull), pullcomp);
// qsort(b, n, sizeof(ull), pullcomp);
// ull xl = a[(n - 1) / 2], xr = a[n / 2];
// ull yl = b[(n - 1) / 2], yr = b[n / 2];
// ull maxloss = 0;
// ull goodx = arr[0].a, goody = arr[0].b;
// for (i = 0; i < n; i++) {
// result += ullabs(arr[i].a, xl) + ullabs(arr[i].b, yl);
// ull mayx, mayy;
// if (ullabs(arr[i].a, xl) > ullabs(arr[i].a, xr)) {
// mayx = xl;
// } else {
// mayx = xr;
// }
// if (ullabs(arr[i].b, yl) > ullabs(arr[i].b, yr)) {
// mayy = yl;
// } else {
// mayy = yr;
// }
// maybe = ullabs(arr[i].a, mayx) + ullabs(arr[i].b, mayy);
// if (maybe > maxloss) {
// maxloss = maybe;
// goodx = mayx;
// goody = mayy;
// // printf("%llu (%llu,%llu)\n", maxloss, goodx, goody);
// }
// }
// // printf("%llu*2-%llu=\n", result, maybe);
// result = result * 2 - maxloss;
// printf("%llu\n", result);
// printf("%llu %llu\n", goodx + 1, goody + 1);
// printf("%llu\n", result);
// printf("%.12lf\n", (double)result);
// puts(s);
return 0;
success:
// puts("YES");
// puts("Yes");
// printf("%llu\n", result);
// puts("0");
puts("Possible");
return 0;
fail:
// puts("NO");
// puts("No");
// puts("0");
puts("-1");
// puts("-1 -1 -1");
// puts("Impossible");
return 1;
}
int32_t main (void) {
int32_t i, j;
int32_t x, y;
// scanf("%lf%lf", &vda, &vdb);
// scanf("%lld%lld%lld%lld", &vsa, &vsb, &vsc, &vsd);
// scanf("%llu%llu", &vua, &vub, &vuc, &vud);
// scanf("%llu%llu", &h, &w);
// scanf("%*llu%*llu");
scanf("%llu", &n, &m);
// scanf("%llu", &k, &m, &n);
scanf("%llu%llu%llu%llu", &vua, &vub, &vuc, &vud, &vue, &vuf);
// scanf("%lld%lld", &vsa, &vsb, &vsc);
// scanf("%s", s);
// scanf("%s", t);
// scanf("%llu", &m);
// scanf("%llu", &q);
// for (i = 0; i < n; i++) {
// scanf("%llu", &a[i]);
// // a[i]--;
// }
// for (i = 0; i < m; i++) {
// scanf("%llu", &b[i]);
// }
// for (i = 0; i < h; i++) {
// scanf("%llu", &a[i]);
// }
// for (i = 0; i < h; i++) {
// for (j = 0; j < w; j++) {
// scanf("%llu", &a[i][j]);
// }
// }
// for (i = 0; i < w; i++) {
// scanf("%llu", &b[i]);
// }
// for (i = 0; i < m; i++) {
// scanf("%llu", &b[i]);
// }
// for (i = 0; i < h; i++) {
// scanf("%s", s[i]);
// }
// scanf("%s", t);
// for (i = 0; i < n; i++) {
// // scanf("%llu", &a[i]);
// // scanf("%llu", &b[i]);
// scanf("%llu", &arr[i].a);
// scanf("%llu", &arr[i].b);
// // scanf("%llu", &c[i]);
// arr[i].a--;
// arr[i].b--;
// // a[i]--;
// // b[i]--;
// }
// for (i = 0; i < k; i++) {
// scanf("%llu", &c[i]);
// c[i]--;
// }
// for (i = 0; i < m; i++) {
// scanf("%llu%llu", &arr[i].a, &arr[i].b);
// arr[i].a--;
// arr[i].b--;
// }
// for (i = 0; i < k; i++) {
// scanf("%llu%llu", &brr[i].a, &brr[i].b);
// brr[i].a--;
// brr[i].b--;
// }
// for (i = 0; i < m; i++) {
// for (j = 0; j < m; j++) {
// scanf("%llu", &a[i][j]);
// }
// }
// for (i = 0; i < n; i++) {
// scanf("%llu%llu%llu", &a[i], &b[i], &c[i]);
// }
// scanf("%llu", &q);
// scanf("%llu", &k);
// k--;
// for (i = 0; i < q; i++) {
// scanf("%llu%llu%llu", &c[i], &a[i], &b[i]);
// // a[i]--;
// // b[i]--;
// // solve();
// }
// for (i = 0; i < m; i++) {
// scanf("%llu%llu", &arr[i].a, &arr[i].b);
// arr[i].a--;
// arr[i].b--;
// }
// for (i = 0; i < n; i++) {
// for (j = 0; j < m; j++) {
// scanf("%llu", &a[i][j]);
// a[i][j]--;
// }
// }
solve();
// for (i = 0; i < m; i++) {
// scanf("%llu%llu%llu", &vua, &vub, &vuc);
// // scanf("%s%s", s, t);
// // scanf("%f%f%f", &vda, &vdb, &vdc);
// // scanf("%s", s);
// solve();
// }
// while (scanf("%llu%llu", &n, &k), n + k) {
// for (i = 0; i < n; i++) {
// scanf("%llu", &a[i]);
// }
// solve();
// }
return 0;
}
| /usr/bin/ld: /tmp/ccO95XHu.o: in function `distance':
main.c:(.text+0x4ba): undefined reference to `sqrt'
/tmp/ccO95XHu.o: in function `grouping':
main.c:(.text+0x61a): relocation truncated to fit: R_X86_64_PC32 against symbol `division' defined in .bss section in /tmp/ccO95XHu.o
main.c:(.text+0x6b5): relocation truncated to fit: R_X86_64_PC32 against symbol `division' defined in .bss section in /tmp/ccO95XHu.o
main.c:(.text+0x6da): relocation truncated to fit: R_X86_64_PC32 against symbol `division' defined in .bss section in /tmp/ccO95XHu.o
collect2: error: ld returned 1 exit status
|
s483219608 | p03832 | C | /*
cat <<EOF >mistaken-paste
*/
#pragma GCC diagnostic ignored "-Wincompatible-pointer-types"
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <time.h>
#define BIG 2000000007
#define VERYBIG 200000000000007LL
#define MOD 1000000007
typedef uint64_t ull;
typedef int64_t sll;
#define N_MAX 200000
#define M_MAX 200000
#ifdef __cplusplus
#include <queue>
#include <stack>
// #include <tuple>
#include <set>
// using namespace std; // HELL
using std::queue;
using std::priority_queue;
using std::stack;
// using std::tuple;
using std::set;
using std::vector;
using std::greater;
using std::pair;
typedef priority_queue<ull, vector<ull>, greater<ull> > upque123;
typedef priority_queue<ull, vector<ull> > upque321;
typedef priority_queue<sll, vector<sll>, greater<sll> > spque123;
typedef priority_queue<sll, vector<sll> > spque321;
#endif
typedef struct {
int32_t a;
int32_t b;
} hw;
typedef struct {
sll a;
sll b;
} hwll;
typedef struct {
hwll a;
hwll b;
} linell;
typedef struct {
ull s;
ull t;
int32_t c;
} struct_a;
typedef struct {
int32_t from;
int32_t to;
sll cost;
} struct_b;
const hw vector8[8] = {
{-1, -1},
{-1, 0},
{-1, +1},
{ 0, -1},
{ 0, +1},
{+1, -1},
{+1, 0},
{+1, +1}
};
ull n, m;
ull h, w;
ull k;
ull q;
ull vua, vub, vuc, vud, vue, vuf;
sll vsa, vsb, vsc, vsd, vse, vsf;
long double vra, vrb, vrc;
double vda, vdb, vdc;
size_t slen;
size_t tlen;
char ch, dh;
void swap_adj (ull *a, ull *b) {
if (*a != *b) {
ull tmp = *b;
*b = *a;
*a = tmp;
}
return;
}
int32_t digits (ull x) {
int32_t i = 1;
while (x >= 10) {
x /= 10;
i++;
}
return i;
}
ull umin (ull x, ull y) {
return (x < y) ? x : y;
}
ull umax (ull x, ull y) {
return (x > y) ? x : y;
}
sll smin (sll x, sll y) {
return (x < y) ? x : y;
}
sll smax (sll x, sll y) {
return (x > y) ? x : y;
}
ull gcd (ull x, ull y) {
if (x < y) {
return gcd(y, x);
} else if (y == 0) {
return x;
} else {
return gcd(y, x % y);
}
}
ull bitpow (ull a, ull x, ull modulo) {
ull result = 1;
while (x) {
if (x & 1) {
result *= a;
result %= modulo;
}
x /= 2;
a = (a * a) % modulo;
}
return result;
}
ull divide (ull a, ull b, ull modulo) {
return (a * bitpow(b, modulo - 2, modulo)) % modulo;
}
ull ullabs (ull a, ull b) {
if (a >= b) {
return a - b;
} else {
return b - a;
}
}
sll sllabs (sll a, sll b) {
if (a >= b) {
return a - b;
} else {
return b - a;
}
}
sll nibutanlobo (bool (*func)(sll arg), sll ok, sll ng) {
while (sllabs(ok, ng) > 1) {
sll med = (ok + ng) / 2;
if (func(med)) {
ok = med;
} else {
ng = med;
}
// printf("debug: [%lld %lld)\n", ok, ng);
}
if (!func(ok)) return ok * 2 - ng;
return ok;
}
void printUquotient (ull left, ull right) {
const int32_t digits = 20;
printf("%llu.", left / right);
left %= right;
for (int32_t i = 0; i < digits; i++) {
left *= 10;
printf("%1d", left / right);
left %= right;
}
puts("");
return;
}
void printSquotient (sll left, sll right) {
if (left * right < 0) putchar('-');
printUquotient(sllabs(left, 0), sllabs(right, 0));
return;
}
int bitcount (ull n) {
int result = 0;
while (n) {
if (n & 1) result++;
n /= 2;
}
return result;
}
#ifdef __cplusplus
typedef struct {
int32_t to;
sll cost;
} edge;
typedef pair<sll, int32_t> P;
std::vector<edge> g[N_MAX];
void dijk_init (ull n, struct_b arr[]) {
edge x;
for (int32_t i = 0; i < n; i++) {
x.to = arr[i].to;
x.cost = arr[i].cost;
g[arr[i].from].push_back(x);
}
}
bool dijkstra (int s, sll distance[]) {
priority_queue<P, std::vector<P>, greater<P> > que; // (最短距離, 頂点番号)
que.push(P(distance[s], s));
bool ischanged = false;
while (!que.empty()) {
P p = que.top();
que.pop();
sll v = p.second;
if (distance[v] < p.first) continue;
int32_t maxsize = g[v].size();
for (int32_t i = 0; i < maxsize; i++) {
edge e = g[v][i];
if (distance[e.to] > distance[v] + e.cost) {
distance[e.to] = distance[v] + e.cost;
ischanged = true;
que.push(P(distance[e.to], e.to));
}
}
}
return ischanged;
}
#endif
sll dist[N_MAX];
struct_b path[M_MAX * 2];
ull a[N_MAX];
// ull a[M_MAX];
// sll a[N_MAX];
// ull a[N_MAX][N_MAX];
// ull a[M_MAX][M_MAX];
// sll a[N_MAX][N_MAX];
ull b[N_MAX];
// ull b[M_MAX];
// sll b[N_MAX];
// ull c[N_MAX];
sll c[M_MAX];
// char c[N_MAX];
// char s[N_MAX + 1];
// char s[N_MAX + 1][N_MAX + 1];
// char s[N_MAX + 1][M_MAX + 1];
// char t[N_MAX + 1];
// ull alphabets[26];
// ull blphabets[26];
// char alphabets[26];
// ull dp[N_MAX + 1];
// sll dp[N_MAX + 1];
// ull dp[N_MAX + 1][N_MAX + 1];
// sll dp[N_MAX + 1][N_MAX + 1];
// bool dp[N_MAX + 1];
// bool dp[N_MAX + 1][N_MAX + 1];
// hwll arr[N_MAX];
hwll arr[M_MAX];
// hwll brr[M_MAX];
ull dp[N_MAX + 1];
ull amazing[N_MAX + 100];
ull npkdp[N_MAX + 1][N_MAX + 1];
ull division[N_MAX + 1][N_MAX + 1];
double distance (sll x1, sll y1, sll x2, sll y2) {
double xdist2, ydist2, origindist, dist;
xdist2 = (x1 - x2) * (x1 - x2);
ydist2 = (y1 - y2) * (y1 - y2);
return sqrt(xdist2 + ydist2);
}
int32_t pullcomp (const void *left, const void *right) {
ull l = *(ull*)left;
ull r = *(ull*)right;
if (l < r) {
return -1;
}
if (l > r) {
return +1;
}
return 0;
}
int32_t phwllABcomp (const void *left, const void *right) {
hwll l = *(hwll*)left;
hwll r = *(hwll*)right;
if (l.a < r.a) {
return -1;
}
if (l.a > r.a) {
return +1;
}
if (l.b < r.b) {
return -1;
}
if (l.b > r.b) {
return +1;
}
return 0;
}
ull npk (ull n, ull k) {
return divide(amazing[n], amazing[n - k], MOD);
}
ull grouping (sll whole, sll members, sll parts) {
// whole_P_(mem*par)/(members!)^parts / parts!
if (!division[members][parts]) {
division[members][parts] = (bitpow(amazing[members], parts, MOD) * amazing[parts]) % MOD;
}
return divide(npk(whole, members * parts), division[members][parts], MOD);
}
ull solve () {
sll i, j, ki;
// ull result = 0;
sll result = 0;
// double result = 0;
ull maybe = 0;
// sll maybe = 0;
ull sum = 0;
// sll sum = 0;
ull item;
ull *dpcell;
amazing[0] = 1;
for (i = 1; i <= n; i++) {
amazing[i] = (amazing[i - 1] * i) % MOD;
}
sll latest = n;
dp[n] = 1;
for (i = vua; i <= vub; i++) {
latest = smax(latest - i * vud, 0);
for (j = latest; j <= n - i * vuc; j++) {
for (ki = vuc; ki <= vud; ki++) {
sll xi = j + i * ki;
if (xi > n) break;
if (!dp[xi]) continue;
dp[j] += dp[xi] * grouping(xi, i, ki);
dp[j] %= MOD;
}
// printf("[%lld]; %llu\n", j, dp[j]);
}
// if (i <= 50 || i % 50 == 0) {
// printf("%lld... [0]:%llu\n", i, dp[0]);
// fflush(stdout);
// }
}
result = dp[0];
// for (i = 0; i < n; i++) {
// a[i] = arr[i].a;
// b[i] = arr[i].b;
// }
// qsort(a, n, sizeof(ull), pullcomp);
// qsort(b, n, sizeof(ull), pullcomp);
// ull xl = a[(n - 1) / 2], xr = a[n / 2];
// ull yl = b[(n - 1) / 2], yr = b[n / 2];
// ull maxloss = 0;
// ull goodx = arr[0].a, goody = arr[0].b;
// for (i = 0; i < n; i++) {
// result += ullabs(arr[i].a, xl) + ullabs(arr[i].b, yl);
// ull mayx, mayy;
// if (ullabs(arr[i].a, xl) > ullabs(arr[i].a, xr)) {
// mayx = xl;
// } else {
// mayx = xr;
// }
// if (ullabs(arr[i].b, yl) > ullabs(arr[i].b, yr)) {
// mayy = yl;
// } else {
// mayy = yr;
// }
// maybe = ullabs(arr[i].a, mayx) + ullabs(arr[i].b, mayy);
// if (maybe > maxloss) {
// maxloss = maybe;
// goodx = mayx;
// goody = mayy;
// // printf("%llu (%llu,%llu)\n", maxloss, goodx, goody);
// }
// }
// // printf("%llu*2-%llu=\n", result, maybe);
// result = result * 2 - maxloss;
// printf("%llu\n", result);
// printf("%llu %llu\n", goodx + 1, goody + 1);
// printf("%llu\n", result);
// printf("%.12lf\n", (double)result);
// puts(s);
return 0;
success:
// puts("YES");
// puts("Yes");
// printf("%llu\n", result);
// puts("0");
puts("Possible");
return 0;
fail:
// puts("NO");
// puts("No");
// puts("0");
puts("-1");
// puts("-1 -1 -1");
// puts("Impossible");
return 1;
}
int32_t main (void) {
int32_t i, j;
int32_t x, y;
// scanf("%lf%lf", &vda, &vdb);
// scanf("%lld%lld%lld%lld", &vsa, &vsb, &vsc, &vsd);
// scanf("%llu%llu", &vua, &vub, &vuc, &vud);
// scanf("%llu%llu", &h, &w);
scanf("%*llu%*llu");
scanf("%llu", &n, &m);
// scanf("%llu", &k, &m, &n);
// scanf("%llu%llu%llu%llu", &vua, &vub, &vuc, &vud, &vue, &vuf);
// scanf("%lld%lld", &vsa, &vsb, &vsc);
// scanf("%s", s);
// scanf("%s", t);
// scanf("%llu", &m);
// scanf("%llu", &q);
// for (i = 0; i < n; i++) {
// scanf("%llu", &a[i]);
// // a[i]--;
// }
// for (i = 0; i < m; i++) {
// scanf("%llu", &b[i]);
// }
// for (i = 0; i < h; i++) {
// scanf("%llu", &a[i]);
// }
// for (i = 0; i < h; i++) {
// for (j = 0; j < w; j++) {
// scanf("%llu", &a[i][j]);
// }
// }
// for (i = 0; i < w; i++) {
// scanf("%llu", &b[i]);
// }
// for (i = 0; i < m; i++) {
// scanf("%llu", &b[i]);
// }
// for (i = 0; i < h; i++) {
// scanf("%s", s[i]);
// }
// scanf("%s", t);
for (i = 0; i < n; i++) {
// scanf("%llu", &a[i]);
// scanf("%llu", &b[i]);
scanf("%llu", &arr[i].a);
scanf("%llu", &arr[i].b);
// scanf("%llu", &c[i]);
arr[i].a--;
arr[i].b--;
// a[i]--;
// b[i]--;
}
// for (i = 0; i < k; i++) {
// scanf("%llu", &c[i]);
// c[i]--;
// }
// for (i = 0; i < m; i++) {
// scanf("%llu%llu", &arr[i].a, &arr[i].b);
// arr[i].a--;
// arr[i].b--;
// }
// for (i = 0; i < k; i++) {
// scanf("%llu%llu", &brr[i].a, &brr[i].b);
// brr[i].a--;
// brr[i].b--;
// }
// for (i = 0; i < m; i++) {
// for (j = 0; j < m; j++) {
// scanf("%llu", &a[i][j]);
// }
// }
// for (i = 0; i < n; i++) {
// scanf("%llu%llu%llu", &a[i], &b[i], &c[i]);
// }
// scanf("%llu", &q);
// scanf("%llu", &k);
// k--;
// for (i = 0; i < q; i++) {
// scanf("%llu%llu%llu", &c[i], &a[i], &b[i]);
// // a[i]--;
// // b[i]--;
// // solve();
// }
// for (i = 0; i < m; i++) {
// scanf("%llu%llu", &arr[i].a, &arr[i].b);
// arr[i].a--;
// arr[i].b--;
// }
// for (i = 0; i < n; i++) {
// for (j = 0; j < m; j++) {
// scanf("%llu", &a[i][j]);
// a[i][j]--;
// }
// }
solve();
// for (i = 0; i < m; i++) {
// scanf("%llu%llu%llu", &vua, &vub, &vuc);
// // scanf("%s%s", s, t);
// // scanf("%f%f%f", &vda, &vdb, &vdc);
// // scanf("%s", s);
// solve();
// }
// while (scanf("%llu%llu", &n, &k), n + k) {
// for (i = 0; i < n; i++) {
// scanf("%llu", &a[i]);
// }
// solve();
// }
return 0;
}
| /usr/bin/ld: /tmp/cclfx8Qq.o: in function `distance':
main.c:(.text+0x4ba): undefined reference to `sqrt'
/tmp/cclfx8Qq.o: in function `grouping':
main.c:(.text+0x61a): relocation truncated to fit: R_X86_64_PC32 against symbol `division' defined in .bss section in /tmp/cclfx8Qq.o
main.c:(.text+0x6b5): relocation truncated to fit: R_X86_64_PC32 against symbol `division' defined in .bss section in /tmp/cclfx8Qq.o
main.c:(.text+0x6da): relocation truncated to fit: R_X86_64_PC32 against symbol `division' defined in .bss section in /tmp/cclfx8Qq.o
collect2: error: ld returned 1 exit status
|
s786055064 | p03832 | C | /*
cat <<EOF >mistaken-paste
*/
#pragma GCC diagnostic ignored "-Wincompatible-pointer-types"
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <time.h>
#define BIG 2000000007
#define VERYBIG 200000000000007LL
#define MOD 1000000007
typedef uint64_t ull;
typedef int64_t sll;
#define N_MAX 200000
#define M_MAX 200000
#ifdef __cplusplus
#include <queue>
#include <stack>
// #include <tuple>
#include <set>
// using namespace std; // HELL
using std::queue;
using std::priority_queue;
using std::stack;
// using std::tuple;
using std::set;
using std::vector;
using std::greater;
using std::pair;
typedef priority_queue<ull, vector<ull>, greater<ull> > upque123;
typedef priority_queue<ull, vector<ull> > upque321;
typedef priority_queue<sll, vector<sll>, greater<sll> > spque123;
typedef priority_queue<sll, vector<sll> > spque321;
#endif
typedef struct {
int32_t a;
int32_t b;
} hw;
typedef struct {
sll a;
sll b;
} hwll;
typedef struct {
hwll a;
hwll b;
} linell;
typedef struct {
ull s;
ull t;
int32_t c;
} struct_a;
typedef struct {
int32_t from;
int32_t to;
sll cost;
} struct_b;
const hw vector8[8] = {
{-1, -1},
{-1, 0},
{-1, +1},
{ 0, -1},
{ 0, +1},
{+1, -1},
{+1, 0},
{+1, +1}
};
ull n, m;
ull h, w;
ull k;
ull q;
ull vua, vub, vuc, vud, vue, vuf;
sll vsa, vsb, vsc, vsd, vse, vsf;
long double vra, vrb, vrc;
double vda, vdb, vdc;
size_t slen;
size_t tlen;
char ch, dh;
void swap_adj (ull *a, ull *b) {
if (*a != *b) {
ull tmp = *b;
*b = *a;
*a = tmp;
}
return;
}
int32_t digits (ull x) {
int32_t i = 1;
while (x >= 10) {
x /= 10;
i++;
}
return i;
}
ull umin (ull x, ull y) {
return (x < y) ? x : y;
}
ull umax (ull x, ull y) {
return (x > y) ? x : y;
}
sll smin (sll x, sll y) {
return (x < y) ? x : y;
}
sll smax (sll x, sll y) {
return (x > y) ? x : y;
}
ull gcd (ull x, ull y) {
if (x < y) {
return gcd(y, x);
} else if (y == 0) {
return x;
} else {
return gcd(y, x % y);
}
}
ull bitpow (ull a, ull x, ull modulo) {
ull result = 1;
while (x) {
if (x & 1) {
result *= a;
result %= modulo;
}
x /= 2;
a = (a * a) % modulo;
}
return result;
}
ull divide (ull a, ull b, ull modulo) {
return (a * bitpow(b, modulo - 2, modulo)) % modulo;
}
ull ullabs (ull a, ull b) {
if (a >= b) {
return a - b;
} else {
return b - a;
}
}
sll sllabs (sll a, sll b) {
if (a >= b) {
return a - b;
} else {
return b - a;
}
}
sll nibutanlobo (bool (*func)(sll arg), sll ok, sll ng) {
while (sllabs(ok, ng) > 1) {
sll med = (ok + ng) / 2;
if (func(med)) {
ok = med;
} else {
ng = med;
}
// printf("debug: [%lld %lld)\n", ok, ng);
}
if (!func(ok)) return ok * 2 - ng;
return ok;
}
void printUquotient (ull left, ull right) {
const int32_t digits = 20;
printf("%llu.", left / right);
left %= right;
for (int32_t i = 0; i < digits; i++) {
left *= 10;
printf("%1d", left / right);
left %= right;
}
puts("");
return;
}
void printSquotient (sll left, sll right) {
if (left * right < 0) putchar('-');
printUquotient(sllabs(left, 0), sllabs(right, 0));
return;
}
int bitcount (ull n) {
int result = 0;
while (n) {
if (n & 1) result++;
n /= 2;
}
return result;
}
#ifdef __cplusplus
typedef struct {
int32_t to;
sll cost;
} edge;
typedef pair<sll, int32_t> P;
std::vector<edge> g[N_MAX];
void dijk_init (ull n, struct_b arr[]) {
edge x;
for (int32_t i = 0; i < n; i++) {
x.to = arr[i].to;
x.cost = arr[i].cost;
g[arr[i].from].push_back(x);
}
}
bool dijkstra (int s, sll distance[]) {
priority_queue<P, std::vector<P>, greater<P> > que; // (最短距離, 頂点番号)
que.push(P(distance[s], s));
bool ischanged = false;
while (!que.empty()) {
P p = que.top();
que.pop();
sll v = p.second;
if (distance[v] < p.first) continue;
int32_t maxsize = g[v].size();
for (int32_t i = 0; i < maxsize; i++) {
edge e = g[v][i];
if (distance[e.to] > distance[v] + e.cost) {
distance[e.to] = distance[v] + e.cost;
ischanged = true;
que.push(P(distance[e.to], e.to));
}
}
}
return ischanged;
}
#endif
sll dist[N_MAX];
struct_b path[M_MAX * 2];
ull a[N_MAX];
// ull a[M_MAX];
// sll a[N_MAX];
// ull a[N_MAX][N_MAX];
// ull a[M_MAX][M_MAX];
// sll a[N_MAX][N_MAX];
ull b[N_MAX];
// ull b[M_MAX];
// sll b[N_MAX];
// ull c[N_MAX];
sll c[M_MAX];
// char c[N_MAX];
// char s[N_MAX + 1];
// char s[N_MAX + 1][N_MAX + 1];
// char s[N_MAX + 1][M_MAX + 1];
// char t[N_MAX + 1];
// ull alphabets[26];
// ull blphabets[26];
// char alphabets[26];
// ull dp[N_MAX + 1];
// sll dp[N_MAX + 1];
// ull dp[N_MAX + 1][N_MAX + 1];
// sll dp[N_MAX + 1][N_MAX + 1];
// bool dp[N_MAX + 1];
// bool dp[N_MAX + 1][N_MAX + 1];
// hwll arr[N_MAX];
hwll arr[M_MAX];
// hwll brr[M_MAX];
ull dp[N_MAX + 1];
ull amazing[N_MAX + 100];
ull npkdp[N_MAX + 1][N_MAX + 1];
ull division[N_MAX + 1][N_MAX + 1];
double distance (sll x1, sll y1, sll x2, sll y2) {
double xdist2, ydist2, origindist, dist;
xdist2 = (x1 - x2) * (x1 - x2);
ydist2 = (y1 - y2) * (y1 - y2);
return sqrt(xdist2 + ydist2);
}
int32_t pullcomp (const void *left, const void *right) {
ull l = *(ull*)left;
ull r = *(ull*)right;
if (l < r) {
return -1;
}
if (l > r) {
return +1;
}
return 0;
}
int32_t phwllABcomp (const void *left, const void *right) {
hwll l = *(hwll*)left;
hwll r = *(hwll*)right;
if (l.a < r.a) {
return -1;
}
if (l.a > r.a) {
return +1;
}
if (l.b < r.b) {
return -1;
}
if (l.b > r.b) {
return +1;
}
return 0;
}
ull npk (ull n, ull k) {
return divide(amazing[n], amazing[n - k], MOD);
}
ull grouping (sll whole, sll members, sll parts) {
// whole_P_(mem*par)/(members!)^parts / parts!
if (!division[members][parts]) {
division[members][parts] = (bitpow(amazing[i], j, MOD) * amazing[j]) % MOD;
}
return divide(npk(whole, members * parts), division[members][parts], MOD);
}
ull solve () {
sll i, j, ki;
// ull result = 0;
sll result = 0;
// double result = 0;
ull maybe = 0;
// sll maybe = 0;
ull sum = 0;
// sll sum = 0;
ull item;
ull *dpcell;
amazing[0] = 1;
for (i = 1; i <= n; i++) {
amazing[i] = (amazing[i - 1] * i) % MOD;
}
sll latest = n;
dp[n] = 1;
for (i = vua; i <= vub; i++) {
latest = smax(latest - i * vud, 0);
for (j = latest; j <= n - i * vuc; j++) {
for (ki = vuc; ki <= vud; ki++) {
sll xi = j + i * ki;
if (xi > n) break;
if (!dp[xi]) continue;
dp[j] += dp[xi] * grouping(xi, i, ki);
dp[j] %= MOD;
}
// printf("[%lld]; %llu\n", j, dp[j]);
}
// if (i <= 50 || i % 50 == 0) {
// printf("%lld... [0]:%llu\n", i, dp[0]);
// fflush(stdout);
// }
}
result = dp[0];
// for (i = 0; i < n; i++) {
// a[i] = arr[i].a;
// b[i] = arr[i].b;
// }
// qsort(a, n, sizeof(ull), pullcomp);
// qsort(b, n, sizeof(ull), pullcomp);
// ull xl = a[(n - 1) / 2], xr = a[n / 2];
// ull yl = b[(n - 1) / 2], yr = b[n / 2];
// ull maxloss = 0;
// ull goodx = arr[0].a, goody = arr[0].b;
// for (i = 0; i < n; i++) {
// result += ullabs(arr[i].a, xl) + ullabs(arr[i].b, yl);
// ull mayx, mayy;
// if (ullabs(arr[i].a, xl) > ullabs(arr[i].a, xr)) {
// mayx = xl;
// } else {
// mayx = xr;
// }
// if (ullabs(arr[i].b, yl) > ullabs(arr[i].b, yr)) {
// mayy = yl;
// } else {
// mayy = yr;
// }
// maybe = ullabs(arr[i].a, mayx) + ullabs(arr[i].b, mayy);
// if (maybe > maxloss) {
// maxloss = maybe;
// goodx = mayx;
// goody = mayy;
// // printf("%llu (%llu,%llu)\n", maxloss, goodx, goody);
// }
// }
// // printf("%llu*2-%llu=\n", result, maybe);
// result = result * 2 - maxloss;
// printf("%llu\n", result);
// printf("%llu %llu\n", goodx + 1, goody + 1);
// printf("%llu\n", result);
// printf("%.12lf\n", (double)result);
// puts(s);
return 0;
success:
// puts("YES");
// puts("Yes");
// printf("%llu\n", result);
// puts("0");
puts("Possible");
return 0;
fail:
// puts("NO");
// puts("No");
// puts("0");
puts("-1");
// puts("-1 -1 -1");
// puts("Impossible");
return 1;
}
int32_t main (void) {
int32_t i, j;
int32_t x, y;
// scanf("%lf%lf", &vda, &vdb);
// scanf("%lld%lld%lld%lld", &vsa, &vsb, &vsc, &vsd);
// scanf("%llu%llu", &vua, &vub, &vuc, &vud);
// scanf("%llu%llu", &h, &w);
scanf("%*llu%*llu");
scanf("%llu", &n, &m);
// scanf("%llu", &k, &m, &n);
// scanf("%llu%llu%llu%llu", &vua, &vub, &vuc, &vud, &vue, &vuf);
// scanf("%lld%lld", &vsa, &vsb, &vsc);
// scanf("%s", s);
// scanf("%s", t);
// scanf("%llu", &m);
// scanf("%llu", &q);
// for (i = 0; i < n; i++) {
// scanf("%llu", &a[i]);
// // a[i]--;
// }
// for (i = 0; i < m; i++) {
// scanf("%llu", &b[i]);
// }
// for (i = 0; i < h; i++) {
// scanf("%llu", &a[i]);
// }
// for (i = 0; i < h; i++) {
// for (j = 0; j < w; j++) {
// scanf("%llu", &a[i][j]);
// }
// }
// for (i = 0; i < w; i++) {
// scanf("%llu", &b[i]);
// }
// for (i = 0; i < m; i++) {
// scanf("%llu", &b[i]);
// }
// for (i = 0; i < h; i++) {
// scanf("%s", s[i]);
// }
// scanf("%s", t);
for (i = 0; i < n; i++) {
// scanf("%llu", &a[i]);
// scanf("%llu", &b[i]);
scanf("%llu", &arr[i].a);
scanf("%llu", &arr[i].b);
// scanf("%llu", &c[i]);
arr[i].a--;
arr[i].b--;
// a[i]--;
// b[i]--;
}
// for (i = 0; i < k; i++) {
// scanf("%llu", &c[i]);
// c[i]--;
// }
// for (i = 0; i < m; i++) {
// scanf("%llu%llu", &arr[i].a, &arr[i].b);
// arr[i].a--;
// arr[i].b--;
// }
// for (i = 0; i < k; i++) {
// scanf("%llu%llu", &brr[i].a, &brr[i].b);
// brr[i].a--;
// brr[i].b--;
// }
// for (i = 0; i < m; i++) {
// for (j = 0; j < m; j++) {
// scanf("%llu", &a[i][j]);
// }
// }
// for (i = 0; i < n; i++) {
// scanf("%llu%llu%llu", &a[i], &b[i], &c[i]);
// }
// scanf("%llu", &q);
// scanf("%llu", &k);
// k--;
// for (i = 0; i < q; i++) {
// scanf("%llu%llu%llu", &c[i], &a[i], &b[i]);
// // a[i]--;
// // b[i]--;
// // solve();
// }
// for (i = 0; i < m; i++) {
// scanf("%llu%llu", &arr[i].a, &arr[i].b);
// arr[i].a--;
// arr[i].b--;
// }
// for (i = 0; i < n; i++) {
// for (j = 0; j < m; j++) {
// scanf("%llu", &a[i][j]);
// a[i][j]--;
// }
// }
solve();
// for (i = 0; i < m; i++) {
// scanf("%llu%llu%llu", &vua, &vub, &vuc);
// // scanf("%s%s", s, t);
// // scanf("%f%f%f", &vda, &vdb, &vdc);
// // scanf("%s", s);
// solve();
// }
// while (scanf("%llu%llu", &n, &k), n + k) {
// for (i = 0; i < n; i++) {
// scanf("%llu", &a[i]);
// }
// solve();
// }
return 0;
}
| main.c: In function 'grouping':
main.c:355:60: error: 'i' undeclared (first use in this function)
355 | division[members][parts] = (bitpow(amazing[i], j, MOD) * amazing[j]) % MOD;
| ^
main.c:355:60: note: each undeclared identifier is reported only once for each function it appears in
main.c:355:64: error: 'j' undeclared (first use in this function)
355 | division[members][parts] = (bitpow(amazing[i], j, MOD) * amazing[j]) % MOD;
| ^
|
s870557366 | p03832 | C++ | #include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
const double PI = M_PI;
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
/* Coding Space*/
class FermatCombination{
public:
vector<ll> factrial; // 階乗
vector<ll> inverse; // 逆元
FermatCombination(int size){
factrial.resize(size+1);
inverse.resize(size+1);
factrial[0] = 1;
inverse[0] = 1;
for(int i = 1; i < size+1; i++){
factrial[i] = factrial[i-1] * i % DIV;
inverse[i] = pow(factrial[i],DIV-2,DIV);
}
}
ll combination(int n, int k){
if(n < k) return 0;
return factrial[n]* inverse[k] % DIV * inverse[n - k] % DIV;
}
ll permutation(int n, int k){
if(n < k) return 0;
return factrial[n] * inverse[n-k] % DIV;
}
ll multi_choose(int n, int k){
if(n == 0 && k == 0) return 1;
else return combination(n+k-1,k);
}
};
ll dp[1010][1010] = {}; // i : members of group, j : number of using.
int main(){
int n,a,b,c,d; cin >> n >> a >> b >> c >> d;
FermatCombination fc(n+1);
rep(i,1010) dp[i][0] = 1;
for(int i = a; i <= b; i++)
for(int j = 0; j <= n; j++){
if(dp[i][j] == 0) continue;
if(j != 0){
dp[i+1][j] += dp[i][j];
dp[i][j] %= DIV;
}
ll tmp = 1;
for(int k = 1; k <= d; k++){
if(n-j-i*k- < 0) break;
tmp *= fc.combination(n-j-i*(k-1), i );
tmp %= DIV;
tmp *= fc.inverse[k];
tmp %= DIV;
if(k >= c && k <= d){
dp[i+1][j+i*k] += 1LL * dp[i][j] * tmp;
dp[i+1][j+i*k] %= DIV;
}
}
}
cout << dp[b+1][n] % DIV << endl;
} | a.cc: In function 'int main()':
a.cc:70:21: error: expected primary-expression before '<' token
70 | if(n-j-i*k- < 0) break;
| ^
|
s267359213 | p03832 | C++ | #include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long
using namespace std;
struct Culc {
vector<long long> factorial;
long long p;
//階乗
Culc(long long N, long long p_) {
long long ans = 1;
p=p_;
factorial.push_back(ans);
for (long long i = 1; i <= N; i++) {
ans = ans * i % p;
factorial.push_back(ans);
}
}
long long extgcd(long long a, long long b, long long &x, long long &y) {
long long g = a;
if (b) {
g = extgcd(b, a % b, y, x);
y -= x * (a / b);
} else {
x = 1;
y = 0;
}
return g;
}
long long gcd(long long a, long long b) {
return b == 0 ? a : gcd(b, a % b);
}
long long lcm(long long a, long long b) {
return a * b / gcd(a, b);
}
long long inverse(long long a, long long p) {
long long x, y;
extgcd(a, p, x, y);
return ((x % p) + p) % p;
}
//nCk mod p
//
long long combination(long long n, long long k) {
return factorial[n] * (inverse(factorial[k] * factorial[n - k] % p, p)) % p;
}
};
int main(){
int N,A,B,C,D;cin>>N>>A>>B>>C>>D;
LL inf = 1e9+7;
//dp[i][j]:i人をj人以下のグループで分けるときの組み合わせ
//dp[i][j] = dp[i][j-1] + iCj * dp[i-j][j-1] + iCj*(i-j)Cj/2 * dp[i-2*j][j-1] + ...
//=dp[i][j-1] + sigma(for k=C; k<=D&&kj<=i;k++) dp[i-kj][j-1]* (iCj*(i-j)Cj*...*(i-(k-1)j)Cj)/k!
//k=0 or C<=k<=D
LL dp[N+1][B+1];
fill(dp[0],dp[N+1],0);
REP(i,B+1)dp[0][i]=1;
Culc culc(N+1,inf);
REP(i,N+1){
for(int j=A;j<=B;j++){
LL sigma =0;
LL comb=1;
LL cnt=0;
for(int k=C;k<=D&&k*j<=i;k++){
cnt++;
comb = (comb*culc.combination(i-j*(k-C),j))%inf;
sigma += (((dp[i-k*j][j-1]*comb)%inf)*culc.inverse(culc.factorial[k],inf)%inf;
sigma %=inf;
}
dp[i][j]=(dp[i][j-1]+sigma)%inf;
}
}
cout<<dp[N][B]<<endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:80:94: error: expected ')' before ';' token
80 | sigma += (((dp[i-k*j][j-1]*comb)%inf)*culc.inverse(culc.factorial[k],inf)%inf;
| ~ ^
| )
|
s053057018 | p03832 | C++ | class Euclid {
private:
ll m, n;
vvll mx_multiply(vvll mx1, vvll mx2) {
vvll ret(mx1.size(), vll(mx2[0].size(), 0));
Loop(i, mx1.size()) {
Loop(j, mx1[0].size()) {
Loop(k, mx2[0].size()) {
ret[i][j] += mx1[i][k] * mx2[k][j];
}
}
}
return ret;
}
public:
ll x, y, gcd;
Euclid(ll M, ll N) {
m = M;
n = N;
}
//mx+ny=gcd(m,n)であるx,yを求める
void mainfunc() {
vll r(100), k(100);
bool swapflag = false, mflag = false, nflag = false;
if (m < n) { swap(m, n); swapflag = true; }
if (m < 0) { m *= -1; mflag = true; }
if (n < 0) { n *= -1; nflag = true; }
r[0] = m;
r[1] = n;
int h = 1;
while (1) {
k[h - 1] = r[h - 1] / r[h];
r[h + 1] = r[h - 1] % r[h];
if (r[h + 1] == 0) break;
h++;
}
gcd = r[h];
vvll mx(2, vll(2, 1));
mx[0][0] = 0;
mx[1][1] = (-1) * k[0];
Loop1(i, h - 1) {
vvll multiplier(2, vll(2, 1));
multiplier[0][0] = 0;
multiplier[1][1] = (-1) * k[i];
mx = mx_multiply(multiplier, mx);
}
x = mx[0][0];
y = mx[0][1];
if (nflag) { n *= -1; y *= -1; }
if (mflag) { m *= -1; x *= -1; }
if (swapflag) { swap(m, n); swap(x, y); }
}
};
//x! O(x)
vll mod_factorial(ll x, ll mod) {
if (x < 0) return{};
else {
vll ret((int)x + 1);
ret[0] = 1;
Loop1(i, (int)x) ret[i] = ret[i - 1] * i % mod;
return ret;
}
}
//p!/(Πary!) O(p+log(Σary))
ll mod_multicombination(ll p, vll ary, ll mod) {
vll fact = mod_factorial(p, mod);
p = fact[(int)p];
Loop(i, ary.size()) ary[i] = fact[(int)ary[i]];
ll q = 1;
Loop(i, ary.size()) q = q * ary[i] % mod;
Euclid *euclid = new Euclid(q, mod * (-1));
euclid->mainfunc();
ll r = euclid->x;
if (r < 0) r += (r / mod*(-1) + 1) * mod;
return p * r % mod;
}
//x^y
ll mod_pow(ll x, ll y, ll mod) {
if (y == 1) return x;
else {
ll ans = mod_pow(x, y / 2, mod);
ans = ans * ans % mod;
if (y % 2 == 1) ans = ans * x % mod;
return ans;
}
} | a.cc:3:9: error: 'll' does not name a type
3 | ll m, n;
| ^~
a.cc:4:9: error: 'vvll' does not name a type
4 | vvll mx_multiply(vvll mx1, vvll mx2) {
| ^~~~
a.cc:16:9: error: 'll' does not name a type
16 | ll x, y, gcd;
| ^~
a.cc:17:18: error: expected ')' before 'M'
17 | Euclid(ll M, ll N) {
| ~ ^~
| )
a.cc: In member function 'void Euclid::mainfunc()':
a.cc:23:17: error: 'vll' was not declared in this scope
23 | vll r(100), k(100);
| ^~~
a.cc:25:21: error: 'm' was not declared in this scope
25 | if (m < n) { swap(m, n); swapflag = true; }
| ^
a.cc:25:25: error: 'n' was not declared in this scope
25 | if (m < n) { swap(m, n); swapflag = true; }
| ^
a.cc:25:30: error: 'swap' was not declared in this scope
25 | if (m < n) { swap(m, n); swapflag = true; }
| ^~~~
a.cc:26:21: error: 'm' was not declared in this scope
26 | if (m < 0) { m *= -1; mflag = true; }
| ^
a.cc:27:21: error: 'n' was not declared in this scope
27 | if (n < 0) { n *= -1; nflag = true; }
| ^
a.cc:28:17: error: 'r' was not declared in this scope
28 | r[0] = m;
| ^
a.cc:28:24: error: 'm' was not declared in this scope
28 | r[0] = m;
| ^
a.cc:29:24: error: 'n' was not declared in this scope
29 | r[1] = n;
| ^
a.cc:32:25: error: 'k' was not declared in this scope
32 | k[h - 1] = r[h - 1] / r[h];
| ^
a.cc:37:17: error: 'gcd' was not declared in this scope
37 | gcd = r[h];
| ^~~
a.cc:38:17: error: 'vvll' was not declared in this scope
38 | vvll mx(2, vll(2, 1));
| ^~~~
a.cc:39:17: error: 'mx' was not declared in this scope
39 | mx[0][0] = 0;
| ^~
a.cc:40:35: error: 'k' was not declared in this scope
40 | mx[1][1] = (-1) * k[0];
| ^
a.cc:41:23: error: 'i' was not declared in this scope
41 | Loop1(i, h - 1) {
| ^
a.cc:41:17: error: 'Loop1' was not declared in this scope
41 | Loop1(i, h - 1) {
| ^~~~~
a.cc:47:17: error: 'x' was not declared in this scope
47 | x = mx[0][0];
| ^
a.cc:48:17: error: 'y' was not declared in this scope
48 | y = mx[0][1];
| ^
a.cc:51:33: error: 'swap' was not declared in this scope
51 | if (swapflag) { swap(m, n); swap(x, y); }
| ^~~~
a.cc: At global scope:
a.cc:56:1: error: 'vll' does not name a type
56 | vll mod_factorial(ll x, ll mod) {
| ^~~
a.cc:70:1: error: 'll' does not name a type
70 | ll mod_multicombination(ll p, vll ary, ll mod) {
| ^~
a.cc:84:1: error: 'll' does not name a type
84 | ll mod_pow(ll x, ll y, ll mod) {
| ^~
|
s652388584 | p03832 | C++ | #include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define sz(a) ((int)(a).size())
#define rep(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define dec(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define clr(a,v) memset(a, v, sizeof(a))
#define all(a) (a).begin(),(a).end()
#define MAXN 1010
#define N 1010
#define LOGN 20
#define buli(x) (__builtin_popcountll(x))
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;
inline void gn(long long&x){
int sg=1;char c;while(((c=getchar())<'0'||c>'9')&&c!='-');c=='-'?(sg=-1,x=0):(x=c-'0');
while((c=getchar())>='0'&&c<='9')x=x*10+c-'0';x*=sg;
}
inline void gn(int&x){long long t;gn(t);x=t;}
inline void gn(unsigned long long&x){long long t;gn(t);x=t;}
inline void gn(double&x){double t;scanf("%lf",&t);x=t;}
inline void gn(long double&x){double t;scanf("%lf",&t);x=t;}
inline void gs(char *s){scanf("%s",s);}
inline void gc(char &c){while((c=getchar())>126 || c<33);}
const int mod = 1e9+7;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
#define int long long
int a, b, c, d, n;
ll fat[N], ifat[N], mat[N][N];
int dp[N][N], dp2[N][N];
void pre(){
rep(i,0,MAXN){
mat[i][0]=mat[i][i]=1;
rep(j,0,i){
mat[i][j]=(mat[i-1][j]+mat[i-1][j-1])%mod;
}
}
}
ll comb(int x, int y){
return mat[x][y];
}
ll solve2(int qt, int t){
if(qt == 1) return 1;
if(dp2[qt][t]!=-1)return dp2[qt][t];
ll ans =0;
ans = (solve2(qt-1,t)*comb(qt*t, t))%mod;
ans*=ifat[qt];
ans%=mod;
return dp2[qt][t]=ans;
}
int solve(int p, int t){
if(p == 0)return 1;
if(t >b)return 0;
if(dp[p][t]!=-1)return dp[p][t];
ll ans=0;
ans += solve(p,t+1);
ans%=mod;
for (int i = c; i <= d && i * t <= p; i++){
ans += (solve(p - (i * t), t + 1) * ((comb(p, t * i) * solve2(i, t))%mod))%mod;
ans %=mod;
}
return dp[p][t]=ans;
}
int main()
{
fat[1]=1;
rep(i,2,MAXN)fat[i]= (fat[i-1]*i)%mod;
rep(i,1,MAXN)ifat[i]=powmod(fat[i],mod-2);
gn(n); gn(a);gn(b);gn(c);gn(d);
pre();
clr(dp, -1);
clr(dp2, -1);
printf("%d\n", solve(n, a));
return 0;
}
| cc1plus: error: '::main' must return 'int'
|
s091046591 | p03832 | C++ | #include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
#define INF INT_MAX/3
#define MAX_N 1000
#define M 1000000007
ll fact[11111];
//// extended gcd
ll extgcd(ll a,ll b,ll& x,ll& y){
ll d=a;
if(b!=0){
d=extgcd(b,a%b,y,x);
y-=(a/b)*x;
}else{
x=1;y=0;
}
return d;
}
//// mod inverse
ll mod_inverse(ll a,ll m){
ll x,y;
extgcd(a,m,x,y);
return (m+x%m)%m;
}
//// mod combination ex.( num of route (0,0)->(x,y)=mod_comb(x+y,x,M)
ll mod_comb(int n,int k,int p){
if(n<0||k<0||n<k)return 0;
return ((fact[n]*mod_inverse(fact[k],p))%p)*mod_inverse(fact[n-k],p)%p;
}
ll dp[1111][1111];
ll a,b,c,d;
ll dfs(ll g,ll rest){
if(rest==0)return 1;
else if(rest<g||g>b)return 0;
else{
if(mem[g][rest]!=-1)return mem[g][rest];
ll res=0;
res=(res+dfs(g+1,rest))%M;
ll ncomb=1,nrest=rest;
repl(i,c,d+1){
if(g*i>rest)break;
ncomb=ncomb*mod_comb(nrest,g,M)%M;
nrest-=g;
res=(res+((dfs(g+1,rest-g*i)*ncomb)%M)*mod_inverse(fact[i],M))%M;
}
return mem[g][rest]=res%M;
}
}
int main(){
cin.sync_with_stdio(false);
fact[0]=fact[1]=1;
repl(i,1,11111)fact[i+1]=(fact[i]*(i+1))%M;
ll n;
memset(mem,-1,sizeof(mem));
cin>>n>>a>>b>>c>>d;
cout<<dfs(a,n)<<endl;
return 0;
}
| a.cc: In function 'll dfs(ll, ll)':
a.cc:66:20: error: 'mem' was not declared in this scope
66 | if(mem[g][rest]!=-1)return mem[g][rest];
| ^~~
a.cc:76:24: error: 'mem' was not declared in this scope
76 | return mem[g][rest]=res%M;
| ^~~
a.cc: In function 'int main()':
a.cc:85:16: error: 'mem' was not declared in this scope
85 | memset(mem,-1,sizeof(mem));
| ^~~
|
s352235051 | p03832 | C++ | #include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<map>
#include<cstring>
#include<string>
#include <math.h>
#include<algorithm>
// #include <boost/multiprecision/cpp_int.hpp>
#include<functional>
#define int long long
#define mod 1000000007
#define pa pair<int,int>
#define ll long long
#define pal pair<double,int>
#define ppa pair<int,pa>
#define ssa pair<string,int>
#define mp make_pair
#define pb push_back
#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b))<EPS)
using namespace std;
//priority_queue<int, vector<int>, greater<int> > que;
class Point{
public:
double x,y;
Point(double x=0,double y=0):x(x),y(y) {}
Point operator + (Point p) {return Point(x+p.x,y+p.y);}
Point operator - (Point p) {return Point(x-p.x,y-p.y);}
Point operator * (double a) {return Point(x*a,y*a);}
Point operator / (double a) {return Point(x/a,y/a);}
double absv() {return sqrt(norm());}
double norm() {return x*x+y*y;}
bool operator < (const Point &p) const{
return x != p.x ? x<p.x: y<p.y;
}
bool operator == (const Point &p) const{
return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
}
};
typedef Point Vector;
struct Segment{
Point p1,p2;
};
double hen(Vector a){
if(fabs(a.x)<EPS && a.y>0) return acos(0);
else if(fabs(a.x)<EPS && a.y<0) return 3*acos(0);
else if(fabs(a.y)<EPS && a.x<0) return 2*acos(0);
else if(fabs(a.y)<EPS && a.x>0) return 0.0;
else if(a.y>0) return acos(a.x/a.absv());
else return 2*acos(0)+acos(-a.x/a.absv());
}
string itos( int i ) {
ostringstream s ;
s << i ;
return s.str() ;
}
int gcd(int v,int b){
if(v>b) return gcd(b,v);
if(v==b) return b;
if(b%v==0) return v;
return gcd(v,b%v);
}
double dot(Vector a,Vector b){
return a.x*b.x+a.y*b.y;
}
double cross(Vector a,Vector b){
return a.x*b.y-a.y*b.x;
}
double distans(double x1,double y1,double x2,double y2){
double rr=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
return sqrt(rr);
}
int beki(int a, int r){
if(r==0)return 1;
if(r==1) return a%mod;
if(r%2==1){
int y=beki(a,r-1);
return(y*a)%mod;
}
int yy=beki(a,r/2);
return (yy*yy)%mod;
}
int inf=mod*2;
int kai[100000];
int inv[100000];
int memo[1004][1004]={0};
//----------------kokomade tenpure------------
int n,a,b,c,d,ans=0;
int ic(int u,int v){
return v*(v+1)/2-u*(u+1)/2;
}
int comb(int k,int r){
if(k==0)return 1;
int z=kai[k]*inv[r];
z%=mod;
z *= inv[k-r];
return z%mod;
}
int cou=0;
void saiki(int nokori,int nin,int u){
cou++;
// cout<<nokori<<" "<<nin<<" "<<u<<endl;
if(nin==a-1 && nokori!=0)return;
if(u==0) return;
if(nin==a-1){
ans +=u;
// cout<<u<<endl;
return;
}
if(nokori > d* ic(a-1,nin))return;
saiki(nokori,nin-1,u);
for(int i=c;i<=d;i++){
if(nin*i<=nokori){
int uu=u;
uu *= comb(nokori,nin*i);
uu%=mod;
// if(nokori==1000 && nin==1&& i==1)cout<<u<<" uu="<<comb(nokori,nin*i)<<endl;
for(int j=0;j<i;j++){
uu *= comb(nin*(i-j),nin);
uu %=mod;
}
uu*=inv[i];
uu%=mod;
saiki(nokori-nin*i,nin-1,uu);
}
}
return;
}
signed main(){
kai[0]=1;
for(int i=1;i<100000;i++)kai[i]=(i*kai[i-1])%mod;
for(int i=0;i<100000;i++){
inv[i]=beki(kai[i],mod-2)%mod;
}
cin>>n>>a>>b>>c>>d;
for(int i=a-1;i<=b;i++)for(int j=0;j<=1000;j++){
int u=1;
if(i==a-1 && j==0)memo[a-1][0]=1;
else if(i>a-1){
memo[i][j] += memo[i-1][j];
for(int k=c;k<=d;k++){
if(j< i*k) break;
int u=comb(j,k*i);
u%=mod;
for(int jj=0;jj<k;jj++){
u *= comb(i*(k-jj),i);
u %=mod;
}
uu*=inv[k];
uu%=mod;
memo[i][j] += (memo[i-1][j-i*k]*u)%mod;
}
}
}
cout<<memo[b][n]<<endl;
return 0;
}
//printf("%d %.10f %.10f\n",i,xx/ri,yy/ri); | a.cc: In function 'int main()':
a.cc:181:33: error: 'uu' was not declared in this scope; did you mean 'u'?
181 | uu*=inv[k];
| ^~
| u
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.