submission_id
stringlengths 10
10
| problem_id
stringlengths 6
6
| language
stringclasses 3
values | code
stringlengths 1
522k
| compiler_output
stringlengths 43
10.2k
|
|---|---|---|---|---|
s885728492
|
p04014
|
C
|
long n,s;
bool f(long b)
{
long sum=0;
long _n=n;
while(_n)
{
sum+=_n%b;
_n/=b;
}
return sum==s;
}
main()
{
scanf("%ld%ld",&n,&s);
if(n==s)
{
printf("%ld\n",n+1);
return 0;
}
for(long i=2;i*i<=n;i++)
if(f(i))
{
printf("%ld\n",i);
return 0;
}
long minb=n+1;
for(long i=1;i*i<=n;i++)
{
long b=(n-s)/i+1;
if(b>1&&f(b))
{
minb=min(minb,b);
}
}
printf("%ld\n",minb==n+1?-1:minb);
}
|
main.c:2:1: error: unknown type name 'bool'
2 | bool f(long b)
| ^~~~
main.c:1:1: note: 'bool' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
+++ |+#include <stdbool.h>
1 | long n,s;
main.c:13:1: error: return type defaults to 'int' [-Wimplicit-int]
13 | main()
| ^~~~
main.c: In function 'main':
main.c:15:9: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
15 | scanf("%ld%ld",&n,&s);
| ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
+++ |+#include <stdio.h>
1 | long n,s;
main.c:15:9: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
15 | scanf("%ld%ld",&n,&s);
| ^~~~~
main.c:15:9: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:18:17: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
18 | printf("%ld\n",n+1);
| ^~~~~~
main.c:18:17: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:18:17: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:18:17: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:24:25: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
24 | printf("%ld\n",i);
| ^~~~~~
main.c:24:25: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:33:30: error: implicit declaration of function 'min'; did you mean 'main'? [-Wimplicit-function-declaration]
33 | minb=min(minb,b);
| ^~~
| main
main.c:36:9: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
36 | printf("%ld\n",minb==n+1?-1:minb);
| ^~~~~~
main.c:36:9: note: include '<stdio.h>' or provide a declaration of 'printf'
|
s278783088
|
p04014
|
C++
|
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()
ll const M = 1e11;
int main(){
ll n, s, b = 1e9;
scanf("%lld%lld", &n, &s);
for(ll i = 10; i<=M; i *= 10){
ll sm = 0, x = n;
while(x){
sm += (x % i);
x /= i;
}
if(sm == s){b = i; break;}
}
for(ll i = 2; i<=sqrt(n); ++i){
ll sm = 0, x = n;
while(x){
sm += (x % i);
x /= i;
}
if(sm == s){b = min(b,i); break;}
}
if(s == 1)b = n;
if(b == 1e9)b = -1;
if(n == s)an = n+1;
printf("%lld\n", b);
}
|
a.cc: In function 'int main()':
a.cc:29:15: error: 'an' was not declared in this scope; did you mean 'n'?
29 | if(n == s)an = n+1;
| ^~
| n
|
s542947613
|
p04014
|
C++
|
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll f(ll b, ll n) {
if(n < b)return n;
return f(b,n/b) + n % b;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
ll n,s; cin >> n >> s;
ll sq = sqrt(n);
for(ll i = 2; i <= sq; i++) {
if(f(i,n) == s) {
cout << i << '\n';
return 0;
}
}
for(ll i = sq; i > 0; i--) {
if(abs(n-s) % i != 0)continue;
ll x = (n-s)/i + 1;
if(x < 2)continue;
if(x < sq)continue;
if(x*i + (n%x) != n)continue;
if(f(x,n) != s)continue;
cout << x << '\n';s
return 0;
}
cout << -1 << '\n';
return 0;
}
|
a.cc: In function 'int main()':
a.cc:41:36: error: expected ';' before 'return'
41 | cout << x << '\n';s
| ^
| ;
42 | return 0;
| ~~~~~~
|
s660807424
|
p04014
|
C++
|
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
#include <map>
#include <string>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define ll long long
#define rn(i,n) for(int i=1;i<=n;i++)
#define N 1000;
#define INF 1000000007
ll f(ll b, ll n){
if(n<b)return n;
else return f(b,floor(n/b))+n%b;
}
int main() {
ll s,n;
cin>>n>>s;
if(s==n){cout<<n+1<<endl;return 0;}
for(int i=2;i<=floor(sqrt(n));i++){
if(f(i,n)==s){
cout<<b<<endl;
return 0;
}
}
return 0;
}
|
a.cc: In function 'int main()':
a.cc:26:13: error: 'b' was not declared in this scope
26 | cout<<b<<endl;
| ^
|
s816100514
|
p04014
|
C++
|
#include <cstdio>
#include <cmath>
#include <iostream>
typedef long long ll;
ll n, s;
ll f(ll b, ll n) { return n < b ? n : f(b, n / b) + n % b; }
int main() {
scanf("%lld%lld", &n, &s);
if (s > n) return puts("-1"), 0;
if (s == n) return printf("%lld\n", n + 1);
ll bl = sqrt(n) + 1;
for (ll i = 2; i <= bl; ++i) if (f(i, n) == s) return printf("%lld\n", i), 0;
ll ans = LONG_LONG_MAX;
n -= s, bl = sqrt(n);
for (ll i = 1; i <= bl; ++i) if (n % i == 0) {
ll b = n / i + 1;
if (f(b, n + s) == s) ans = std :: min(ans, b);
}
printf("%lld\n", ans == LONG_LONG_MAX ? -1 : ans);
return 0;
}
|
a.cc: In function 'int main()':
a.cc:17:14: error: 'LONG_LONG_MAX' was not declared in this scope
17 | ll ans = LONG_LONG_MAX;
| ^~~~~~~~~~~~~
|
s319276947
|
p04014
|
C++
|
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>
using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
return os;
}
#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else
#define DMP(...) ((void)0)
#endif
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
const lint n, s;
cin >> n >> s;
auto check = [&](const lint b) {
if (b < 2) return false;
lint tmp = n, sum = 0;
while (tmp) {
sum += tmp % b;
tmp /= b;
}
return sum == s;
};
auto end = [&](const lint b) {
cout << b << "\n";
exit(0);
};
if (n < s) end(-1);
else if (n == s) end(n + 1);
for (int i = 2; i < 320000; i++) if (check(i)) end(i);
for (int i = 320000; i >= 1; i--) {
lint b = (n - s) / i + 1;
if (check(b)) end(b);
}
end(-1);
}
|
a.cc: In function 'int main()':
a.cc:43:20: error: uninitialized 'const n' [-fpermissive]
43 | const lint n, s;
| ^
a.cc:43:23: error: uninitialized 'const s' [-fpermissive]
43 | const lint n, s;
| ^
a.cc:44:13: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'const lint' {aka 'const long long int'})
44 | cin >> n >> s;
| ~~~ ^~ ~
| | |
| | const lint {aka const long long int}
| std::istream {aka std::basic_istream<char>}
In file included from /usr/include/c++/14/iostream:42,
from a.cc:4:
/usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
170 | operator>>(bool& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:170:7: note: conversion of argument 1 would be ill-formed:
a.cc:44:16: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'lint' {aka 'long long int'}
44 | cin >> n >> s;
| ^
/usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
174 | operator>>(short& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:174:7: note: conversion of argument 1 would be ill-formed:
a.cc:44:16: error: cannot bind non-const lvalue reference of type 'short int&' to a value of type 'lint' {aka 'long long int'}
44 | cin >> n >> s;
| ^
/usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
177 | operator>>(unsigned short& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:177:7: note: conversion of argument 1 would be ill-formed:
a.cc:44:16: error: cannot bind non-const lvalue reference of type 'short unsigned int&' to a value of type 'lint' {aka 'long long int'}
44 | cin >> n >> s;
| ^
/usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
181 | operator>>(int& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:181:7: note: conversion of argument 1 would be ill-formed:
a.cc:44:16: error: cannot bind non-const lvalue reference of type 'int&' to a value of type 'lint' {aka 'long long int'}
44 | cin >> n >> s;
| ^
/usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
184 | operator>>(unsigned int& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:184:7: note: conversion of argument 1 would be ill-formed:
a.cc:44:16: error: cannot bind non-const lvalue reference of type 'unsigned int&' to a value of type 'lint' {aka 'long long int'}
44 | cin >> n >> s;
| ^
/usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
188 | operator>>(long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:188:7: note: conversion of argument 1 would be ill-formed:
a.cc:44:16: error: cannot bind non-const lvalue reference of type 'long int&' to a value of type 'lint' {aka 'long long int'}
44 | cin >> n >> s;
| ^
/usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
192 | operator>>(unsigned long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:192:7: note: conversion of argument 1 would be ill-formed:
a.cc:44:16: error: cannot bind non-const lvalue reference of type 'long unsigned int&' to a value of type 'lint' {aka 'long long int'}
44 | cin >> n >> s;
| ^
/usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
203 | operator>>(unsigned long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:203:7: note: conversion of argument 1 would be ill-formed:
a.cc:44:16: error: cannot bind non-const lvalue reference of type 'long long unsigned int&' to a value of type 'lint' {aka 'long long int'}
44 | cin >> n >> s;
| ^
/usr/include/c++/14/istream:219:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(float&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
219 | operator>>(float& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:219:7: note: conversion of argument 1 would be ill-formed:
a.cc:44:16: error: cannot bind non-const lvalue reference of type 'float&' to a value of type 'lint' {aka 'long long int'}
44 | cin >> n >> s;
| ^
/usr/include/c++/14/istream:223:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
223 | operator>>(double& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:223:7: note: conversion of argument 1 would be ill-formed:
a.cc:44:16: error: cannot bind non-const lvalue reference of type 'double&' to a value of type 'lint' {aka 'long long int'}
44 | cin >> n >> s;
| ^
/usr/include/c++/14/istream:227:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
227 | operator>>(long double& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:227:7: note: conversion of argument 1 would be ill-formed:
a.cc:44:16: error: cannot bind non-const lvalue reference of type 'long double&' to a value of type 'lint' {aka 'long long int'}
44 | cin >> n >> s;
| ^
/usr/include/c++/14/istream:328:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
328 | operator>>(void*& __p)
| ^~~~~~~~
/usr/include/c++/14/istream:328:7: note: conversion of argument 1 would be ill-formed:
a.cc:44:16: error: invalid conversion from 'lint' {aka 'long long int'} to 'void*' [-fpermissive]
44 | cin >> n >> s;
| ^
| |
| lint {aka long long int}
a.cc:44:16: error: cannot bind rvalue '(void*)((lint)n)' to 'void*&'
/usr/include/c++/14/istream:122:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__istream_type& (*)(__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
122 | operator>>(__istream_type& (*__pf)(__istream_type&))
| ^~~~~~~~
/usr/include/c++/14/istream:122:7: note: conversion of argument 1 would be ill-formed:
a.cc:44:16: error: invalid conversion from 'lint' {aka 'long long int'} to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'} [-fpermissive]
44 | cin >> n >> s;
| ^
| |
| lint {aka long long int}
/usr/include/c++/14/istream:126:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>; __ios_type = std::basic_ios<char>]' (near match)
126 | operator>>(__ios_type& (*__pf)(__ios_type&))
| ^~~~~~~~
/usr/include/c++/14/istream:126:7: note: conversion of argument 1 would be ill-formed:
a.cc:44:16: error: invalid conversion from 'lint' {aka 'long long int'} to 'std::basic_istream<char>::__ios_type& (*)(std::basic_istream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'} [-fpermissive]
44 | cin >> n >> s;
| ^
| |
| lint {aka long long int}
/usr/include/c++/14/istream:133:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
133 | operator>>(ios_base& (*__pf)(ios_base&))
| ^~~~~~~~
/usr/include/c++/14/istream:133:7: not
|
s083436207
|
p04014
|
C++
|
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>
using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
return os;
}
#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else
#define DMP(...) ((void)0)
#endif
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
lint n, s;
cin >> n >> s;
auto check = [&](lint &b) {
if (b < 2) return false;
lint tmp = n, sum = 0;
while (tmp) {
sum += tmp % b;
tmp /= b;
}
return sum == s;
};
auto end = [&](lint b) {
cout << b << "\n";
exit(0);
};
if (n < s) end(-1);
else if (n == s) end(n + 1);
for (int i = 2; i < 320000; i++) if (check(i)) end(i);
for (int i = 320000; i >= 1; i--) {
lint b = (n - s) / i + 1;
if (check(b)) end(b);
}
end(-1);
}
|
a.cc: In function 'int main()':
a.cc:64:51: error: no match for call to '(main()::<lambda(lint&)>) (int&)'
64 | for (int i = 2; i < 320000; i++) if (check(i)) end(i);
| ~~~~~^~~
a.cc:46:22: note: candidate: 'main()::<lambda(lint&)>' (near match)
46 | auto check = [&](lint &b) {
| ^
a.cc:46:22: note: conversion of argument 1 would be ill-formed:
a.cc:64:52: error: cannot bind non-const lvalue reference of type 'lint&' {aka 'long long int&'} to a value of type 'int'
64 | for (int i = 2; i < 320000; i++) if (check(i)) end(i);
| ^
|
s757061147
|
p04014
|
C++
|
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>
using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
return os;
}
#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else
#define DMP(...) ((void)0)
#endif
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
lint n, s;
cin >> n >> s;
auto check = [&](lint &&b) {
if (b < 2) return false;
lint tmp = n, sum = 0;
while (tmp) {
sum += tmp % b;
tmp /= b;
}
return sum == s;
};
auto end = [&](lint &&b) {
cout << b << "\n";
exit(0);
};
if (n < s) end(-1);
else if (n == s) end(n + 1);
for (int i = 2; i < 320000; i++) if (check(i)) end(i);
for (int i = 320000; i >= 1; i--) {
lint b = (n - s) / i + 1;
if (check(b)) end(b);
}
end(-1);
}
|
a.cc: In function 'int main()':
a.cc:67:26: error: no match for call to '(main()::<lambda(lint&&)>) (lint&)'
67 | if (check(b)) end(b);
| ~~~~~^~~
a.cc:46:22: note: candidate: 'main()::<lambda(lint&&)>' (near match)
46 | auto check = [&](lint &&b) {
| ^
a.cc:46:22: note: conversion of argument 1 would be ill-formed:
a.cc:67:27: error: cannot bind rvalue reference of type 'lint&&' {aka 'long long int&&'} to lvalue of type 'lint' {aka 'long long int'}
67 | if (check(b)) end(b);
| ^
a.cc:67:34: error: no match for call to '(main()::<lambda(lint&&)>) (lint&)'
67 | if (check(b)) end(b);
| ~~~^~~
a.cc:56:20: note: candidate: 'main()::<lambda(lint&&)>' (near match)
56 | auto end = [&](lint &&b) {
| ^
a.cc:56:20: note: conversion of argument 1 would be ill-formed:
a.cc:67:35: error: cannot bind rvalue reference of type 'lint&&' {aka 'long long int&&'} to lvalue of type 'lint' {aka 'long long int'}
67 | if (check(b)) end(b);
| ^
|
s811854171
|
p04014
|
C++
|
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>
using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
return os;
}
#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else
#define DMP(...) ((void)0)
#endif
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
lint n, s;
cin >> n >> s;
auto check = [&](lint &b) {
if (b < 2) return false;
lint tmp = n, sum = 0;
while (tmp) {
sum += tmp % b;
tmp /= b;
}
return sum == s;
};
auto end = [&](lint &b) {
cout << b << "\n";
exit(0);
};
if (n < s) end(-1);
else if (n == s) end(n + 1);
for (int i = 2; i < 320000; i++) if (check(i)) end(i);
for (int i = 320000; i >= 1; i--) {
lint b = (n - s) / i + 1;
if (check(b)) end(b);
}
end(-1);
}
|
a.cc: In function 'int main()':
a.cc:61:23: error: no match for call to '(main()::<lambda(lint&)>) (int)'
61 | if (n < s) end(-1);
| ~~~^~~~
a.cc:56:20: note: candidate: 'main()::<lambda(lint&)>' (near match)
56 | auto end = [&](lint &b) {
| ^
a.cc:56:20: note: conversion of argument 1 would be ill-formed:
a.cc:61:24: error: cannot bind non-const lvalue reference of type 'lint&' {aka 'long long int&'} to a value of type 'int'
61 | if (n < s) end(-1);
| ^~
a.cc:62:29: error: no match for call to '(main()::<lambda(lint&)>) (lint)'
62 | else if (n == s) end(n + 1);
| ~~~^~~~~~~
a.cc:56:20: note: candidate: 'main()::<lambda(lint&)>' (near match)
56 | auto end = [&](lint &b) {
| ^
a.cc:56:20: note: conversion of argument 1 would be ill-formed:
a.cc:62:32: error: cannot bind non-const lvalue reference of type 'lint&' {aka 'long long int&'} to an rvalue of type 'lint' {aka 'long long int'}
62 | else if (n == s) end(n + 1);
| ~~^~~
a.cc:64:51: error: no match for call to '(main()::<lambda(lint&)>) (int&)'
64 | for (int i = 2; i < 320000; i++) if (check(i)) end(i);
| ~~~~~^~~
a.cc:46:22: note: candidate: 'main()::<lambda(lint&)>' (near match)
46 | auto check = [&](lint &b) {
| ^
a.cc:46:22: note: conversion of argument 1 would be ill-formed:
a.cc:64:52: error: cannot bind non-const lvalue reference of type 'lint&' {aka 'long long int&'} to a value of type 'int'
64 | for (int i = 2; i < 320000; i++) if (check(i)) end(i);
| ^
a.cc:64:59: error: no match for call to '(main()::<lambda(lint&)>) (int&)'
64 | for (int i = 2; i < 320000; i++) if (check(i)) end(i);
| ~~~^~~
a.cc:56:20: note: candidate: 'main()::<lambda(lint&)>' (near match)
56 | auto end = [&](lint &b) {
| ^
a.cc:56:20: note: conversion of argument 1 would be ill-formed:
a.cc:64:60: error: cannot bind non-const lvalue reference of type 'lint&' {aka 'long long int&'} to a value of type 'int'
64 | for (int i = 2; i < 320000; i++) if (check(i)) end(i);
| ^
a.cc:70:12: error: no match for call to '(main()::<lambda(lint&)>) (int)'
70 | end(-1);
| ~~~^~~~
a.cc:56:20: note: candidate: 'main()::<lambda(lint&)>' (near match)
56 | auto end = [&](lint &b) {
| ^
a.cc:56:20: note: conversion of argument 1 would be ill-formed:
a.cc:70:13: error: cannot bind non-const lvalue reference of type 'lint&' {aka 'long long int&'} to a value of type 'int'
70 | end(-1);
| ^~
|
s351904153
|
p04014
|
C++
|
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define all(v) (v).begin(),v.end()
set<string> c;
const ll mod=1000000007;
const ll mod2=998244353;
const ll inf=100000000000000000;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
vector<int> dy={-1,0,1,0},dx={0,-1,0,1};
int main(){
ll n,s;
cin>>n>>s;
if(s==n){cout<<n+1<<endl;return 0;}
ll border=sqrt(n);
for(int i=2;i<=sqrt(n)+100000;i++){
ll res=0,rec=n;
while(rec!=0){
res+=rec%i;
rec/=i;
}
if(res==s){cout<<i<<endl;return 0;}
}
vector<ll> tmp;
for(ll i=2;i<=sqrt(n-s)+10000;i++){
if((n-s)%(i-1)!=0)continue;
tmp.push_back(i);
tmp.push_back((n-s)/i+1));
}
sort(all(tmp));
for(int i=0;i<tmp.size();i++){
ll res=0,tm=tmp[i],rec=n;
// cout<<tm<<endl;
while(rec!=0){
res+=rec%tm;
rec/=tm;
}
if(res==s){cout<<tm<<endl;return 0;}
}
cout<<-1<<endl;
}
|
a.cc: In function 'int main()':
a.cc:32:29: error: expected ';' before ')' token
32 | tmp.push_back((n-s)/i+1));
| ^
| ;
|
s755037022
|
p04014
|
C++
|
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x) \
for(auto &youso_ : (x)) cin >> youso_
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
#define rAll(a) (a).rbegin(), (a).rend()
template <typename T = long long> inline T IN() {
T x;
cin >> x;
return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
cin >> head;
CIN(move(tail)...);
}
#define CCIN(...) \
char __VA_ARGS__; \
CIN(__VA_ARGS__)
#define DCIN(...) \
double __VA_ARGS__; \
CIN(__VA_ARGS__)
#define LCIN(...) \
ll __VA_ARGS__; \
CIN(__VA_ARGS__)
#define SCIN(...) \
string __VA_ARGS__; \
CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v) \
{ \
FOREACH(x, v) { cout << x << " "; } \
cout << "\n"; \
}
template <typename T = string> inline void eputs(T s) {
cout << s << "\n";
exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
std::fill((T *)array, (T *)(array + N), val);
}
template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;
typedef long long ll;
typedef pair<ll, ll> PL;
typedef vector<PL> VPL;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<double> VD;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
const double PI = atan(1.0) * 4.0;
const ll dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
#define PI 3.141592653589793238
void cinfast() {
cin.tie(0);
ios::sync_with_stdio(false);
}
ll N;
VPL nn,pp,pn,np;
ll N,S;
ll f(ll b,ll n) {
if(n<b) return n;
return f(b,n/b)+(n%b);
}
signed main() {
cin>>N>>S;
if(S>N) eputs(-1);
if(N==S) eputs(N+1);
set<ll> SS;
for(ll b=2;b*b<=N;b++) if(f(b,N)==S) SS.insert(b);
for(ll p=1;p*p<N && p<=S;p++) {
ll m=S-p;
if(N-m>=0 && (N-m)%p==0) {
ll b=(N-m)/p;
if(b>p && b>m) SS.insert((N-m)/p);
}
}
if(SS.size())eputs(*SS.begin());
eputs(-1);
}
|
a.cc:83:4: error: redefinition of 'll N'
83 | ll N,S;
| ^
a.cc:80:4: note: 'll N' previously declared here
80 | ll N;
| ^
|
s241716896
|
p04014
|
C++
|
import sequtils,algorithm
proc scanf(formatstr: cstring){.header: "<stdio.h>", varargs.}
proc getchar(): char {.header: "<stdio.h>", varargs.}
proc nextInt(): int = scanf("%lld",addr result)
proc nextFloat(): float = scanf("%lf",addr result)
proc nextString(): string =
var get = false
result = ""
while true:
var c = getchar()
if int(c) > int(' '):
get = true
result.add(c)
else:
if get: break
get = false
proc divs(n:int):seq[int] =
var d = 1
result = newSeq[int]()
while true:
if d * d > n: break
if n mod d == 0:
result.add d
if d * d < n: result.add n div d
d += 1
result.sort()
proc solve(n:int, s:int):void =
proc calc(b:int):int =
var
m = n
d = 0
result = 0
while m > 0:
result += m mod b
m = m div b
d += 1
var b = 2
while true:
if b * b > n:
break
let t = calc(b)
if t == s:
echo b
return
b += 1
let T = n - s
if T < 0:
echo -1
return
elif T == 0: # n == s
echo n + 1
return
let ds = divs(T)
for d in ds:
let
b = d + 1
q = T div d
if b < 100000000 and b * b <= n: continue # already listed
if not (0 <= q and q < b): continue
let r = s - q
if not (0 <= r and r < b): continue
echo b
return
echo -1
return
proc main():void =
var n = 0
n = nextInt()
var s = 0
s = nextInt()
solve(n, s);
return
main()
|
a.cc:52:16: error: stray '#' in program
52 | elif T == 0: # n == s
| ^
a.cc:60:47: error: stray '#' in program
60 | if b < 100000000 and b * b <= n: continue # already listed
| ^
a.cc:1:1: error: 'import' does not name a type
1 | import sequtils,algorithm
| ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'proc' does not name a type
3 | proc getchar(): char {.header: "<stdio.h>", varargs.}
| ^~~~
a.cc:4:1: error: 'proc' does not name a type
4 | proc nextInt(): int = scanf("%lld",addr result)
| ^~~~
a.cc:75:3: error: expected unqualified-id before 'return'
75 | return
| ^~~~~~
|
s731098144
|
p04014
|
C++
|
#include <bits/stdc++.h>
using namespace std;
long long f(long long b,long long n)
{
if(n<b)
return n;
else
return f(b,floor(n/b))+(n%b);
}
long long n,s;
long long answ=9999999999999999999;
int main()
{
scanf("%lld %lld",&n,&s);
long long maxb=sqrt(n);
for(long long b=2; b<=maxb; b++)
if(f(b,n)==s)
{
printf("%lld",b);
return 0;
}
long long fj=n-s;
long long maxfj=sqrt(n-s);
for(long long k=1; k<maxfj; k++)
{
if(fj%k==0)
{
long long b=k+1;
long long a1=(s-n)/k;
long long a0=s-a1;
if(n==a0+a1*b)
{
printf("%lld",b);
return 0;
}
b=a1,a1=k+1;
a0=s-a1;
if(n==a0+a1*b)
answ=min(answ,b);
}
}
long long k=n-s;
long long b=k+1,a1=1;
long long a0=s-a1;
if(n==a0+a1*b)
{
printf("%lld",b);
return 0;
}
if(answ!=0)
printf("%lld",answ)
else
printf("-1");
return 0;
}
|
a.cc:11:16: warning: integer constant is so large that it is unsigned
11 | long long answ=9999999999999999999;
| ^~~~~~~~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:51:36: error: expected ';' before 'else'
51 | printf("%lld",answ)
| ^
| ;
52 | else
| ~~~~
|
s760209717
|
p04014
|
C++
|
#include <iostream>
using namespace std;
long long f(long long b, long long n) {
if (b < 2) return -1;
long long ans = 0;
while (n > 0) {
ans += n % b;
n /= b;
}
return ans;
}
int main() {
long long n, s;
cin >> n >> s;
if (s > n) return cout << "-1\n", 0;
if (n == s) return cout << n + 1 << '\n', 0;
for (long long i = 2; i * i <= n; ++i) {
if (f(i, n) == s) cout << i << '\n', exit(0);
}
long long rs = n;
for (long long i = 1; i * i <= n; ++i) {
long long x = n / i;
if (f(x, n) == s) rs = min(rs, x);
long long x = s / i;
if (f(x, n) == s) rs = min(rs, x);
long long x = (n - s) / i;
if (f(x, n) == s) rs = min(rs, x);
long long x = (n - s) / i + 1;
if (f(x, n) == s) rs = min(rs, x);
}
cout << rs << '\n';
return 0;
}
|
a.cc: In function 'int main()':
a.cc:28:15: error: redeclaration of 'long long int x'
28 | long long x = s / i;
| ^
a.cc:26:15: note: 'long long int x' previously declared here
26 | long long x = n / i;
| ^
a.cc:30:15: error: redeclaration of 'long long int x'
30 | long long x = (n - s) / i;
| ^
a.cc:26:15: note: 'long long int x' previously declared here
26 | long long x = n / i;
| ^
a.cc:32:15: error: redeclaration of 'long long int x'
32 | long long x = (n - s) / i + 1;
| ^
a.cc:26:15: note: 'long long int x' previously declared here
26 | long long x = n / i;
| ^
|
s583168117
|
p04014
|
C++
|
#include<bits/stdc++.h>
using namespace std;
long long fb(long long b,long long n) {
if(n<b)return n;
return f(b,floor(n/b))+(n%b)
}
int main() {
long long n,s,a;
cin>>n>>s;
if(s>n) {
cout<<-1<<endl;
}
if(s==n) {
cout<<n+1<<endl;
}
for(int i=2; i<=sqrt(n)+1; i++) {
if(fb(i,n)==s) {
cout<<i<<endl;
return 0;
}
}
for( int i=1;i*i<= n;i++ ) {
if(n%i == 0 ) {
int b=n/i+1;
if(f(b,n+s)==s) ans=min(ans,b) ;
}
}
cout<<ans!=1e11?ans:-1<<Endl;
return 0;
}
|
a.cc: In function 'long long int fb(long long int, long long int)':
a.cc:5:16: error: 'f' was not declared in this scope
5 | return f(b,floor(n/b))+(n%b)
| ^
a.cc:5:37: error: expected ';' before '}' token
5 | return f(b,floor(n/b))+(n%b)
| ^
| ;
6 | }
| ~
a.cc: In function 'int main()':
a.cc:25:28: error: 'f' was not declared in this scope
25 | if(f(b,n+s)==s) ans=min(ans,b) ;
| ^
a.cc:25:41: error: 'ans' was not declared in this scope; did you mean 'abs'?
25 | if(f(b,n+s)==s) ans=min(ans,b) ;
| ^~~
| abs
a.cc:28:15: error: 'ans' was not declared in this scope; did you mean 'abs'?
28 | cout<<ans!=1e11?ans:-1<<Endl;
| ^~~
| abs
a.cc:28:33: error: 'Endl' was not declared in this scope
28 | cout<<ans!=1e11?ans:-1<<Endl;
| ^~~~
|
s070526612
|
p04014
|
C++
|
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#define y0 qvya13579
#define y1 qvyb24680
#define j0 qvja13579
#define j1 qvjb24680
#define next qvne13579xt
#define prev qvpr13579ev
#define INF 1000000007
#define MOD 1000000007
#define PI acos(-1.0)
#define endl "\n"
#define IOS cin.tie(0);ios::sync_with_stdio(false)
#define M_P make_pair
#define PU_B push_back
#define PU_F push_front
#define PO_B pop_back
#define PO_F pop_front
#define U_B upper_bound
#define L_B lower_bound
#define B_S binary_search
#define PR_Q priority_queue
#define FIR first
#define SEC second
#if __cplusplus < 201103L
#define stoi(argument_string) atoi((argument_string).c_str())
#endif
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP_R(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=((int)(m));i<(int)(n);++i)
#define FOR_R(i,m,n) for(int i=((int)(m)-1);i>=(int)(n);--i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define SIZ(x) ((int)(x).size())
#define COUT(x) cout<<(x)<<endl
#define CIN(x) cin>>(x)
#define CIN2(x,y) cin>>(x)>>(y)
#define CIN3(x,y,z) cin>>(x)>>(y)>>(z)
#define CIN4(x,y,z,w) cin>>(x)>>(y)>>(z)>>(w)
#define SCAND(x) scanf("%d",&(x))
#define SCAND2(x,y) scanf("%d%d",&(x),&(y))
#define SCAND3(x,y,z) scanf("%d%d%d",&(x),&(y),&(z))
#define SCAND4(x,y,z,w) scanf("%d%d%d%d",&(x),&(y),&(z),&(w))
#define SCANLLD(x) scanf("%lld",&(x))
#define SCANLLD2(x,y) scanf("%lld%lld",&(x),&(y))
#define SCANLLD3(x,y,z) scanf("%lld%lld%lld",&(x),&(y),&(z))
#define SCANLLD4(x,y,z,w) scanf("%lld%lld%lld%lld",&(x),&(y),&(z),&(w))
#define PRINTD(x) printf("%d\n",(x))
#define PRINTLLD(x) printf("%lld\n",(x))
typedef long long int lli;
using namespace std;
bool compare_by_2nd(pair<int,int> a, pair<int,int> b)
{
if( a.second != b.second )
{
return a.second < b.second;
}
else
{
return a.first < b.first;
}
}
int ctoi(char c)
{
if( c >= '0' and c <= '9' )
{
return (int)(c-'0');
}
return -1;
}
int alphabet_pos(char c)
{
if( c >= 'a' and c <= 'z' )
{
return (int)(c-'a');
}
return -1;
}
int alphabet_pos_capital(char c)
{
if( c >= 'A' and c <= 'Z' )
{
return (int)(c-'A');
}
return -1;
}
vector<string> split(string str, char ch)
{
int first = 0;
int last = str.find_first_of(ch);
if(last == string::npos)
{
last = SIZ(str);
}
vector<string> result;
while( first < SIZ(str) )
{
string Ssubstr(str, first, last - first);
result.push_back(Ssubstr);
first = last + 1;
last = str.find_first_of(ch, first);
if(last == string::npos)
{
last = SIZ(str);
}
}
return result;
}
int gcd( int a , int b ) // assuming a,b >= 1
{
if( a < b )
{
return gcd( b , a );
}
if( a % b == 0 )
{
return b;
}
return gcd( b , a % b );
}
int lcm( int a , int b ) // assuming a,b >= 1
{
return a * b / gcd( a , b );
}
lli pow_fast( lli x, lli n_power , lli modulus )
{
if( n_power == 0 )
{
return 1;
}
if( n_power % 2 == 0)
{
return pow_fast( x * x % modulus , n_power / 2 , modulus );
}
return x * pow_fast( x , n_power - 1 , modulus ) % modulus;
}
struct UnionFind //size-based
{
vector<int> parent, treesize;
UnionFind( int size ) : parent( size ) , treesize( size , 1 ) //constructor
{
for( int i = 0 ; i < size ; ++ i )
{
parent[i] = i;
}
}
int root( int x )
{
if( parent[x] == x )
{
return x;
}
return parent[x] = root(parent[x]);
}
void unite( int x, int y )
{
x = root(x);
y = root(y);
if( x == y )
{
return;
}
if( treesize[x] < treesize[y] )
{
parent[x] = y;
treesize[y] += treesize[x];
}
else
{
parent[y] = x;
treesize[x] += treesize[y];
}
}
bool sametree( int x, int y )
{
return root(x) == root(y);
}
int gettreesize( int x )
{
return treesize[root(x)];
}
};
/*------------------ the end of the template -----------------------*/
lli f( lli b , lli n )
{
if( n < b )
{
return n;
}
return f( b , n / b ) + ( n % b );
}
int main()
{
IOS; /* making cin faster */
lli n,s;
SCANLLD2(n,s);
if( n == s )
{
PRINTD(n+1);
return 0;
}
lli b;
for( b = 2 ; b <= (int)sqrt(n) ; ++ b )
{
if( f(b,n) == s )
{
PRINTLLD(b);
return 0;
}
}
lli q;
b = -1;
for( q = 1 ; q < (int) sqrt(n) ; ++ q )
{
lli r = s - q;
if( (n-r)/q >= 2 and r >= 0 )
{
if( f( (n-r)/q , n ) == s )
{
if( b == -1 )
{
b = (n-r)q;
}
else
{
b = min((n-r)q,b);
}
}
}
}
if( b != -1 )
{
PRINTLLD(b);
return 0;
}
PRINTD(-1);
}
|
a.cc: In function 'int main()':
a.cc:365:28: error: expected ';' before 'q'
365 | b = (n-r)q;
| ^
| ;
a.cc:369:32: error: expected ')' before 'q'
369 | b = min((n-r)q,b);
| ~ ^
| )
|
s475782911
|
p04014
|
C++
|
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
int f(long long n, long long b) {
long long sum = 0;
while (n > 0) {
sum += n % b;
n /= b;
}
return sum;
}
int main(int argc, char* argv[]) {
std::cin.tie(0);
std::ios::sync_with_stdio(false);
/* */
long long n, s;
std::cin >> n >> s;
if (n < s) { std::printf("-1\n"); std::exit(EXIT_SUCCESS); }
if (n == s) { std::printf("%lld\n", n + 1); std::exit(EXIT_SUCCESS); }
for (int b = 2; b <= (int)sqrt(n); ++b) {
if (f(n, b) == s) {
std::printf("%d\n", b);
std::exit(EXIT_SUCCESS);
}
}
long long min_b = 9999999999;
for (int p = (int)sqrt(n); p >= 1; --p) {
auto q = s - p;
if ( (n - q) % p != 0 ) continue;
auto b = (n - q) / p;
if ( f(n, b) != s ) continue;
b = std::min(min_b, b);
}
if (min_b == 9999999999) {
std::printf("-1\n");
} else {
std::printf("%lld\n", b);
}
/* */
return EXIT_SUCCESS;
}
|
a.cc: In function 'int main(int, char**)':
a.cc:47:27: error: 'b' was not declared in this scope
47 | std::printf("%lld\n", b);
| ^
|
s289030221
|
p04014
|
C++
|
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<unordered_map>
#include<math.h>
using namespace std;
typedef long long ll;
ll Decimal(ll b, ll n){
if(n == 0)return 0;
return Decimal(b, n / b) + n % b;
}
int main(){
ll n, s;
cin>>n>>s;
if(s == 1){
cout<<n<<endl;
return 0;
}
if(s == n){
cout<<n + 1<<endl;
return 0;
}
for(ll i = 2; i <= sqrt(n); i++){
if(Decimal(i, n) == s){
cout<<i<<endl;
return 0;
}
}
for(ll i = sqrt(n); i > 0; i--){
ll b = (n - s)/(ll)p+1;
if(b > p){
if(Decimal(b, n) == s){
cout<<b<<endl;
return 0;
}
}
}
cout<<-1<<endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:32:36: error: 'p' was not declared in this scope
32 | ll b = (n - s)/(ll)p+1;
| ^
|
s084563280
|
p04014
|
Java
|
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
long n = sc.nextLong();
long s = sc.nextLong();
long ans = Long.MAX_VALUE;
if(n==s){
System.out.println(n+1);
return;
}
long a=Math.sqrt(n);
for(long i = 2; i<=a; i++){
if(s==co(i,n)){
System.out.println(i);
return;
}
}
for(long i=a; i>=1; i--){
if(co(((n-s)/i)+1,n)==s && ((n-s)/i)+1>1){
System.out.println(((n-s)/i)+1);
return;
}
}
System.out.println(-1);
}
static long co(long i,long n){
long re=0;
while(n>0){
re+=n%i;
n/=i;
}
return re;
}
}
|
Main.java:12: error: incompatible types: possible lossy conversion from double to long
long a=Math.sqrt(n);
^
1 error
|
s496403888
|
p04014
|
C++
|
#include "bits/stdc++.h"
#define int long long
using namespace std;
int f(int b, int n) {
if (n < b) {
return n;
} else {
return n % b + f(b, n / b);
}
}
void main()
{
int n, s;
cin >> n >> s;
if (n == s) {
cout << n + 1 << endl;
} else {
int minb = 99999999999999;
for (int i = 2; i <= sqrt(n); i++) {
if (f(i, n) == s) {
minb = min(minb, i);
}
}
for (int i = 1; i < sqrt(n); i++) {
int b = (n - s) / i + 1;
if (f(b, n) == s) {
minb = min(minb, b);
}
}
if (minb != 99999999999999)
cout << minb << endl;
else
cout << -1 << endl;
}
}
|
a.cc:13:1: error: '::main' must return 'int'
13 | void main()
| ^~~~
|
s842486781
|
p04014
|
Java
|
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
long n = sc.nextLong();
long s = sc.nextLong();
if (s == n) {
System.out.println(n + 1);
return;
}
for (long i = 2; i * i <= n; i++) {
if (solve(n, s, i)) {
System.out.println(i);
return;
}
}
boolean ok = false;
long ans = 1000000000000L;
for (long p = 1; p * p < n; p++) {
long b = (n - s) / p + 1;
// System.out.println("b = " + b);
if (!(b * b > n && b < n)) {
continue;
}
if (solve(n, s, b)) {
ans = Math.min(min, b);
ok = true;
}
}
if (!ok) {
System.out.println(-1);
return;
}
System.out.println(min);
}
public static boolean solve(long n, long s, long num) {
long ans = 0;
while (n > 0) {
ans += n % num;
n /= num;
}
if (ans == s) {
return true;
}
return false;
}
}
|
Main.java:26: error: cannot find symbol
ans = Math.min(min, b);
^
symbol: variable min
location: class Main
Main.java:34: error: cannot find symbol
System.out.println(min);
^
symbol: variable min
location: class Main
2 errors
|
s374310206
|
p04014
|
Java
|
n = int(input())
s = int(input())
d = 0
k = 1
while k*k <= n-s:
if (n-s)%k > 0:
k += 1
continue
l = (n-s)//k
if (l+1)*(l+1) > n:
b = l+1
if n//b + n%b == s:
d = b
b = k+1
a = 0
r = n
while r > 0:
a += r%b
r = r//b
if a == s:
print(b)
exit()
k += 1
if n == s:
print(n+1)
elif d>0:
print(d)
else:
print(-1)
|
Main.java:1: error: class, interface, enum, or record expected
n = int(input())
^
1 error
|
s314572827
|
p04014
|
C++
|
#include <bits/stdc++.h>
using namespace std;
long long m, s, ans = 1e12;
long long f(long long b, long long n){
if(b == 1) return 0;
if(n < b) return n;
else return f(b, n / b) + n % b;
}
int main(){
cin.tie(0), ios::sync_with_stdio(0);
cin >> m >> s;
if(m == s){
cout << m + 1;
return 0;
}
for(int i = 2; i*i <= n; i++){
if(f(i, m) == s)
ans = min (ans,i);
}
for(int i = 2; i*i <= s; i++){
if(f(i, m) == s)
ans = min (ans,i);
}
if(m > s){
for(int i = 2; i*i <= m - s; i++){
int pointer = (m - s)/i + 1;
if(f(i, m) == s)
ans = min(ans,i);
if(f(pointer, m) == s)
ans = min(ans,pointer);
}
}
if(ans!=1e12) {cout << ans; exit(0);}
cout << "-1\n";
}
|
a.cc: In function 'int main()':
a.cc:20:27: error: 'n' was not declared in this scope
20 | for(int i = 2; i*i <= n; i++){
| ^
a.cc:22:23: error: no matching function for call to 'min(long long int&, int&)'
22 | ans = min (ans,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:22:23: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
22 | ans = min (ans,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:22:23: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
22 | ans = min (ans,i);
| ~~~~^~~~~~~
a.cc:26:23: error: no matching function for call to 'min(long long int&, int&)'
26 | ans = min (ans,i);
| ~~~~^~~~~~~
/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:26:23: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
26 | ans = min (ans,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
/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:26:23: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
26 | ans = min (ans,i);
| ~~~~^~~~~~~
a.cc:32:26: error: no matching function for call to 'min(long long int&, int&)'
32 | ans = min(ans,i);
| ~~~^~~~~~~
/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:32:26: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
32 | ans = min(ans,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
/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:32:26: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
32 | ans = min(ans,i);
| ~~~^~~~~~~
a.cc:34:26: error: no matching function for call to 'min(long long int&, int&)'
34 | ans = min(ans,pointer);
| ~~~^~~~~~~~~~~~~
/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:34:26: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
34 | ans = min(ans,pointer);
| ~~~^~~~~~~~~~~~~
/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
/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:34:26: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
34 | ans = min(ans,pointer);
| ~~~^~~~~~~~~~~~~
|
s463820390
|
p04014
|
C++
|
#include <bits/stdc++.h>
using namespace std;
long long m, s;
long long f(long long b, long long n){
if(n < b) return n;
else return f(b, n / b) + n % b;
}
int main(){
cin.tie(0), ios::sync_with_stdio(0);
cin >> m >> s;
for(int i = 2; i <= 1e6; i++){
if(f(i, m) == s){
cout << i << "\n";
return 0;
}
}
for(int i = 2; i <= sqrt(s); i++){
if(s%i == 0){
if(f(i, m) == s){
cout << i << "\n";
return 0;
}
}
}
if(n > s){
for(int i = 2; i <= sqrt(n - s); i++){
if(s%i == 0){
if(f(i, m) == s){
cout << i << "\n";
return 0;
}
}
}
}
if(m != 1 && f(m, m) == s){
cout << m << "\n";
return 0;
}
cout << "-1\n";
}
|
a.cc: In function 'int main()':
a.cc:29:8: error: 'n' was not declared in this scope; did you mean 'yn'?
29 | if(n > s){
| ^
| yn
|
s832056229
|
p04014
|
C++
|
#include <bits/stdc++.h>
using namespace std;
long long m, s;
long long f(long long b, long long n){
if(n < b) return n;
else return f(b, n / b) + n % b;
}
int main(){
cin.tie(0), ios::sync_with_stdio(0);
cin >> m >> s;
for(int i = 2; i <= 1e6; i++){
if(f(i, m) == s){
cout << i << "\n";
return 0;
}
}
for(int i = 2; i <= sqrt(s); i++){
if(s%i == 0){
if(f(i, m)) == s){
cout << i << "\n";
return 0;
}
if(f(s / i, m)) == s){
cout << s / i << "\n";
return 0;
}
}
}
cout << "-1";
}
|
a.cc: In function 'int main()':
a.cc:23:25: error: expected primary-expression before '==' token
23 | if(f(i, m)) == s){
| ^~
a.cc:27:29: error: expected primary-expression before '==' token
27 | if(f(s / i, m)) == s){
| ^~
|
s124333270
|
p04014
|
C++
|
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int INF = 1e9;
const int inf = 1e18;
const int MOD = 1e9 + 7;
int f(int b, int n){
if (n < b){
return n;
}
return f(b, n / b) + (n % b);
}
int main(){
int n, s, b;
cin >> n >> s;
if (n == s){
cout << n + 1;
return 0;
}
int ans = inf;
for (int i = 2; i * i <= n; i++){
if (f(i, n) == s){
cout << i;
return 0;
}
}
for (int i = 1; i * i <= n - s; i++){
b = (n - s) / i + 1;
if (f(b, n) == s){
ans = min(ans, b);
}
}
if (ans == inf){
cout << -1;
return 0;
}
cout << ans;
}
|
cc1plus: error: '::main' must return 'int'
|
s836535343
|
p04014
|
C++
|
#include <bits/stdc++.h>
using namespace std;
typedef long long int LLI;
LLI n;
LLI s;
LLI f(LLI b, LLI n) {
if (b == 1) return -1;
if (n < b) return n;
return n%b + f(b, n/b);
}
int main() {
scanf("%lld%lld", &n, &s);
LLI low = -1;
LLI high = 1000000;
while (high - low > 1) {
LLI mid = (high+low)/2;
if (mid*mid > n) high = mid;
else low = mid;
}
LLI ans = n+2;
if (n >= s) {
for (LLI c=1; c<=high; c++) {
if ((n-s) % c != 0) continue;
LLI b = (n-s)/c+1;
if (n/b != c) continue;
if (f(b, n) == s) {
ans = min(ans, b);
}
}
}
for (LLI b=1; b<=high; b++) {
if (f(b, n) == s) {
ans = min(ans, b);
}
}
if (n == s) {
ans = min(ans, n+1);
}
if (s == 1) {
ans = min(ans, max(2, n));
}
if (ans == n+2) puts("-1");
else printf("%lld\n", ans);
}
|
a.cc: In function 'int main()':
a.cc:49:23: error: no matching function for call to 'max(int, LLI&)'
49 | ans = min(ans, max(2, n));
| ~~~^~~~~~
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:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:49:23: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'LLI' {aka 'long long int'})
49 | ans = min(ans, max(2, n));
| ~~~^~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:49:23: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
49 | ans = min(ans, max(2, n));
| ~~~^~~~~~
|
s722408836
|
p04014
|
C++
|
#include<iostream>
#include<algorithm>
#define LL long long
LL n, s;
int main() {
std::cin >> n >> s;
int q = std::sqrt(n);
if (n == s) {
std::cout << s + 1 << std::endl;
return 0;
}
for (LL i = 2; i <= q; i++) {
LL copy = n;
LL sum = 0;
while (copy) {
sum += copy % i;
copy /= i;
}
if (s == sum) {
std::cout << i << std::endl;
return 0;
}
}
for (int i = q; i > 0; i--) {
LL b = (n - s) / i + 1;
LL sum = i + (n - i * b);
if (b < i || n - i * b >= b || n - i * b < 0)continue;
if (s == sum) {
std::cout << b << std::endl;
return 0;
}
}
std::cout << -1 << std::endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:7:22: error: 'sqrt' is not a member of 'std'; did you mean 'sort'?
7 | int q = std::sqrt(n);
| ^~~~
| sort
|
s503448431
|
p04014
|
C++
|
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
#define ll long long
const ll INF=10000000000000;
ll n,s;
ll f(ll b,ll n){
ll ret=0;
while(n){
ret+=n%b;
n/=b;
}
return ret;
}
int main(){
cin>>n>>s;
if(n==s){cout<<n+1<<endl; return 0;}
for(ll i=2;i<=sqrt(n);i++){
//cout<<f(i,n)<<endl;
if(f(i,n)==s){
cout<<i<<endl;
return 0;
}
}
ll ans=INF;
for(ll i=1;i<sqrt(n);i++){
if((n-s)%i==0)if(f((n-s)/i+1,n)==s)ans=min(ans,(n-s)/i+1);
}
if(ans==INF)ans=-1;
cout<<ans<<endl;
return 0;
}
|
a.cc:17:9: warning: "ll" redefined
17 | #define ll long long
| ^~
a.cc:16:9: note: this is the location of the previous definition
16 | #define ll __int64
| ^~
a.cc: In function 'int main()':
a.cc:33:23: error: 'sqrt' was not declared in this scope
33 | for(ll i=2;i<=sqrt(n);i++){
| ^~~~
a.cc:42:22: error: 'sqrt' was not declared in this scope
42 | for(ll i=1;i<sqrt(n);i++){
| ^~~~
|
s921277280
|
p04014
|
C++
|
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
//#define ll long long
const ll INF=10000000000000;
ll n,s;
ll f(ll b,ll n){
ll ret=0;
while(n){
ret+=n%b;
n/=b;
}
return ret;
}
int main(){
cin>>n>>s;
if(n==s){cout<<n+1<<endl; return 0;}
for(ll i=2;i<=sqrt(n);i++){
//cout<<f(i,n)<<endl;
if(f(i,n)==s){
cout<<i<<endl;
return 0;
}
}
ll ans=INF;
for(ll i=1;i<sqrt(n);i++){
if((n-s)%i==0)if(f((n-s)/i+1,n)==s)ans=min(ans,(n-s)/i+1);
}
if(ans==INF)ans=-1;
cout<<ans<<endl;
return 0;
}
|
a.cc:16:12: error: '__int64' does not name a type; did you mean '__int64_t'?
16 | #define ll __int64
| ^~~~~~~
a.cc:18:7: note: in expansion of macro 'll'
18 | const ll INF=10000000000000;
| ^~
a.cc:16:12: error: '__int64' does not name a type; did you mean '__int64_t'?
16 | #define ll __int64
| ^~~~~~~
a.cc:19:1: note: in expansion of macro 'll'
19 | ll n,s;
| ^~
a.cc:16:12: error: '__int64' does not name a type; did you mean '__int64_t'?
16 | #define ll __int64
| ^~~~~~~
a.cc:21:1: note: in expansion of macro 'll'
21 | ll f(ll b,ll n){
| ^~
a.cc: In function 'int main()':
a.cc:31:14: error: 'n' was not declared in this scope
31 | cin>>n>>s;
| ^
a.cc:31:17: error: 's' was not declared in this scope
31 | cin>>n>>s;
| ^
a.cc:16:12: error: '__int64' was not declared in this scope; did you mean '__int64_t'?
16 | #define ll __int64
| ^~~~~~~
a.cc:33:13: note: in expansion of macro 'll'
33 | for(ll i=2;i<=sqrt(n);i++){
| ^~
a.cc:33:20: error: 'i' was not declared in this scope
33 | for(ll i=2;i<=sqrt(n);i++){
| ^
a.cc:33:23: error: 'sqrt' was not declared in this scope
33 | for(ll i=2;i<=sqrt(n);i++){
| ^~~~
a.cc:35:20: error: 'f' was not declared in this scope
35 | if(f(i,n)==s){
| ^
a.cc:16:12: error: '__int64' was not declared in this scope; did you mean '__int64_t'?
16 | #define ll __int64
| ^~~~~~~
a.cc:41:9: note: in expansion of macro 'll'
41 | ll ans=INF;
| ^~
a.cc:42:16: error: expected ';' before 'i'
42 | for(ll i=1;i<sqrt(n);i++){
| ^
a.cc:42:20: error: 'i' was not declared in this scope
42 | for(ll i=1;i<sqrt(n);i++){
| ^
a.cc:42:22: error: 'sqrt' was not declared in this scope
42 | for(ll i=1;i<sqrt(n);i++){
| ^~~~
a.cc:43:34: error: 'f' was not declared in this scope
43 | if((n-s)%i==0)if(f((n-s)/i+1,n)==s)ans=min(ans,(n-s)/i+1);
| ^
a.cc:43:52: error: 'ans' was not declared in this scope; did you mean 'abs'?
43 | if((n-s)%i==0)if(f((n-s)/i+1,n)==s)ans=min(ans,(n-s)/i+1);
| ^~~
| abs
a.cc:46:12: error: 'ans' was not declared in this scope; did you mean 'abs'?
46 | if(ans==INF)ans=-1;
| ^~~
| abs
a.cc:46:17: error: 'INF' was not declared in this scope
46 | if(ans==INF)ans=-1;
| ^~~
a.cc:47:15: error: 'ans' was not declared in this scope; did you mean 'abs'?
47 | cout<<ans<<endl;
| ^~~
| abs
|
s808494125
|
p04014
|
C++
|
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
//#define ll long long
ll n,s;
ll f(ll b,ll n){
ll ret=0;
while(n){
ret+=n%b;
n/=b;
}
return ret;
}
int main(){
cin>>n>>s;
for(int i=2;i<=10000000;i++){
if(f(i,n)==s){
cout<<i<<endl;
return 0;
}
}
cout<<-1<<endl;
return 0;
}
|
a.cc:16:12: error: '__int64' does not name a type; did you mean '__int64_t'?
16 | #define ll __int64
| ^~~~~~~
a.cc:19:1: note: in expansion of macro 'll'
19 | ll n,s;
| ^~
a.cc:16:12: error: '__int64' does not name a type; did you mean '__int64_t'?
16 | #define ll __int64
| ^~~~~~~
a.cc:21:1: note: in expansion of macro 'll'
21 | ll f(ll b,ll n){
| ^~
a.cc: In function 'int main()':
a.cc:31:14: error: 'n' was not declared in this scope
31 | cin>>n>>s;
| ^
a.cc:31:17: error: 's' was not declared in this scope
31 | cin>>n>>s;
| ^
a.cc:33:20: error: 'f' was not declared in this scope
33 | if(f(i,n)==s){
| ^
|
s297805592
|
p04014
|
C++
|
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define dump(x) cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long int
int digitSum(int b, int n)
{
if (n < b)
return n;
else
return digitSum(b, n / b) + n % b;
}
signed main(void)
{
cin.tie(0);
ios::sync_with_stdio(false);
int n, s;
cin >> n >> s;
if (n < s){
cout << "-1" << endl;
return 0;
} else if (s == 1) {
cout << n << endl;
return 0;
} else if (s == n) {
cout << n+1 << endl;
return 0;
}
if (n < 1000000) {
REP(i,2,n) {
if (digitSum(i, n) == s) {
cout << i << endl;
return 0;
}
}
cout << "-1" << endl;
return 0;
}
int N = sqrt(n) + 1;
REP(i,2,N) {
if (digitSum(i, n) == s) {
cout << i << endl;
return 0;
}
}
for(int i = N; i >= 0; i--) {
int b = min((n-s)/(i+1)-2,2);
//dump(b);
rep(j, 5){
if (digitSum(b+j, n) == s) {
cout << b << endl;
return 0;
}
}
}
cout << "-1" << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:54:20: error: no matching function for call to 'min(long long int, int)'
54 | int b = min((n-s)/(i+1)-2,2);
| ~~~^~~~~~~~~~~~~~~~~
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:54:20: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
54 | int b = min((n-s)/(i+1)-2,2);
| ~~~^~~~~~~~~~~~~~~~~
/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:54:20: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
54 | int b = min((n-s)/(i+1)-2,2);
| ~~~^~~~~~~~~~~~~~~~~
|
s198904535
|
p04014
|
C++
|
#include <algorithm>
#include <complex>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using std::cin;
using std::cout;
using std::endl;
using std::cerr;
using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::stack;
using std::priority_queue;
using std::min;
using std::max;
using std::sort;
using std::abs;
typedef long long int ll;
const int MOD = 1e9 + 7;
ll f(ll b, ll n) { return n < b ? n : f(b, n / b) + n % b; }
ll solve(ll n, ll s) {
if (n < s) {
return -1;
}
// keta = 1
if (n == s) {
return n + 1;
}
// keta > 2
for (ll b = 2; b * b <= n; b++) {
if (f(b, n) == s) {
return b;
}
}
// keta = 2
for (ll p = 1; p * p < n; p++) {
ll b = 1 + (n - s) / p;
if(f(b, n) = s){
return b;
}
}
return -1;
}
int main() {
ll n, s;
cin >> n >> s;
cout << solve(n, s) << endl;
return 0;
}
|
a.cc: In function 'll solve(ll, ll)':
a.cc:53:13: error: lvalue required as left operand of assignment
53 | if(f(b, n) = s){
| ~^~~~~~
|
s960189627
|
p04014
|
C++
|
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln
#define int long long
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
struct oreno_initializer {
oreno_initializer() {
cin.tie(0);
ios::sync_with_stdio(0);
}
} oreno_initializer;
// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .。.:( ^ω^)・゚+.。.:( ^ω^)・゚+.。.:( ^ω^)・゚+.。.:( ^ω^)・゚+.。.:( ^ω^)・゚+
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・
ll n, s;
ll f(ll b, ll n) {
if (n<b) return n;
return f(b, n/b) + n%b;
}
int main() {
cin >> n >> s;
if (n==s) {
cout << n+1 << ln;
return 0;
}
// まず√nまで全探索
repst(b,2,sqrt(n)) {
if (f(b,n)==s) {
cout << b << ln;
return 0;
}
}
// ここまでで見つからなかったら、bが存在するとしたら(√n, n]の範囲
// √n<bのときはnのb進表記ってのは2桁になる (適当な数字で実際に考えるとわかる)
// 上位桁をp、下位桁をqとするとn = pb+qで、題意からp+q = sも成り立つ
// この2式をいろいろやるとb = (n-s+p)/p (qが消せる)
// つまり題意を満たすbってのは下位桁qに依存せず上位桁pから一意に決まるってことがわかる
// あとはpを全探索してこのbでf(b,n)==sがほんとに成り立つか確認
ll ans = linf;
reps(p,1,sqrt(n)) {
if ((n-s+p)%p!=0) continue;
ll b = (n-s+p)/p;
if (f(b,n)==s) chmin(ans, b);
}
if (ans!=linf) cout << ans << ln;
else cout << -1 << ln;
}
|
cc1plus: error: '::main' must return 'int'
|
s966284345
|
p04014
|
C++
|
#include <cstdio>
#include <cmath>
#include <vector>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define ALL(v) (v.begin()), (v.end())
typedef long long ll;
//------------------------------------------------------------------------------
vector<ll> divisor(ll n) {
vector<ll> res;
for (int i = 1; i * i <= n; i++) {
if (n % i == 0) {
res.push_back(i);
if (i != n / i) res.push_back(n / i);
}
}
return res;
}
//------------------------------------------------------------------------------
const ll N_MAX = 100000000000;
const ll S_MAX = 100000000000;
ll n;
ll s;
int f(int b, int k) {
int ret = 0;
while(k > 0) {
ret += k % b;
k = k / b;
}
return ret;
}
ll find() {
if (s > n) return -1;
int m = sqrt(n);
FOR(b, 2, m) {
if (f(b, n) == s) return b;
}
if (s == n) return n + 1;
vector<ll> divs = divisor(n - s);
sort(ALL(divs));
REP(i, divs.size()) {
ll d = divs[i];
ll r = s - (n - s) / d;
if (r >= 0 && r <= d) return d + 1;
}
return -1;
}
void solve() {
printf("%lld\n", find());
}
void input() {
scanf("%lld", &n);
scanf("%lld", &s);
}
int main() {
input();
solve();
return 0;
}
|
a.cc: In function 'll find()':
a.cc:49:3: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
49 | sort(ALL(divs));
| ^~~~
| sqrt
|
s475030257
|
p04014
|
C++
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll f(ll b,ll n){
if(n<b) return n;
else return f(b,n/b)+n%b;
}
ll solve(ll n,ll s){
if(n==s)return n+1;
if(n<s)return -1;
ll b=2;
for(;b*b<=n;b++){
if(f(b,n)==s)return i;
}
for(;b>0;i--){
if((n-s)%i==0 && f((n-s)/b+1,n)==s){
return (n-s)/b+1;
}
}
return -1;
}
int main(void){
ll n,s;
cin>>n>>s;
cout<<solve(n,s)<<endl;
return 0;
}
|
a.cc: In function 'll solve(ll, ll)':
a.cc:16:37: error: 'i' was not declared in this scope
16 | if(f(b,n)==s)return i;
| ^
a.cc:19:18: error: 'i' was not declared in this scope
19 | for(;b>0;i--){
| ^
|
s332844541
|
p04014
|
C++
|
#include<stdio.h>
int ds(int n, int b){
int s=0;
while(n>0){
s=s+n%b;
n=n/b;
}
return s;
}
int main(){
int n,s,i;
scanf("%d %d",&n, &s);
if(n-s<0) printf("-1");
if(n-s==0) printf("%d",n+1);
for(i=2;i*i<=n;i++){
if(ds(n,i)==s){
printf("%d",i);
return 0;
}
}
for(;--i;){
b=(n-s)/i+1;
if(b<2) continue;
if(f(b,n)==s){
printf("%d",b);
return 0;
}
}
printf("-1");
return 0;
}
|
a.cc: In function 'int main()':
a.cc:23:17: error: 'b' was not declared in this scope
23 | b=(n-s)/i+1;
| ^
a.cc:25:20: error: 'f' was not declared in this scope
25 | if(f(b,n)==s){
| ^
|
s161545105
|
p04014
|
C++
|
#include <iostream>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll n, s;
ll ds(ll n, int b){
ll s = 0;
while(n){
s += n % b;
n /= b;
}
return s;
}
int main(){
cin >> n >> s;
ll d = n - s;
if(d <= 0){
cout << (d == 0 ? n + 1 : -1) << endl;
return 0;
}
int i;
for(i = 2; ll(i) * i <= n; ++i){
if(ds(n, i) == s){
cout << i << endl;
return 0;
}
}
for(--i; i > 0; --i){
if(d % i == 0 && s >= i && d / i >= max(i, s - i)){
cout << d / i + 1 << endl;
return 0;
}
}
cout << -1 << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:36:56: error: no matching function for call to 'max(int&, ll)'
36 | if(d % i == 0 && s >= i && d / i >= max(i, s - i)){
| ~~~^~~~~~~~~~
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:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:36:56: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
36 | if(d % i == 0 && s >= i && d / i >= max(i, s - i)){
| ~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:36:56: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
36 | if(d % i == 0 && s >= i && d / i >= max(i, s - i)){
| ~~~^~~~~~~~~~
|
s088056840
|
p04014
|
C++
|
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
using namespace std;
ll N,S;
ll f(ll b,ll n){
if(n<b) return n;
return f(b,n/b)+n%b;
}
void solve(){
if(S>N){
printf("-1\n");return;
}
if(N==S){
printf("%lld\n",N+1);
return;
}
ll i=0;
for (i = 2;i*i<=N;i++){
if(S==f(i,N)){
printf("%lld\n",i);
return;
}
}
ll b = 100000000001;
for (int p = sqrt(N);p>0;p--){
ll b = (n-s)/p + 1;
if(b>1&&f(b,N)==S){
cout << b <<endl;
return;
}
}
if(b<100000000001)printf("%lld\n",b);
else printf("-1\n");
}
int main() {
cin >> N;
cin >> S;
solve();
return 0;
}
|
a.cc: In function 'void solve()':
a.cc:31:21: error: 'n' was not declared in this scope
31 | ll b = (n-s)/p + 1;
| ^
a.cc:31:23: error: 's' was not declared in this scope
31 | ll b = (n-s)/p + 1;
| ^
|
s293537837
|
p04014
|
C++
|
#include<bits/stdc++.h>
using namespace std;long long n,s,sum,g,i,A,B,C;main(){cin>>n>>s;if(n==s){cout<<n+1<<endl;goto F;}for(i=2;i<=min(n+1,3000000LL);i++){sum=0;g=1;while(g<=1LL<<37){sum+=(n/g)%i;g*=i;}if(sum==s){cout<<i<<endl;goto E;}}for(i=min(s,n/1000000);i>=1;i--){A=i,B=s-i;if((n-B)%A!=0)continue;C=(n-B)/A;if(C<=B||C<=1)continue;cout<<C<<endl;goto E;}cout<<"-1"<<endl;E:;}
|
a.cc:2:49: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
2 | using namespace std;long long n,s,sum,g,i,A,B,C;main(){cin>>n>>s;if(n==s){cout<<n+1<<endl;goto F;}for(i=2;i<=min(n+1,3000000LL);i++){sum=0;g=1;while(g<=1LL<<37){sum+=(n/g)%i;g*=i;}if(sum==s){cout<<i<<endl;goto E;}}for(i=min(s,n/1000000);i>=1;i--){A=i,B=s-i;if((n-B)%A!=0)continue;C=(n-B)/A;if(C<=B||C<=1)continue;cout<<C<<endl;goto E;}cout<<"-1"<<endl;E:;}
| ^~~~
a.cc: In function 'int main()':
a.cc:2:96: error: label 'F' used but not defined
2 | using namespace std;long long n,s,sum,g,i,A,B,C;main(){cin>>n>>s;if(n==s){cout<<n+1<<endl;goto F;}for(i=2;i<=min(n+1,3000000LL);i++){sum=0;g=1;while(g<=1LL<<37){sum+=(n/g)%i;g*=i;}if(sum==s){cout<<i<<endl;goto E;}}for(i=min(s,n/1000000);i>=1;i--){A=i,B=s-i;if((n-B)%A!=0)continue;C=(n-B)/A;if(C<=B||C<=1)continue;cout<<C<<endl;goto E;}cout<<"-1"<<endl;E:;}
| ^
|
s191797257
|
p04014
|
C++
|
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <string>
#include <climits>
using namespace std;
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) FOR(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
const unsigned long long MOD = 100000000000000000;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
#define INF INT_MAX/3
#define MAX_N 100000000000
int N,S;
bool flag=false;
bool CONTINUE=true;
ll p;
ll func(ll b,ll n){
if(n<b){
return n;
} else {
return dp[b]=func(b,floor(n/b))+(n%b);
}
}
/*
bool check(ll m){
p=func(m,N);
if(p==S&&m>=2){
cout<<-1<<endl;
flag=true;
return false;
} else if(p==S&&m<2){
cout<<-2<<endl;
flag=false;
return true;
} else if(p>S){
return false;
}
return true;
}
*/
void solve(){
int i=0;
cin>>N>>S;
ll l=0;
ll r=N;
ll mid=0;
ll ans=INT_MAX;
ll o;
for(int j=0;j<100;j++){
i++;
cout<<i<<" "<<l<<" "<<r<<endl;
mid=(r+l)/2;
o=func(mid,N);
if(o==S){
flag=true;
l=0;
if(ans>o) ans=o;
}else if(o<S){
l=1+mid;
} else {
r=mid;
}
}
if(flag){
cout<<ans<<endl;
} else {
cout<<-1<<endl;
}
}
int main(){
solve();
return 0;
}
|
a.cc: In function 'll func(ll, ll)':
a.cc:39:12: error: 'dp' was not declared in this scope; did you mean 'p'?
39 | return dp[b]=func(b,floor(n/b))+(n%b);
| ^~
| p
|
s877307124
|
p04015
|
C++
|
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;
// dijkstra
struct edge{ll to, cost;};
typedef pair<ll,ll> P;
struct graph{
ll V;
vector<vector<edge> > G;
vector<ll> d;
graph(ll n){
init(n);
}
void init(ll n){
V = n;
G.resize(V);
d.resize(V);
rep(i,V){
d[i] = INF;
}
}
void add_edge(ll s, ll t, ll cost){
edge e;
e.to = t, e.cost = cost;
G[s].push_back(e);
}
void dijkstra(ll s){
rep(i,V){
d[i] = INF;
}
d[s] = 0;
priority_queue<P,vector<P>, greater<P> > que;
que.push(P(0,s));
while(!que.empty()){
P p = que.top(); que.pop();
ll v = p.second;
if(d[v]<p.first) continue;
for(auto e : G[v]){
if(d[e.to]>d[v]+e.cost){
d[e.to] = d[v]+e.cost;
que.push(P(d[e.to],e.to));
}
}
}
}
};
// dijkstra end
class UnionFind
{
public:
ll par[100005];
ll depth[100005];
ll nGroup[100005];
UnionFind(ll n) {
init(n);
}
void init(ll n) {
for(ll i=0; i<n; i++) {
par[i] = i;
depth[i] = 0;
nGroup[i] = 1;
}
}
ll root(ll x) {
if(par[x] == x) {
return x;
} else {
return par[x] = root(par[x]);
}
}
bool same(ll x, ll y) {
return root(x) == root(y);
}
void unite(ll x, ll y) {
x = root(x);
y = root(y);
if(x == y) return;
if(depth[x] < depth[y]) {
par[x] = y;
nGroup[y] += nGroup[x];
nGroup[x] = 0;
} else {
par[y] = x;
nGroup[x] += nGroup[y];
nGroup[y] = 0;
if(depth[x] == depth[y])
depth[x]++;
}
}
};
// unionfind end
// nCr
const ll MAX = 500010;
ll fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (ll 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;
}
}
// nCr end
// tree DP
vector<ll> depth;
vector<ll> f;
vector<ll> g;
void dfs(const Graph &G, ll v, ll p, ll d) {
depth[v] = d;
for (auto nv : G[v]) {
if (nv == p) continue;
dfs(G, nv, v, d+1);
}
f[v] = 1;
g[v] = 1;
for (auto c : G[v]) {
if (c == p) continue;
f[v]*=g[c];
f[v]%=MOD;
g[v]*=f[c];
g[v]%=MOD;
}
f[v]+=g[v];
f[v]%=MOD;
}
// tree DP end
template<ll MOD> struct Fp {
ll val;
constexpr Fp(ll v = 0) noexcept : val(v % MOD) {
if (val < 0) val += MOD;
}
constexpr ll 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 {
ll a = r.val, b = MOD, u = 1, v = 0;
while (b) {
ll 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 Fp<MOD> modpow(const Fp<MOD> &a, ll n) noexcept {
if (n == 0) return 1;
auto t = modpow(a, n / 2);
t = t * t;
if (n & 1) t = t * a;
return t;
}
};
using mint = Fp<MOD>;
mint calc(ll N, ll K) {
mint res = 1;
for (ll n = 0; n < K; ++n) {
res *= (N - n);
res /= (n + 1);
}
return res;
}
mint COM(ll n, ll k){
if (k == 0) return 1;
if (n < k) return 0;
if (n < 0 || k < 0) return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct S{
long long value;
ll size;
};
using F = long long;
const F ID = 8e18;
S op(S a, S b){ return {a.value+b.value, a.size+b.size}; }
S e(){ return {0, 0}; }
S mapping(F f, S x){
if(f != ID) x.value = f*x.value%MOD9;
return x;
}
F composition(F f, F g){ return (f == ID ? g : f); }
F id(){ return 0; }
ll dp[55][150];
int main(){
ll n,a; cin>>n>>a;
ll x[n]={};
rep(i,n){
cin>>x[i];
x[i]-=a;
x[i]+=100;}
dp[0][100]++;
rep(i,n){
rep(j,150){
if(j>=x[i]){
dp[i+1][j] += dp[i][j-x[i]];
}
dp[i+1][j] += dp[i][j];
}
}
cout << dp[n][100] << endl;
}
|
a.cc:2:9: fatal error: atcoder/all: No such file or directory
2 | #include<atcoder/all>
| ^~~~~~~~~~~~~
compilation terminated.
|
s037787109
|
p04015
|
C++
|
//g++ main.cpp -I /usr/local/include/ac-library
//#include <atcoder/all>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
//using namespace atcoder;
stack<int> st;
queue<int> qu;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define sz(x) (int)(x).size()
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
ll dp[51][51][2501];
int main(){
int n,a;
cin >> n>> a;
vector<int> x[n+1];
x[0]=0;
rep2(i,n){
cin >> x[i];
}
rep(j,n+1){
rep(k,n+1){
rep(s,n*50+1){
if(j==0&&k==0&&s==0){
dp[j][k][s]=1;
}else if(j>=1&&s<x[j]){
dp[j][k][s]=dp[j-1][k][s];
}else if(j>=1&&k>=1&&s>=x[j]){
dp[j][k][s]=dp[j-1][k][s]+dp[j-1][k-1][s-x[j]];
}else{
dp[j][k][s]=0;
}
}
}
}
ll ans=0;
rep2(k,n){
ans+=dp[n][k][k*a];
}
cout<<ans<<endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:23:10: error: no match for 'operator=' (operand types are 'std::vector<int>' and 'int')
23 | x[0]=0;
| ^
In file included from /usr/include/c++/14/vector:72,
from /usr/include/c++/14/functional:64,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
from a.cc:3:
/usr/include/c++/14/bits/vector.tcc:210:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]'
210 | vector<_Tp, _Alloc>::
| ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:211:42: note: no known conversion for argument 1 from 'int' to 'const std::vector<int>&'
211 | operator=(const vector<_Tp, _Alloc>& __x)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/14/vector:66:
/usr/include/c++/14/bits/stl_vector.h:766:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = int; _Alloc = std::allocator<int>]'
766 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
| ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:766:26: note: no known conversion for argument 1 from 'int' to 'std::vector<int>&&'
766 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
| ~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:788:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>]'
788 | operator=(initializer_list<value_type> __l)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:788:46: note: no known conversion for argument 1 from 'int' to 'std::initializer_list<int>'
788 | operator=(initializer_list<value_type> __l)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
a.cc:25:13: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'std::vector<int>')
25 | cin >> x[i];
| ~~~ ^~ ~~~~
| | |
| | std::vector<int>
| std::istream {aka std::basic_istream<char>}
In file included 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/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
170 | operator>>(bool& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:170:24: note: no known conversion for argument 1 from 'std::vector<int>' to 'bool&'
170 | operator>>(bool& __n)
| ~~~~~~^~~
/usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]'
174 | operator>>(short& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:174:25: note: no known conversion for argument 1 from 'std::vector<int>' to 'short int&'
174 | operator>>(short& __n);
| ~~~~~~~^~~
/usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
177 | operator>>(unsigned short& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:177:34: note: no known conversion for argument 1 from 'std::vector<int>' to 'short unsigned int&'
177 | operator>>(unsigned short& __n)
| ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]'
181 | operator>>(int& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:181:23: note: no known conversion for argument 1 from 'std::vector<int>' to 'int&'
181 | operator>>(int& __n);
| ~~~~~^~~
/usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
184 | operator>>(unsigned int& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:184:32: note: no known conversion for argument 1 from 'std::vector<int>' to 'unsigned int&'
184 | operator>>(unsigned int& __n)
| ~~~~~~~~~~~~~~^~~
/usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
188 | operator>>(long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:188:24: note: no known conversion for argument 1 from 'std::vector<int>' to 'long int&'
188 | operator>>(long& __n)
| ~~~~~~^~~
/usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
192 | operator>>(unsigned long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:192:33: note: no known conversion for argument 1 from 'std::vector<int>' to 'long unsigned int&'
192 | operator>>(unsigned long& __n)
| ~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
199 | operator>>(long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:199:29: note: no known conversion for argument 1 from 'std::vector<int>' to 'long long int&'
199 | operator>>(long long& __n)
| ~~~~~~~~~~~^~~
/usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
203 | operator>>(unsigned long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:203:38: note: no known conversion for argument 1 from 'std::vector<int>' to 'long long unsigned int&'
203 | operator>>(unsigned long long& __n)
| ~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/istream:219:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(float&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
219 | operator>>(float& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:219:25: note: no known conversion for argument 1 from 'std::vector<int>' to 'float&'
219 | operator>>(float& __f)
| ~~~~~~~^~~
/usr/include/c++/14/istream:223:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
223 | operator>>(double& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:223:26: note: no known conversion for argument 1 from 'std::vector<int>' to 'double&'
223 | operator>>(double& __f)
| ~~~~~~~~^~~
/usr/include/c++/14/istream:227:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
227 | operator>>(long double& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:227:31: note: no known conversion for argument 1 from 'std::vector<int>' to 'long double&'
227 | operator>>(long double& __f)
| ~~~~~~~~~~~~~^~~
/usr/include/c++/14/istream:328:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
328 | operator>>(void*& __p)
| ^~~~~~~~
/usr/include/c++/14/istream:328:25: note: no known conversion for argument 1 from 'std::vector<int>' to 'void*&'
328 | operator>>(void*& __p)
| ~~~~~~~^~~
/usr/include/c++/14/istream:122:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__istream_type& (*)(__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
122 | operator>>(__istream_type& (*__pf)(__istream_type&))
| ^~~~~~~~
/usr/include/c++/14/istream:122:36: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'}
122 | operator>>(__istream_type& (*__pf)(__istream_type&))
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/istream:126:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basi
|
s745633735
|
p04015
|
C++
|
//g++ main.cpp -I /usr/local/include/ac-library
#include<cmath>
//#include <atcoder/all>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
//using namespace atcoder;
stack<int> st;
queue<int> qu;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
#define ALL(a) a.begin(), a.end()
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define pb push_back
#define sz(x) (int)(x).size()
#define mod 1000000007
//#define mint=modint1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<int, int> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
ll dp[55][55][2505];
int main(){
int n,a;
cin >> n>> a;
vector<int> x(n,0);
rep2(i,n){
cin >> x[i];
}
rep(j,n+1){
rep(k,n+1){
rep(s,n*x+1){
if(j==0&&k==0&&s==0){
dp[j][k][s]=1;
}else if(j>=1&&s<x[j]){
dp[j][k][s]=dp[j-1][k][s];
}else if(j>=1&&k>=1&&s>=x[j]){
dp[j][k][s]=dp[j-1][k][s]+dp[j-1][k-1][s-x[j]];
}else{
dp[j][k][s]=0;
}
}
}
}
ll ans=0;
rep2(k,n){
ans+=dp[n][k][k*a];
}
cout<<ans<<endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:49:20: error: no match for 'operator*' (operand types are 'int' and 'std::vector<int>')
49 | rep(s,n*x+1){
| ~^~
| | |
| | std::vector<int>
| int
a.cc:11:39: note: in definition of macro 'rep'
11 | #define rep(i,n) for(int i=0; i<(int)(n); i++)
| ^
In file included from /usr/include/c++/14/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127,
from a.cc:4:
/usr/include/c++/14/complex:400:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator*(const complex<_Tp>&, const complex<_Tp>&)'
400 | operator*(const complex<_Tp>& __x, const complex<_Tp>& __y)
| ^~~~~~~~
/usr/include/c++/14/complex:400:5: note: template argument deduction/substitution failed:
a.cc:49:21: note: mismatched types 'const std::complex<_Tp>' and 'int'
49 | rep(s,n*x+1){
| ^
a.cc:11:39: note: in definition of macro 'rep'
11 | #define rep(i,n) for(int i=0; i<(int)(n); i++)
| ^
/usr/include/c++/14/complex:409:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator*(const complex<_Tp>&, const _Tp&)'
409 | operator*(const complex<_Tp>& __x, const _Tp& __y)
| ^~~~~~~~
/usr/include/c++/14/complex:409:5: note: template argument deduction/substitution failed:
a.cc:49:21: note: mismatched types 'const std::complex<_Tp>' and 'int'
49 | rep(s,n*x+1){
| ^
a.cc:11:39: note: in definition of macro 'rep'
11 | #define rep(i,n) for(int i=0; i<(int)(n); i++)
| ^
/usr/include/c++/14/complex:418:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator*(const _Tp&, const complex<_Tp>&)'
418 | operator*(const _Tp& __x, const complex<_Tp>& __y)
| ^~~~~~~~
/usr/include/c++/14/complex:418:5: note: template argument deduction/substitution failed:
a.cc:49:21: note: 'std::vector<int>' is not derived from 'const std::complex<_Tp>'
49 | rep(s,n*x+1){
| ^
a.cc:11:39: note: in definition of macro 'rep'
11 | #define rep(i,n) for(int i=0; i<(int)(n); i++)
| ^
In file included from /usr/include/c++/14/valarray:605,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166:
/usr/include/c++/14/bits/valarray_after.h:407:5: note: candidate: 'template<class _Dom1, class _Dom2> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_Expr, std::_Expr, _Dom1, _Dom2>, typename std::__fun<std::__multiplies, typename _Dom1::value_type>::result_type> std::operator*(const _Expr<_Dom1, typename _Dom1::value_type>&, const _Expr<_Dom2, typename _Dom2::value_type>&)'
407 | _DEFINE_EXPR_BINARY_OPERATOR(*, struct std::__multiplies)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:407:5: note: template argument deduction/substitution failed:
a.cc:49:21: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int'
49 | rep(s,n*x+1){
| ^
a.cc:11:39: note: in definition of macro 'rep'
11 | #define rep(i,n) for(int i=0; i<(int)(n); i++)
| ^
/usr/include/c++/14/bits/valarray_after.h:407:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_Expr, std::_Constant, _Dom, typename _Dom::value_type>, typename std::__fun<std::__multiplies, typename _Dom1::value_type>::result_type> std::operator*(const _Expr<_Dom1, typename _Dom1::value_type>&, const typename _Dom::value_type&)'
407 | _DEFINE_EXPR_BINARY_OPERATOR(*, struct std::__multiplies)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:407:5: note: template argument deduction/substitution failed:
a.cc:49:21: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int'
49 | rep(s,n*x+1){
| ^
a.cc:11:39: note: in definition of macro 'rep'
11 | #define rep(i,n) for(int i=0; i<(int)(n); i++)
| ^
/usr/include/c++/14/bits/valarray_after.h:407:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_Constant, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__multiplies, typename _Dom1::value_type>::result_type> std::operator*(const typename _Dom::value_type&, const _Expr<_Dom1, typename _Dom1::value_type>&)'
407 | _DEFINE_EXPR_BINARY_OPERATOR(*, struct std::__multiplies)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:407:5: note: template argument deduction/substitution failed:
a.cc:49:21: note: 'std::vector<int>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
49 | rep(s,n*x+1){
| ^
a.cc:11:39: note: in definition of macro 'rep'
11 | #define rep(i,n) for(int i=0; i<(int)(n); i++)
| ^
/usr/include/c++/14/bits/valarray_after.h:407:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_Expr, std::_ValArray, _Dom, typename _Dom::value_type>, typename std::__fun<std::__multiplies, typename _Dom1::value_type>::result_type> std::operator*(const _Expr<_Dom1, typename _Dom1::value_type>&, const valarray<typename _Dom::value_type>&)'
407 | _DEFINE_EXPR_BINARY_OPERATOR(*, struct std::__multiplies)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:407:5: note: template argument deduction/substitution failed:
a.cc:49:21: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int'
49 | rep(s,n*x+1){
| ^
a.cc:11:39: note: in definition of macro 'rep'
11 | #define rep(i,n) for(int i=0; i<(int)(n); i++)
| ^
/usr/include/c++/14/bits/valarray_after.h:407:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_ValArray, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__multiplies, typename _Dom1::value_type>::result_type> std::operator*(const valarray<typename _Dom::value_type>&, const _Expr<_Dom1, typename _Dom1::value_type>&)'
407 | _DEFINE_EXPR_BINARY_OPERATOR(*, struct std::__multiplies)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:407:5: note: template argument deduction/substitution failed:
a.cc:49:21: note: 'std::vector<int>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
49 | rep(s,n*x+1){
| ^
a.cc:11:39: note: in definition of macro 'rep'
11 | #define rep(i,n) for(int i=0; i<(int)(n); i++)
| ^
/usr/include/c++/14/valarray:1198:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_ValArray, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__multiplies, _Tp>::result_type> std::operator*(const valarray<_Tp>&, const valarray<_Tp>&)'
1198 | _DEFINE_BINARY_OPERATOR(*, __multiplies)
| ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/valarray:1198:1: note: template argument deduction/substitution failed:
a.cc:49:21: note: mismatched types 'const std::valarray<_Tp>' and 'int'
49 | rep(s,n*x+1){
| ^
a.cc:11:39: note: in definition of macro 'rep'
11 | #define rep(i,n) for(int i=0; i<(int)(n); i++)
| ^
/usr/include/c++/14/valarray:1198:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_ValArray, std::_Constant, _Tp, _Tp>, typename std::__fun<std::__multiplies, _Tp>::result_type> std::operator*(const valarray<_Tp>&, const typename valarray<_Tp>::value_type&)'
1198 | _DEFINE_BINARY_OPERATOR(*, __multiplies)
| ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/valarray:1198:1: note: template argument deduction/substitution failed:
a.cc:49:21: note: mismatched types 'const std::valarray<_Tp>' and 'int'
49 | rep(s,n*x+1){
| ^
a.cc:11:39: note: in definition of macro 'rep'
11 | #define rep(i,n) for(int i=0; i<(int)(n); i++)
| ^
/usr/include/c++/14/valarray:1198:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_Constant, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__multiplies, _Tp>::result_type> std::operator*(const typename valarray<_Tp>::value_type&, const valarray<_Tp>&)'
1198 | _DEFINE_BINARY_OPERATOR(*, __multiplies)
| ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/valarray:1198:1: note: template argument deduction/substitution failed:
a.cc:49:21: note: 'std::vector<int>' is not derived from 'const std::valarray<_Tp>'
49 | rep(s,n*x+1){
| ^
a.cc:11:39: note: in definition of macro 'rep'
11 | #define rep(i,n) for(int i=0; i<(int)(n); i++)
| ^
|
s286682752
|
p04015
|
C++
|
а
|
a.cc:1:1: error: '\U00000430' does not name a type
1 | а
| ^
|
s636805343
|
p04015
|
C++
|
///#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define int long long
#define all(x) (x).begin(), (x).end()
#define finout(x) freopen(x".in", "r", stdin); freopen(x".out", "w", stdout);
#define X first
#define Y second
using namespace std;
const int MOD = 1e9 + 7;
typedef pair <int, int> pii;
typedef vector <int> vi;
inline int ni() {int x; cin >> x; return x;}
template <class T>
inline T nt() {T x; cin >> x; return x;}
inline void print(){}
template<typename T, typename ...TAIL>
inline void print(const T &t, TAIL... tail) {cout << t; print(tail...);}
inline void input() {return;}
template<typename T, typename ...TAIL>
inline void input(T &t, TAIL&... tail) {cin >> t; input(tail...);}
const int N = 1001;
const int inf = 1e9 + 3;
const double PI = 3.14159265359;
signed main () {
///#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define int long long
#define all(x) (x).begin(), (x).end()
#define finout(x) freopen(x".in", "r", stdin); freopen(x".out", "w", stdout);
#define X first
#define Y second
using namespace std;
const int MOD = 1e9 + 7;
typedef pair <int, int> pii;
typedef vector <int> vi;
inline int ni() {int x; cin >> x; return x;}
template <class T>
inline T nt() {T x; cin >> x; return x;}
inline void print(){}
template<typename T, typename ...TAIL>
inline void print(const T &t, TAIL... tail) {cout << t; print(tail...);}
inline void input() {return;}
template<typename T, typename ...TAIL>
inline void input(T &t, TAIL&... tail) {cin >> t; input(tail...);}
const int N = 2 * 1005001;
const int inf = 1e9 + 7;
const double PI = 3.14159265359;
vector <pair <int, int> > q[N];
vi v;
int L;
int ans[N];
int pr[N];
int sfx[N];
int prAns[N];
int sfxAns[N];
void solve(int l, int r) {
/// cout << l << ' ' << r << '\n';
if (l + 1 == r) {
for (auto it : q[l]) {
ans[it.second] = 1;
}
return;
}
for (int i = l; i < r; i++) {
pr[i] = 0; sfx[i] = 0; prAns[i] = 0; sfxAns[i] = 0;
}
int m = (l + r) / 2;
int last = m - 1;
int curd = 0;
int curAns = 1;
int ssfx0 = 0, ppref0 = 0;
for (int i = m - 1; i >= l; i--) {
curd = abs(v[i] - v[last]);
if (curd > L) {
curd = 0;
last = i + 1;
curAns++;
}
if (curAns == 1) ssfx0 = curd;
sfx[i] = curd;
sfxAns[i] = curAns;
}
curd = 0;
last = m;
curAns = 1;
for (int i = m; i < r; i++) {
curd = abs(v[i] - v[last]);
if (curd > L) {
curd = 0;
last = i - 1;
curAns++;
}
if (curAns == 1) ppref0 = curd;
pr[i] = curd;
prAns[i] = curAns;
}
for (int i = m - 1; i >= l; i--) {
while (!q[i].empty() && q[i].back().first >= m) {
int l = i, r = q[i].back().first, ind = q[i].back().second;
q[i].pop_back();
int anss = prAns[r] + sfxAns[l];
if ((prAns[r] > 1 ? ppref0 : pr[r]) + (sfxAns[l] > 1 ? ssfx0 : sfx[l]) + abs(v[m] - v[m - 1]) <= L) anss--;
ans[ind] = anss;
}
}
solve(l, m);
solve(m, r);
}
signed main () {
ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0);
int n = ni();
for (int i = 0; i < n; i++) v.push_back(ni());
L = ni();
int Q = ni();
for (int i = 0; i < Q; i++) {
int l, r;
cin >> l >> r;
l--; r--;
if (l > r) swap(l, r);
q[l].push_back({r, i});
}
for (int i = 0; i < n; i++) {
sort(all(q[i]));
}
solve(0, n);
for (int i = 0; i < Q; i++) {
cout << ans[i] << '\n';
}
}
return 0;
}
|
a.cc: In function 'int main()':
a.cc:42:14: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
42 | inline int ni() {int x; cin >> x; return x;}
| ^~
a.cc:42:14: note: remove parentheses to default-initialize a variable
42 | inline int ni() {int x; cin >> x; return x;}
| ^~
| --
a.cc:42:14: note: or replace parentheses with braces to value-initialize a variable
a.cc:42:17: error: a function-definition is not allowed here before '{' token
42 | inline int ni() {int x; cin >> x; return x;}
| ^
a.cc:43:1: error: a template declaration cannot appear at block scope
43 | template <class T>
| ^~~~~~~~
a.cc:46:1: error: a template declaration cannot appear at block scope
46 | template<typename T, typename ...TAIL>
| ^~~~~~~~
a.cc:49:1: error: a template declaration cannot appear at block scope
49 | template<typename T, typename ...TAIL>
| ^~~~~~~~
a.cc:69:26: error: a function-definition is not allowed here before '{' token
69 | void solve(int l, int r) {
| ^
a.cc:124:13: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
124 | signed main () {
| ^~
a.cc:124:13: note: remove parentheses to default-initialize a variable
124 | signed main () {
| ^~
| --
a.cc:124:13: note: or replace parentheses with braces to value-initialize a variable
a.cc:124:16: error: a function-definition is not allowed here before '{' token
124 | signed main () {
| ^
|
s738651221
|
p04015
|
C++
|
///#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define int long long
#define all(x) (x).begin(), (x).end()
#define finout(x) freopen(x".in", "r", stdin); freopen(x".out", "w", stdout);
#define X first
#define Y second
using namespace std;
const int MOD = 1e9 + 7;
typedef pair <int, int> pii;
typedef vector <int> vi;
inline int ni() {int x; cin >> x; return x;}
template <class T>
inline T nt() {T x; cin >> x; return x;}
inline void print(){}
template<typename T, typename ...TAIL>
inline void print(const T &t, TAIL... tail) {cout << t; print(tail...);}
inline void input() {return;}
template<typename T, typename ...TAIL>
inline void input(T &t, TAIL&... tail) {cin >> t; input(tail...);}
const int N = 1001;
const int inf = 1e9 + 3;
const double PI = 3.14159265359;
signed main () {
///#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define int long long
#define all(x) (x).begin(), (x).end()
#define finout(x) freopen(x".in", "r", stdin); freopen(x".out", "w", stdout);
#define X first
#define Y second
using namespace std;
const int MOD = 1e9 + 7;
typedef pair <int, int> pii;
typedef vector <int> vi;
inline int ni() {int x; cin >> x; return x;}
template <class T>
inline T nt() {T x; cin >> x; return x;}
inline void print(){}
template<typename T, typename ...TAIL>
inline void print(const T &t, TAIL... tail) {cout << t; print(tail...);}
inline void input() {return;}
template<typename T, typename ...TAIL>
inline void input(T &t, TAIL&... tail) {cin >> t; input(tail...);}
const int N = 2 * 1005001;
const int inf = 1e9 + 7;
const double PI = 3.14159265359;
vector <pair <int, int> > q[N];
vi v;
int L;
int ans[N];
int pr[N];
int sfx[N];
int prAns[N];
int sfxAns[N];
void solve(int l, int r) {
/// cout << l << ' ' << r << '\n';
if (l + 1 == r) {
for (auto it : q[l]) {
ans[it.second] = 1;
}
return;
}
for (int i = l; i < r; i++) {
pr[i] = 0; sfx[i] = 0; prAns[i] = 0; sfxAns[i] = 0;
}
int m = (l + r) / 2;
int last = m - 1;
int curd = 0;
int curAns = 1;
int ssfx0 = 0, ppref0 = 0;
for (int i = m - 1; i >= l; i--) {
curd = abs(v[i] - v[last]);
if (curd > L) {
curd = 0;
last = i + 1;
curAns++;
}
if (curAns == 1) ssfx0 = curd;
sfx[i] = curd;
sfxAns[i] = curAns;
}
curd = 0;
last = m;
curAns = 1;
for (int i = m; i < r; i++) {
curd = abs(v[i] - v[last]);
if (curd > L) {
curd = 0;
last = i - 1;
curAns++;
}
if (curAns == 1) ppref0 = curd;
pr[i] = curd;
prAns[i] = curAns;
}
for (int i = m - 1; i >= l; i--) {
while (!q[i].empty() && q[i].back().first >= m) {
int l = i, r = q[i].back().first, ind = q[i].back().second;
q[i].pop_back();
int anss = prAns[r] + sfxAns[l];
if ((prAns[r] > 1 ? ppref0 : pr[r]) + (sfxAns[l] > 1 ? ssfx0 : sfx[l]) + abs(v[m] - v[m - 1]) <= L) anss--;
ans[ind] = anss;
}
}
solve(l, m);
solve(m, r);
}
signed main () {
ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0);
int n = ni();
for (int i = 0; i < n; i++) v.push_back(ni());
L = ni();
int Q = ni();
for (int i = 0; i < Q; i++) {
int l, r;
cin >> l >> r;
l--; r--;
if (l > r) swap(l, r);
q[l].push_back({r, i});
}
for (int i = 0; i < n; i++) {
sort(all(q[i]));
}
solve(0, n);
for (int i = 0; i < Q; i++) {
cout << ans[i] << '\n';
}
}
return 0;
}
|
a.cc: In function 'int main()':
a.cc:42:14: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
42 | inline int ni() {int x; cin >> x; return x;}
| ^~
a.cc:42:14: note: remove parentheses to default-initialize a variable
42 | inline int ni() {int x; cin >> x; return x;}
| ^~
| --
a.cc:42:14: note: or replace parentheses with braces to value-initialize a variable
a.cc:42:17: error: a function-definition is not allowed here before '{' token
42 | inline int ni() {int x; cin >> x; return x;}
| ^
a.cc:43:1: error: a template declaration cannot appear at block scope
43 | template <class T>
| ^~~~~~~~
a.cc:46:1: error: a template declaration cannot appear at block scope
46 | template<typename T, typename ...TAIL>
| ^~~~~~~~
a.cc:49:1: error: a template declaration cannot appear at block scope
49 | template<typename T, typename ...TAIL>
| ^~~~~~~~
a.cc:69:26: error: a function-definition is not allowed here before '{' token
69 | void solve(int l, int r) {
| ^
a.cc:124:13: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
124 | signed main () {
| ^~
a.cc:124:13: note: remove parentheses to default-initialize a variable
124 | signed main () {
| ^~
| --
a.cc:124:13: note: or replace parentheses with braces to value-initialize a variable
a.cc:124:16: error: a function-definition is not allowed here before '{' token
124 | signed main () {
| ^
|
s568176013
|
p04015
|
C++
|
///#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define int long long
#define all(x) (x).begin(), (x).end()
#define finout(x) freopen(x".in", "r", stdin); freopen(x".out", "w", stdout);
#define X first
#define Y second
using namespace std;
const int MOD = 1e9 + 7;
typedef pair <int, int> pii;
typedef vector <int> vi;
inline int ni() {int x; cin >> x; return x;}
template <class T>
inline T nt() {T x; cin >> x; return x;}
inline void print(){}
template<typename T, typename ...TAIL>
inline void print(const T &t, TAIL... tail) {cout << t; print(tail...);}
inline void input() {return;}
template<typename T, typename ...TAIL>
inline void input(T &t, TAIL&... tail) {cin >> t; input(tail...);}
const int N = 1001;
const int inf = 1e9 + 3;
const double PI = 3.14159265359;
signed main () {
///#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define int long long
#define all(x) (x).begin(), (x).end()
#define finout(x) freopen(x".in", "r", stdin); freopen(x".out", "w", stdout);
#define X first
#define Y second
using namespace std;
const int MOD = 1e9 + 7;
typedef pair <int, int> pii;
typedef vector <int> vi;
inline int ni() {int x; cin >> x; return x;}
template <class T>
inline T nt() {T x; cin >> x; return x;}
inline void print(){}
template<typename T, typename ...TAIL>
inline void print(const T &t, TAIL... tail) {cout << t; print(tail...);}
inline void input() {return;}
template<typename T, typename ...TAIL>
inline void input(T &t, TAIL&... tail) {cin >> t; input(tail...);}
const int N = 2 * 1005001;
const int inf = 1e9 + 7;
const double PI = 3.14159265359;
vector <pair <int, int> > q[N];
vi v;
int L;
int ans[N];
int pr[N];
int sfx[N];
int prAns[N];
int sfxAns[N];
void solve(int l, int r) {
/// cout << l << ' ' << r << '\n';
if (r - l <= 2) {
for (auto it : q[l]) {
ans[it.second] = 1;
}
for (auto it : q[r]) {
ans[it.second] = 1;
}
return;
}
for (int i = l; i < r; i++) {
pr[i] = 0; sfx[i] = 0; prAns[i] = 0; sfxAns[i] = 0;
}
int m = (l + r) / 2;
int last = m - 1;
int curd = 0;
int curAns = 1;
int ssfx0 = 0, ppref0 = 0;
for (int i = m - 1; i >= l; i--) {
curd = abs(v[i] - v[last]);
if (curd > L) {
curd = 0;
last = i + 1;
curAns++;
}
if (curAns == 1) ssfx0 = curd;
sfx[i] = curd;
sfxAns[i] = curAns;
}
curd = 0;
last = m;
curAns = 1;
for (int i = m; i < r; i++) {
curd = abs(v[i] - v[last]);
if (curd > L) {
curd = 0;
last = i - 1;
curAns++;
}
if (curAns == 1) ppref0 = curd;
pr[i] = curd;
prAns[i] = curAns;
}
for (int i = m - 1; i >= l; i--) {
while (!q[i].empty() && q[i].back().first >= m) {
int l = i, r = q[i].back().first, ind = q[i].back().second;
q[i].pop_back();
int anss = prAns[r] + sfxAns[l];
if ((prAns[r] > 1 ? ppref0 : pr[r]) + (sfxAns[l] > 1 ? ssfx0 : sfx[l]) + abs(v[m] - v[m - 1]) <= L) anss--;
ans[ind] = anss;
}
}
solve(l, m);
solve(m, r);
}
signed main () {
ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0);
int n = ni();
for (int i = 0; i < n; i++) v.push_back(ni());
L = ni();
int Q = ni();
for (int i = 0; i < Q; i++) {
int l, r;
cin >> l >> r;
l--; r--;
if (l > r) swap(l, r);
q[l].push_back({r, i});
}
for (int i = 0; i < n; i++) {
sort(all(q[i]));
}
solve(0, n);
for (int i = 0; i < Q; i++) {
cout << ans[i] << '\n';
}
}
return 0;
}
|
a.cc: In function 'int main()':
a.cc:42:14: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
42 | inline int ni() {int x; cin >> x; return x;}
| ^~
a.cc:42:14: note: remove parentheses to default-initialize a variable
42 | inline int ni() {int x; cin >> x; return x;}
| ^~
| --
a.cc:42:14: note: or replace parentheses with braces to value-initialize a variable
a.cc:42:17: error: a function-definition is not allowed here before '{' token
42 | inline int ni() {int x; cin >> x; return x;}
| ^
a.cc:43:1: error: a template declaration cannot appear at block scope
43 | template <class T>
| ^~~~~~~~
a.cc:46:1: error: a template declaration cannot appear at block scope
46 | template<typename T, typename ...TAIL>
| ^~~~~~~~
a.cc:49:1: error: a template declaration cannot appear at block scope
49 | template<typename T, typename ...TAIL>
| ^~~~~~~~
a.cc:69:26: error: a function-definition is not allowed here before '{' token
69 | void solve(int l, int r) {
| ^
a.cc:127:13: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
127 | signed main () {
| ^~
a.cc:127:13: note: remove parentheses to default-initialize a variable
127 | signed main () {
| ^~
| --
a.cc:127:13: note: or replace parentheses with braces to value-initialize a variable
a.cc:127:16: error: a function-definition is not allowed here before '{' token
127 | signed main () {
| ^
|
s758552578
|
p04015
|
C++
|
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <chrono>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <cctype>
# include <unordered_map>
# include <unordered_set>
//#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
//#pragma GCC optimization("unroll-loops, no-stack-protector")
//#pragma GCC target("avx,avx2,fma")
#define forn(i, n) for (int i = 0; i < (n); i++)
#define forx(i,x,n) for (int i = x; i < (n); i++)
#define form(i, n) for (int i = n-1; i>=0; i--)
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define pf push_front
#define mp make_pair
#define ll long long
#define ld long double
#define ull unsigned ll
#define srt(a) sort(a.begin(), a.end());
#define pll pair<ll, ll>
#define pii pair<int,int>
#define pld pair<ld,ld>
#define ar array
#define endl '\n';
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <class T> inline T gcd(T a, T b) { while (b) { a %= b; swap(a, b); } return a; }
template <class T> inline T lcm(T a, T b) { return a * b / gcd(a, b); }
const ll MAXN = 32005, K = 200043, M = 1000043, INF = 1e18 + 7;
// the good way to get PI number
const ld PI = acos(-1.0);
ll MOD = 1e9 + 7;
template <class T> T sqr(T a) {
return a * a;
}
ll mul(ll a, ll b) {
return ((a % MOD) * (b % MOD)) % MOD;
}
ll sum(ll a, ll b) {
return ((a % MOD) + (b % MOD)) % MOD;
}
ll sub(ll a, ll b) {
return sum(a, MOD - b);
}
ll bin_pow(ll a, ll n) {
ll res = 1;
while (n > 0) {
if (n & 1)
res = mul(res, a);
a = mul(a, a);
n >>= 1;
}
return res;
}
void solve() {
int n, A;
cin >> n >> A;
vi x(n), y, z;
for (int i = 0; i < n; ++i)
cin >> x[i];
int l = n / 2, r = n - n / 2;
for (int i = 0; i < l; ++i)
y.pb(x[i]);
for (int i = l; i < n; ++i)
z.pb(x[i]);
unordered_map <pii, int> m1, m2;
for (int i = 1; i < (1 << l); ++i) {
bitset<26> b(i);
int sum = 0;
for (int j = 0; j < l; ++j)
sum += b[j] * y[j];
m1[{sum, b.count()}]++;
}
for (int i = 1; i < (1 << r); ++i) {
bitset<26> b(i);
int sum = 0;
for (int j = 0; j < r; ++j)
sum += b[j] * z[j];
m2[{sum, b.count()}]++;
}
ll ans = 0;
for (auto it = m1.begin(); it != m1.end(); ++it) {
int sum = it->first.first, cnt = it->first.second;
ans += (sum == cnt * A) * it->second;
}
for (auto it = m2.begin(); it != m2.end(); ++it) {
int sum = it->first.first, cnt = it->first.second;
ans += (sum == cnt * A) * it->second;
}
for (auto it = m1.begin(); it != m1.end(); ++it) {
int sum = it->first.first, cnt = it->first.second;
for (int i = 1; i <= r; ++i)
ans += it->second * m2[{(cnt + i) * A - sum, i}];
}
cout << ans << endl;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t = 1;
// cin >> t;
while (t --> 0)
solve();
return 0;
}
|
a.cc: In function 'void solve()':
a.cc:111:30: error: use of deleted function 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<int, int>; _Tp = int; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]'
111 | unordered_map <pii, int> m1, m2;
| ^~
In file included from /usr/include/c++/14/unordered_map:41,
from /usr/include/c++/14/functional:63,
from a.cc:20:
/usr/include/c++/14/bits/unordered_map.h:148:7: note: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<int, int>; _Tp = int; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]' is implicitly deleted because the default definition would be ill-formed:
148 | unordered_map() = default;
| ^~~~~~~~~~~~~
/usr/include/c++/14/bits/unordered_map.h: At global scope:
/usr/include/c++/14/bits/unordered_map.h:148:7: error: use of deleted function 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]'
In file included from /usr/include/c++/14/bits/unordered_map.h:33:
/usr/include/c++/14/bits/hashtable.h:539:7: note: 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed:
539 | _Hashtable() = default;
| ^~~~~~~~~~
/usr/include/c++/14/bits/hashtable.h:539:7: error: use of deleted function 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]'
In file included from /usr/include/c++/14/bits/hashtable.h:35:
/usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed:
1731 | _Hashtable_base() = default;
| ^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]'
/usr/include/c++/14/bits/hashtable_policy.h: In instantiation of 'std::__detail::_Hashtable_ebo_helper<_Nm, _Tp, true>::_Hashtable_ebo_helper() [with int _Nm = 1; _Tp = std::hash<std::pair<int, int> >]':
/usr/include/c++/14/bits/hashtable_policy.h:1328:7: required from here
1328 | _Hash_code_base() = default;
| ^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/hashtable_policy.h:1245:49: error: use of deleted function 'std::hash<std::pair<int, int> >::hash()'
1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { }
| ^~~~~
In file included from /usr/include/c++/14/string_view:50,
from /usr/include/c++/14/bits/basic_string.h:47,
from /usr/include/c++/14/string:54,
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/functional_hash.h:102:12: note: 'std::hash<std::pair<int, int> >::hash()' is implicitly deleted because the default definition would be ill-formed:
102 | struct hash : __hash_enum<_Tp>
| ^~~~
/usr/include/c++/14/bits/functional_hash.h:102:12: error: no matching function for call to 'std::__hash_enum<std::pair<int, int>, false>::__hash_enum()'
/usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate: 'std::__hash_enum<_Tp, <anonymous> >::__hash_enum(std::__hash_enum<_Tp, <anonymous> >&&) [with _Tp = std::pair<int, int>; bool <anonymous> = false]'
83 | __hash_enum(__hash_enum&&);
| ^~~~~~~~~~~
/usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<int, int>; bool <anonymous> = false]' is private within this context
102 | struct hash : __hash_enum<_Tp>
| ^~~~
/usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here
84 | ~__hash_enum();
| ^
/usr/include/c++/14/bits/hashtable_policy.h:1245:49: note: use '-fdiagnostics-all-candidates' to display considered candidates
1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { }
| ^~~~~
/usr/include/c++/14/bits/hashtable_policy.h:1328:7: note: 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<int, int>; _Value = std::pair<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' is implicitly deleted because the default definition would be ill-formed:
1328 | _Hash_code_base() = default;
| ^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/hashtable_policy.h:1328:7: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()'
/usr/include/c++/14/bits/hashtable_policy.h:1242:12: note: 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' is implicitly deleted because the default definition would be ill-formed:
1242 | struct _Hashtable_ebo_helper<_Nm, _Tp, true>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/hashtable_policy.h:1242:12: error: use of deleted function 'std::hash<std::pair<int, int> >::~hash()'
/usr/include/c++/14/bits/functional_hash.h:102:12: note: 'std::hash<std::pair<int, int> >::~hash()' is implicitly deleted because the default definition would be ill-formed:
102 | struct hash : __hash_enum<_Tp>
| ^~~~
/usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<int, int>; bool <anonymous> = false]' is private within this context
/usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here
84 | ~__hash_enum();
| ^
/usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: use '-fdiagnostics-all-candidates' to display considered candidates
1731 | _Hashtable_base() = default;
| ^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::__detail::_Select1st, std::hash<std::pair<int, int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()'
/usr/include/c++/14/bits/hashtable_policy.h:1306:12: note: 'std::__detail::_Hash_code_base<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::__detail::_Select1st, std::hash<std::pair<int, int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()' is implicitly deleted because the default definition would be ill-formed:
1306 | struct _Hash_code_base
| ^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/hashtable_policy.h:1306:12: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()'
/usr/include/c++/14/bits/hashtable.h:539:7: note: use '-fdiagnostics-all-candidates' to display considered candidates
539 |
|
s658778707
|
p04015
|
Java
|
import java.io.*;
import java.util.*;
import java.util.Map.Entry;
import static java.lang.Math.min;
/**
* Created by Katushka on 11.03.2020.
*/
public class C {
public static final Comparator<int[]> COMPARATOR = Comparator.comparingInt(o -> o[0]);
static int[] readArray(int size, InputReader in) {
int[] a = new int[size];
for (int i = 0; i < size; i++) {
a[i] = in.nextInt();
}
return a;
}
static long[] readLongArray(int size, InputReader in) {
long[] a = new long[size];
for (int i = 0; i < size; i++) {
a[i] = in.nextLong();
}
return a;
}
static void sortArray(int[] a) {
Random random = new Random();
for (int i = 0; i < a.length; i++) {
int randomPos = random.nextInt(a.length);
int t = a[i];
a[i] = a[randomPos];
a[randomPos] = t;
}
Arrays.sort(a);
}
public static void main(String[] args) throws FileNotFoundException {
InputReader in = new InputReader(System.in);
PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
int n = in.nextInt();
long a = in.nextInt();
int[] xs = readArray(n, in);
Map<Integer, Integer> occs = new HashMap<>();
int max = 0;
for (int i = 0; i < n; i++) {
int x = xs[i];
max = Math.max(max, x);
occs.put(x, occs.getOrDefault(x, 0) + 1);
}
long[][] c = c(n + 1);
Map<Long, long[][]> dp = new HashMap<>();
for (Entry<Integer, Integer> entry : occs.entrySet()) {
int x = entry.getKey();
int xOccs = entry.getValue();
for (int j = 0; j < xOccs; j++) {
long key = ((long) x) * (j + 1);
if (!dp.containsKey(key)) {
dp.put(key, new long[n + 1][max + 1]);
}
dp.get(key)[j + 1][x] += c[xOccs][j + 1];
}
}
for (Entry<Integer, Integer> entry : occs.entrySet()) {
int x = entry.getKey();
int xOccs = entry.getValue();
Map<Long, Map<Integer, Map<Integer, Long>>> updates = new HashMap<>();
for (Long sum : dp.keySet()) {
for (int k = 1; k < n; k++) {
for (int t = 1; t < x; t++) {
for (int j = 0; j < xOccs && j + 1 + k <= n; j++) {
if (dp.get(sum)[k][t] == 0) {
continue;
}
long key = ((long) x) * (j + 1) + sum;
if (!updates.containsKey(key)) {
updates.put(key, new HashMap<>());
}
if (!updates.get(key).containsKey(j + 1 + k)) {
updates.get(key).put(j + 1 + k, new HashMap<>());
}
updates.get(key).get(j + 1 + k).put(x, updates.get(key).get(j + 1 + k).getOrDefault(x, 0L) + c[xOccs][j + 1] * dp.get(sum)[k][t]);
}
}
}
}
for (Long sum : updates.keySet()) {
if (!dp.containsKey(sum)) {
dp.put(sum, new long[n + 1][max + 1]);
}
Map<Integer, Map<Integer, Long>> ktUpdates = updates.get(sum);
for (Integer k : ktUpdates.keySet()) {
Map<Integer, Long> tUpdates = ktUpdates.get(k);
for (Integer t : tUpdates.keySet()) {
dp.get(sum)[k][t] += tUpdates.get(t);
}
}
}
}
long ans = 0;
for (int i = 1; i <= n; i++) {
if (dp.containsKey(a * i)) {
for (int j = 0; j < dp.get(a * i)[i].length; j++) {
ans += dp.get(a * i)[i][j];
}
}
}
out.println(ans);
out.close();
}
static long[][] c(int n) {
long[][] res = new long[n + 1][n + 1];
for (int i = 0; i < n + 1; i++) {
for (int j = 0; j <= i; j++) {
if (i == 0 || j == 0) {
res[i][j] = 1;
} else {
res[i][j] = res[i - 1][j] + res[i - 1][j - 1];
}
}
}
return res;
}
private static long getLessThan(int[] yBits, int ind, int k, long[][] c) {
if (k == 0) {
return 1;
}
if (ind == -1 || k > ind) {
return 0;
}
if (yBits[ind] == 0) {
return getLessThan(yBits, ind - 1, k, c);
} else if (yBits[ind] == 1) {
return c[ind][k] + getLessThan(yBits, ind - 1, k - 1, c);
} else {
return c[ind][k - 1] + c[ind][k];
}
}
private static long getGreaterThan(int[] xBits, int ind, int k, long[][] c) {
if (k == 0) {
while (ind >= 0) {
if (xBits[ind] >= 1) {
return 0;
}
ind--;
}
return 1;
}
if (ind == -1 || k > ind + 1) {
return 0;
}
if (xBits[ind] == 0) {
if (ind == 0) {
return 1;
}
return c[ind][k - 1] + getGreaterThan(xBits, ind - 1, k, c);
} else if (xBits[ind] == 1) {
return getGreaterThan(xBits, ind - 1, k - 1, c);
}
return 0;
}
private static int[] numToBits(long x, int k) {
int[] res = new int[40];
int i = 0;
while (x > 0) {
res[i] = ((int) (x % k));
i++;
x /= k;
}
return res;
}
private static void outputArray(long[] ans, PrintWriter out) {
StringBuilder str = new StringBuilder();
for (long an : ans) {
str.append(an).append(" ");
}
out.println(str);
}
private static class InputReader {
public BufferedReader reader;
public StringTokenizer tokenizer;
public InputReader(InputStream stream) {
reader = new BufferedReader(new InputStreamReader(stream), 32768);
tokenizer = null;
}
public String next() {
while (tokenizer == null || !tokenizer.hasMoreTokens()) {
createTokenizer();
}
return tokenizer.nextToken();
}
private void createTokenizer() {
try {
tokenizer = new StringTokenizer(reader.readLine());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public String nextString() {
try {
return reader.readLine();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public int nextInt() {
return Integer.parseInt(next());
}
public long nextLong() {
return Long.parseLong(next());
}
public char nextChar() {
return next().charAt(0);
}
public int[] nextInts() {
if (tokenizer == null || !tokenizer.hasMoreTokens()) {
createTokenizer();
}
List<Integer> res = new ArrayList<>();
while (tokenizer.hasMoreElements()) {
res.add(Integer.parseInt(tokenizer.nextToken()));
}
int[] resArray = new int[res.size()];
for (int i = 0; i < res.size(); i++) {
resArray[i] = res.get(i);
}
return resArray;
}
}
}
|
Main.java:11: error: class C is public, should be declared in a file named C.java
public class C {
^
1 error
|
s113486198
|
p04015
|
C++
|
#include<bits/stdc++.h>
using namespace std;
int main () {
int N, A;
cin >> N >> A;
vector<int>X(N);
for (int i = 0; i < N; i ++) {
cin >> X[i];
X[i] -= A;
}
vector<int>pl;
vector<int>mn;
long long zr = 1;
for (int i = 0; i < N; i ++) {
if (!(X[i])) zr *= 2;
if (X[i] > 0) pl.push_back(X[i]);
if (X[i] < 0) mn.push_back(-X[i]);
}
vector<long long>dp(2505, 0);
vector<long long>dp_(2505, 0);
dp[0] = 1;
dp_[0] = 1;
int si = (int)de.size();
int si_ = (int)de_.size();
for (int i = 0; i < si; i ++) {
for (int j = 2504; j >= 0; j --) {
if (j >= pl[i]) {
dp[j] += dp[j - pl[i]];
}
}
}
for (int i = 0; i < si_; i ++) {
for (int j = 2504; j >= 0; j --) {
if (j >= mn[i]) {
dp_[j] += dp_[j - mn[i]];
}
}
}
long long ans = 0;
for (int i = 0; i < 2505; i ++) {
ans += dp[i] * dp_[i];
}
cout << ans * zr << endl;
}
|
a.cc: In function 'int main()':
a.cc:23:17: error: 'de' was not declared in this scope; did you mean 'dp'?
23 | int si = (int)de.size();
| ^~
| dp
a.cc:24:18: error: 'de_' was not declared in this scope; did you mean 'dp_'?
24 | int si_ = (int)de_.size();
| ^~~
| dp_
|
s692854550
|
p04015
|
C++
|
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
const int MOD = 1000000007;
const int INF = 1000000000; //1e9
const int NIL = -1;
const long long LINF = 1000000000000000000; // 1e18
const long double EPS = 1E-10;
template<class T, class S> inline bool chmax(T &a, const S &b){
if(a < b){
a = b; return true;
}
return false;
}
template<class T, class S> inline bool chmin(T &a, const S &b){
if(b < a){
a = b; return true;
}
return false;
}
int main(){
int N, A, mx; std::cin >> N >> A;
mx = A;
std::vector<int> x(N);
for(int i(0); i < N; ++i){
std::cin >> x[i];
chmax(mx, x);
}
//dp[i][j][k]: x[0],..,x[i-1]からj枚で和がk
std::vector<std::vector<std::vector<long long>>> dp(N+1,
std::vector<std::vector<long long>>(N+1,
std::vector<long long>(N*mx + 1, 0)));
dp[0][0][0] = 1;
for(int i(1); i <= N; ++i){
for(int j(0); j <= N; ++j){
for(int k(0), k_len(N*mx); k <= k_len; ++k){
dp[i][j][k] = dp[i-1][j][k];
if(j && k >= x[i-1])
dp[i][j][k] += dp[i-1][j-1][k - x[i-1]];
}
}
}
long long ans(0);
for(int i(1); i <= N; ++i){
ans += dp[N][i][A*i];
}
std::cout << ans << std::endl;
return 0;
}
|
a.cc: In instantiation of 'bool chmax(T&, const S&) [with T = int; S = std::vector<int>]':
a.cc:65:14: required from here
65 | chmax(mx, x);
| ~~~~~^~~~~~~
a.cc:42:10: error: no match for 'operator<' (operand types are 'int' and 'const std::vector<int>')
42 | if(a < b){
| ~~^~~
In file included from /usr/include/c++/14/regex:68,
from a.cc:24:
/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:42:10: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int'
42 | if(a < b){
| ~~^~~
/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:42:10: note: mismatched types 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>' and 'int'
42 | if(a < b){
| ~~^~~
/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:42:10: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int'
42 | if(a < b){
| ~~^~~
/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:42:10: note: 'const std::vector<int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
42 | if(a < b){
| ~~^~~
/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:42:10: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int'
42 | if(a < b){
| ~~^~~
/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:42:10: note: 'const std::vector<int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
42 | if(a < b){
| ~~^~~
/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:42:10: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int'
42 | if(a < b){
| ~~^~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/algorithm:60,
from a.cc:2:
/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:42:10: note: mismatched types 'const std::pair<_T1, _T2>' and 'int'
42 | if(a < b){
| ~~^~~
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:42:10: note: mismatched types 'const std::reverse_iterator<_Iterator>' and 'int'
42 | if(a < b){
| ~~^~~
/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:42:10: note: mismatched types 'const std::reverse_iterator<_Iterator>' and 'int'
42 | if(a < b){
| ~~^~~
/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:42:10: note: mismatched types 'const std::move_iterator<_IteratorL>' and 'int'
42 | if(a < b){
| ~~^~~
/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:42:10: note: mismatched types 'const std::move_iterator<_IteratorL>' and 'int'
42 | if(a < b){
| ~~^~~
In file included from a.cc:3:
/usr/include/c++/14/array:339:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> bool std::operator<(const array<_Tp, _Nm>&, const array<_Tp, _Nm>&)'
339 | operator<(const array<_Tp, _Nm>& __a, const array<_Tp, _Nm>& __b)
| ^~~~~~~~
/usr/include/c++/14/array:339:5: note: template argument deduction/substitution failed:
a.cc:42:10: note: mismatched types 'const std::array<_Tp, _Nm>' and 'int'
42 | if(a < b){
| ~~^~~
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 a.cc:4:
/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:42:10: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'int'
42 | if(a < b){
| ~~^~~
/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:42:10: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'int'
42 | if(a < b){
| ~~^~~
/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:42:10: note: 'std::vector<int>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
42 | if(a < b){
| ~~^~~
/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:42:10: note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'int'
42 | if(a < b){
| ~~^~~
/usr/include/c++/14/bits/basic_string.h:3888:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)'
3888 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3888:5: note: template argume
|
s337025893
|
p04015
|
C++
|
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
signed main(){
ll N,A,i,j,k;cin>>N>>A;ll X[N],DP[N+1][4901];
REP(i,N){cin>>X[i];X[i]-=A;}
REP(i,4901)DP[0][i]=0;DP[0][2450]=1;
FOR(i,1,N+1)REP(j,2450)if(j-A[i-1]>=0&&j-A[i-1]<=4900)DP[i][j]=DP[i][j-A[i-1]]+1;
cout<<DP[N][2450]-1<<endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:14:32: error: invalid types 'll {aka long long int}[ll {aka long long int}]' for array subscript
14 | FOR(i,1,N+1)REP(j,2450)if(j-A[i-1]>=0&&j-A[i-1]<=4900)DP[i][j]=DP[i][j-A[i-1]]+1;
| ^
a.cc:14:45: error: invalid types 'll {aka long long int}[ll {aka long long int}]' for array subscript
14 | FOR(i,1,N+1)REP(j,2450)if(j-A[i-1]>=0&&j-A[i-1]<=4900)DP[i][j]=DP[i][j-A[i-1]]+1;
| ^
a.cc:14:75: error: invalid types 'll {aka long long int}[ll {aka long long int}]' for array subscript
14 | FOR(i,1,N+1)REP(j,2450)if(j-A[i-1]>=0&&j-A[i-1]<=4900)DP[i][j]=DP[i][j-A[i-1]]+1;
| ^
|
s469609354
|
p04015
|
C++
|
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
typedef long long ll
//部分点解法
int main(){
int n,a;
cin >> n >> a;
vector<int> x(n);
rep(i,n){
cin >> x[i];
}
ll ans = 0;
rep(bit, 1<<n){
if(bit == 0) continue;
ll sum = 0;
ll count = 0;
rep(i,n){
if(bit & (1<<i)){
sum += x[i];
count++;
}
}
if(a*count == sum) {
ans++;
}
}
cout << ans << endl;
return 0;
}
|
a.cc:9:1: error: expected initializer before 'int'
9 | int main(){
| ^~~
|
s378178528
|
p04015
|
C++
|
afae
|
a.cc:1:1: error: 'afae' does not name a type
1 | afae
| ^~~~
|
s079296192
|
p04015
|
Java
|
import lib.FastScanner;
public class Main {
public static void main(String[] args) {
FastScanner fsc = new FastScanner();
int n = fsc.nextInt();
int a = fsc.nextInt();
int[] x = new int[n];
for (int i = 0; i < n; i++) {
x[i] = fsc.nextInt() - a;
}
long[][] dp = new long[n][5010];
int inflation = 2505;
dp[0][0 + inflation] = 1;
dp[0][x[0] + inflation] += 1;
for (int i = 1; i < n; i++) {
for (int j = 0; j < 5010; j++) {
if (dp[i - 1][j] > 0) {
dp[i][j] += dp[i - 1][j];
dp[i][j + x[i]] += dp[i - 1][j];
}
}
}
System.out.println(dp[n - 1][0 + inflation] - 1);
}
}
|
Main.java:2: error: package lib does not exist
import lib.FastScanner;
^
Main.java:6: error: cannot find symbol
FastScanner fsc = new FastScanner();
^
symbol: class FastScanner
location: class Main
Main.java:6: error: cannot find symbol
FastScanner fsc = new FastScanner();
^
symbol: class FastScanner
location: class Main
3 errors
|
s031001410
|
p04015
|
C++
|
fun main(args: Array<String>) {
val (n, a) = readLine()!!.split(" ").map(String::toInt)
var dp = Array(n+1, {Array(a*n+1, {0.toLong()})})
var dp_copy = Array(n+1, {Array(a*n+1, {0.toLong()})})
val x = readLine()!!.split(" ").map(String::toInt)
dp[0][0] = 1.toLong()
dp_copy[0][0] = 1.toLong()
for(i in 1..n){
for(j in 0..n-1){
for(k in 0..n*a-x[i-1]){
dp_copy[j+1][k+x[i-1]] += dp[j][k]
}
}
for(j in 0..n){
for(k in 0..n*a){
dp[j][k] = dp_copy[j][k]
}
}
}
var ans = 0.toLong()
for(i in 1..n) ans += dp[i][i*a]
println(ans)
}
|
a.cc:8:14: error: too many decimal points in number
8 | for(i in 1..n){
| ^~~~
a.cc:9:18: error: too many decimal points in number
9 | for(j in 0..n-1){
| ^~~~
a.cc:10:22: error: too many decimal points in number
10 | for(k in 0..n*a-x[i-1]){
| ^~~~
a.cc:14:18: error: too many decimal points in number
14 | for(j in 0..n){
| ^~~~
a.cc:15:22: error: too many decimal points in number
15 | for(k in 0..n*a){
| ^~~~
a.cc:21:14: error: too many decimal points in number
21 | for(i in 1..n) ans += dp[i][i*a]
| ^~~~
a.cc:1:1: error: 'fun' does not name a type
1 | fun main(args: Array<String>) {
| ^~~
|
s852732026
|
p04015
|
C++
|
#include <string>
#include <map>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Rep(i, sta, n) for (int i = sta; i < n; ++i)
using namespace std;
typedef long long ll;
const int mod = 1000000007;
ll dp[55][55][2555];
int main() {
int N, A;
cin >> N >> A;
vector<int> x(N);
rep(i, N) cin >> x[i];
int sum = 0;
rep(i, N) sum += x[i];
dp[0][0][0] = 1;
rep(j, N+1) {
rep(k, N+1) {
rep(l, sum+1) {
if (j>=1 && k>=0 && l<x[j-1]) {
dp[j][k][l] = dp[j-1][k][l];
}
else if (j>=1 && k>=1 && l>=x[j-1]) {
dp[j][k][l] = dp[j-1][k][l] + dp[j-1][k-1][l-x[j-1]];
}
else if (j==0 && k==0 && l==0) dp[j][k][l] = 1;
else dp[j][k][l] = 0;
}
}
}
ll ans = 0;
for (int k=1; A*k<=sum; k++) {
ans += dp[N][k][A*k];
}
cout << ans << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:15:5: error: 'cin' was not declared in this scope
15 | cin >> N >> A;
| ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
2 | #include <map>
+++ |+#include <iostream>
3 |
a.cc:16:5: error: 'vector' was not declared in this scope
16 | vector<int> x(N);
| ^~~~~~
a.cc:3:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
2 | #include <map>
+++ |+#include <vector>
3 |
a.cc:16:12: error: expected primary-expression before 'int'
16 | vector<int> x(N);
| ^~~
a.cc:17:22: error: 'x' was not declared in this scope
17 | rep(i, N) cin >> x[i];
| ^
a.cc:19:22: error: 'x' was not declared in this scope
19 | rep(i, N) sum += x[i];
| ^
a.cc:26:39: error: 'x' was not declared in this scope
26 | if (j>=1 && k>=0 && l<x[j-1]) {
| ^
a.cc:43:5: error: 'cout' was not declared in this scope
43 | cout << ans << endl;
| ^~~~
a.cc:43:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:43:20: error: 'endl' was not declared in this scope
43 | cout << ans << endl;
| ^~~~
a.cc:3:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
2 | #include <map>
+++ |+#include <ostream>
3 |
|
s428532527
|
p04015
|
C++
|
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
int main(){
//input
ll N,A; cin>>N>>A;
vector<ll> X(N+1);
rep1(i,N) cin>>X[i];
ll dp[51][51][2501]; //dp[x][y][z]:x番目までy個選び和をzにする
rep1(i,50)rep1(j,50)rep(k,2501) dp[i][j][k]=0;
dp[1][0][0]=1;
dp[1][1][X[1]]=1;
FOR(i,2,51){
rep(j,i+1){
rep(k,2501){
if(j!=0 && k>=X[i]) dp[i][j][k]+=dp[i-1][j-1][k-X[i]];
dp[i][j][k]+=dp[i-1][j][k];
}
}
}
ll ans=0;
rep1(i,50){
if(i*A<=2500) ans+=dp[N][i][i*A];
}
cout<<ans;
}
|
a.cc: In function 'int main()':
a.cc:10:9: error: 'll' was not declared in this scope; did you mean 'all'?
10 | ll N,A; cin>>N>>A;
| ^~
| all
a.cc:10:17: error: 'cin' was not declared in this scope
10 | ll N,A; cin>>N>>A;
| ^~~
a.cc:10:22: error: 'N' was not declared in this scope
10 | ll N,A; cin>>N>>A;
| ^
a.cc:10:25: error: 'A' was not declared in this scope
10 | ll N,A; cin>>N>>A;
| ^
a.cc:11:9: error: 'vector' was not declared in this scope
11 | vector<ll> X(N+1);
| ^~~~~~
a.cc:11:20: error: 'X' was not declared in this scope
11 | vector<ll> X(N+1);
| ^
a.cc:12:14: error: expected ';' before 'i'
12 | rep1(i,N) cin>>X[i];
| ^
a.cc:5:26: note: in definition of macro 'rep1'
5 | #define rep1(i,n) for(ll i=1;i<=(n);i++)
| ^
a.cc:12:14: error: 'i' was not declared in this scope
12 | rep1(i,N) cin>>X[i];
| ^
a.cc:5:30: note: in definition of macro 'rep1'
5 | #define rep1(i,n) for(ll i=1;i<=(n);i++)
| ^
a.cc:14:11: error: expected ';' before 'dp'
14 | ll dp[51][51][2501]; //dp[x][y][z]:x番目までy個選び和をzにする
| ^~~
| ;
a.cc:16:14: error: expected ';' before 'i'
16 | rep1(i,50)rep1(j,50)rep(k,2501) dp[i][j][k]=0;
| ^
a.cc:5:26: note: in definition of macro 'rep1'
5 | #define rep1(i,n) for(ll i=1;i<=(n);i++)
| ^
a.cc:16:14: error: 'i' was not declared in this scope
16 | rep1(i,50)rep1(j,50)rep(k,2501) dp[i][j][k]=0;
| ^
a.cc:5:30: note: in definition of macro 'rep1'
5 | #define rep1(i,n) for(ll i=1;i<=(n);i++)
| ^
a.cc:16:24: error: expected ';' before 'j'
16 | rep1(i,50)rep1(j,50)rep(k,2501) dp[i][j][k]=0;
| ^
a.cc:5:26: note: in definition of macro 'rep1'
5 | #define rep1(i,n) for(ll i=1;i<=(n);i++)
| ^
a.cc:16:24: error: 'j' was not declared in this scope
16 | rep1(i,50)rep1(j,50)rep(k,2501) dp[i][j][k]=0;
| ^
a.cc:5:30: note: in definition of macro 'rep1'
5 | #define rep1(i,n) for(ll i=1;i<=(n);i++)
| ^
a.cc:16:33: error: expected ';' before 'k'
16 | rep1(i,50)rep1(j,50)rep(k,2501) dp[i][j][k]=0;
| ^
a.cc:4:25: note: in definition of macro 'rep'
4 | #define rep(i,n) for(ll i=0;i<(n);i++)
| ^
a.cc:16:33: error: 'k' was not declared in this scope
16 | rep1(i,50)rep1(j,50)rep(k,2501) dp[i][j][k]=0;
| ^
a.cc:4:29: note: in definition of macro 'rep'
4 | #define rep(i,n) for(ll i=0;i<(n);i++)
| ^
a.cc:16:41: error: 'dp' was not declared in this scope
16 | rep1(i,50)rep1(j,50)rep(k,2501) dp[i][j][k]=0;
| ^~
a.cc:17:9: error: 'dp' was not declared in this scope
17 | dp[1][0][0]=1;
| ^~
a.cc:20:13: error: expected ';' before 'i'
20 | FOR(i,2,51){
| ^
a.cc:6:27: note: in definition of macro 'FOR'
6 | #define FOR(i,a,b) for(ll i=(a);i<(b);i++)
| ^
a.cc:20:13: error: 'i' was not declared in this scope
20 | FOR(i,2,51){
| ^
a.cc:6:33: note: in definition of macro 'FOR'
6 | #define FOR(i,a,b) for(ll i=(a);i<(b);i++)
| ^
a.cc:21:21: error: expected ';' before 'j'
21 | rep(j,i+1){
| ^
a.cc:4:25: note: in definition of macro 'rep'
4 | #define rep(i,n) for(ll i=0;i<(n);i++)
| ^
a.cc:21:21: error: 'j' was not declared in this scope
21 | rep(j,i+1){
| ^
a.cc:4:29: note: in definition of macro 'rep'
4 | #define rep(i,n) for(ll i=0;i<(n);i++)
| ^
a.cc:22:29: error: expected ';' before 'k'
22 | rep(k,2501){
| ^
a.cc:4:25: note: in definition of macro 'rep'
4 | #define rep(i,n) for(ll i=0;i<(n);i++)
| ^
a.cc:22:29: error: 'k' was not declared in this scope
22 | rep(k,2501){
| ^
a.cc:4:29: note: in definition of macro 'rep'
4 | #define rep(i,n) for(ll i=0;i<(n);i++)
| ^
a.cc:29:11: error: expected ';' before 'ans'
29 | ll ans=0;
| ^~~~
| ;
a.cc:30:14: error: expected ';' before 'i'
30 | rep1(i,50){
| ^
a.cc:5:26: note: in definition of macro 'rep1'
5 | #define rep1(i,n) for(ll i=1;i<=(n);i++)
| ^
a.cc:30:14: error: 'i' was not declared in this scope
30 | rep1(i,50){
| ^
a.cc:5:30: note: in definition of macro 'rep1'
5 | #define rep1(i,n) for(ll i=1;i<=(n);i++)
| ^
a.cc:31:31: error: 'ans' was not declared in this scope
31 | if(i*A<=2500) ans+=dp[N][i][i*A];
| ^~~
a.cc:34:9: error: 'cout' was not declared in this scope
34 | cout<<ans;
| ^~~~
a.cc:34:15: error: 'ans' was not declared in this scope
34 | cout<<ans;
| ^~~
|
s304267060
|
p04015
|
C++
|
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
int main() {
int N, A;
cin >> N >> A;
vector<int> x(N);
rep(i, 0, N) cin >> x[i], x[i] -= A;
vector<vector<long long>> dp(N + 1, vector<long long>(5555));
int g = 2500;
dp[0][g] = 1;
rep(i, 0, N) rep(j, -g, g) {
dp[i + 1][j + g] += dp[i][j + g];
dp[i + 1][j + g + x[i]] += dp[i][j + g];
}
cout << dp[N][g] - 1 << endl;
return 0;
}
a
|
a.cc:20:1: error: 'a' does not name a type
20 | a
| ^
|
s881241251
|
p04015
|
C++
|
#include<iostream>
using namespace std;
long dp[55][55][600];
main(){
int n,v;
cin>>n>>v;
ll x[n];
for(int i=0;i<n;++i)cin>>x[i];
dp[0][0][0]=1;
for(int i=0;i<n;++i){
for(int j=0;j<i;++j){
for(int k=0;k<550;++k){
dp[i+1][j][k]+=dp[i][j][k];
dp[i+1][j+1][k+x[i]]+=dp[i][j][k];
}
}
}
long ans=0;
for(int i=0;i<n;++i)
ans+=dp[n][i][i*v];
cout<<ans<<endl;
}
|
a.cc:4:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
4 | main(){
| ^~~~
a.cc: In function 'int main()':
a.cc:7:3: error: 'll' was not declared in this scope
7 | ll x[n];
| ^~
a.cc:8:28: error: 'x' was not declared in this scope
8 | for(int i=0;i<n;++i)cin>>x[i];
| ^
a.cc:15:24: error: 'x' was not declared in this scope
15 | dp[i+1][j+1][k+x[i]]+=dp[i][j][k];
| ^
|
s461069482
|
p04015
|
C++
|
#include <bits/stdc++.h>
using namespace std;
long long n,k,a[555];
map<long long,long long> f[555][2555];
int main()
{
cin >> n >> k;
for(int i=1; i<=n; i++)
{
cin >> a[i];
a[i]-=k;
}
for(int i=1; i<=n; i++)
{
long long v=a[i];
for(int j=-1000; j<=1000; j++)
f[i][j]+=f[i-1][j-v];
for(int j=-1000; j<=1000; j++)
f[i][j]+=f[i-1][j];
f[i][v]++;
}
cout << f[n][0];
}
|
a.cc: In function 'int main()':
a.cc:19:20: error: no match for 'operator+=' (operand types are 'std::map<long long int, long long int>' and 'std::map<long long int, long long int>')
19 | f[i][j]+=f[i-1][j-v];
| ~~~~~~~^~~~~~~~~~~~~
a.cc:21:20: error: no match for 'operator+=' (operand types are 'std::map<long long int, long long int>' and 'std::map<long long int, long long int>')
21 | f[i][j]+=f[i-1][j];
| ~~~~~~~^~~~~~~~~~~
a.cc:22:16: error: no 'operator++(int)' declared for postfix '++' [-fpermissive]
22 | f[i][v]++;
| ~~~~~~~^~
a.cc:24:10: error: no match for 'operator<<' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and 'std::map<long long int, long long int>')
24 | cout << f[n][0];
| ~~~~ ^~ ~~~~~~~
| | |
| | std::map<long long int, long long int>
| std::ostream {aka std::basic_ostream<char>}
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,
from a.cc:1:
/usr/include/c++/14/ostream:116:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ostream_type& (*)(__ostream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
116 | operator<<(__ostream_type& (*__pf)(__ostream_type&))
| ^~~~~~~~
/usr/include/c++/14/ostream:116:36: note: no known conversion for argument 1 from 'std::map<long long int, long long int>' to 'std::basic_ostream<char>::__ostream_type& (*)(std::basic_ostream<char>::__ostream_type&)' {aka 'std::basic_ostream<char>& (*)(std::basic_ostream<char>&)'}
116 | operator<<(__ostream_type& (*__pf)(__ostream_type&))
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:125:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; __ios_type = std::basic_ios<char>]'
125 | operator<<(__ios_type& (*__pf)(__ios_type&))
| ^~~~~~~~
/usr/include/c++/14/ostream:125:32: note: no known conversion for argument 1 from 'std::map<long long int, long long int>' to 'std::basic_ostream<char>::__ios_type& (*)(std::basic_ostream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'}
125 | operator<<(__ios_type& (*__pf)(__ios_type&))
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:135:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
135 | operator<<(ios_base& (*__pf) (ios_base&))
| ^~~~~~~~
/usr/include/c++/14/ostream:135:30: note: no known conversion for argument 1 from 'std::map<long long int, long long int>' to 'std::ios_base& (*)(std::ios_base&)'
135 | operator<<(ios_base& (*__pf) (ios_base&))
| ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:174:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
174 | operator<<(long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:174:23: note: no known conversion for argument 1 from 'std::map<long long int, long long int>' to 'long int'
174 | operator<<(long __n)
| ~~~~~^~~
/usr/include/c++/14/ostream:178:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
178 | operator<<(unsigned long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:178:32: note: no known conversion for argument 1 from 'std::map<long long int, long long int>' to 'long unsigned int'
178 | operator<<(unsigned long __n)
| ~~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:182:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
182 | operator<<(bool __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:182:23: note: no known conversion for argument 1 from 'std::map<long long int, long long int>' to 'bool'
182 | operator<<(bool __n)
| ~~~~~^~~
In file included from /usr/include/c++/14/ostream:1022:
/usr/include/c++/14/bits/ostream.tcc:96:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char; _Traits = std::char_traits<char>]'
96 | basic_ostream<_CharT, _Traits>::
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/ostream.tcc:97:22: note: no known conversion for argument 1 from 'std::map<long long int, long long int>' to 'short int'
97 | operator<<(short __n)
| ~~~~~~^~~
/usr/include/c++/14/ostream:189:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
189 | operator<<(unsigned short __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:189:33: note: no known conversion for argument 1 from 'std::map<long long int, long long int>' to 'short unsigned int'
189 | operator<<(unsigned short __n)
| ~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/ostream.tcc:110:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char; _Traits = std::char_traits<char>]'
110 | basic_ostream<_CharT, _Traits>::
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/ostream.tcc:111:20: note: no known conversion for argument 1 from 'std::map<long long int, long long int>' to 'int'
111 | operator<<(int __n)
| ~~~~^~~
/usr/include/c++/14/ostream:200:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
200 | operator<<(unsigned int __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:200:31: note: no known conversion for argument 1 from 'std::map<long long int, long long int>' to 'unsigned int'
200 | operator<<(unsigned int __n)
| ~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:211:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
211 | operator<<(long long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:211:28: note: no known conversion for argument 1 from 'std::map<long long int, long long int>' to 'long long int'
211 | operator<<(long long __n)
| ~~~~~~~~~~^~~
/usr/include/c++/14/ostream:215:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
215 | operator<<(unsigned long long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:215:37: note: no known conversion for argument 1 from 'std::map<long long int, long long int>' to 'long long unsigned int'
215 | operator<<(unsigned long long __n)
| ~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:231:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
231 | operator<<(double __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:231:25: note: no known conversion for argument 1 from 'std::map<long long int, long long int>' to 'double'
231 | operator<<(double __f)
| ~~~~~~~^~~
/usr/include/c++/14/ostream:235:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
235 | operator<<(float __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:235:24: note: no known conversion for argument 1 from 'std::map<long long int, long long int>' to 'float'
235 | operator<<(float __f)
| ~~~~~~^~~
/usr/include/c++/14/ostream:243:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
243 | operator<<(long double __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:243:30: note: no known conversion for argument 1 from 'std::map<long long int, long long int>' to 'long double'
243 | operator<<(long double __f)
| ~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:301:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::_
|
s232692297
|
p04015
|
C++
|
#include <bits/stdc++.h>
#define reps(i,a,b) for(long long int i=a;i<b;i++)
#define rep(i,a) for(long long int i=0;i<a;i++)
typedef long long int ll;
using namespace std;
ll MOD = 1000000007;
ll dp[55][55][200000];
int N,A;
int x[50];
const int MAX = 510000;
struct aaa{
aaa(){
cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
};
}aaaaaaa;
//再帰関数、下の方を先に計算させる感覚
ll dpp(int basho,int maisu,int gouke){
if(basho>=N){
if(gouke==maisu*A && maisu!=0){
return 1;//一番下では1(?)
}
else{
return 0;
}
}
if (dp[basho][maisu][gouke] != -1){
return dp[basho][maisu][gouke];
}
int yes = dpp(basho+1,maisu+1,gouke+x[basho]);
int no = dpp(basho+1,maisu,gouke);
dp[basho][maisu][gouke]= yes+no;
return dp[basho][maisu][gouke];
}
int main(){
cin>>N>>A;
rep(i,N){
cin>>x[i];
}
memset(dp, -1, sizeof(dp));//初期化
cout<<dpp(0,0,0)<<endl;
return 0;
}
|
/tmp/cc66Mgtk.o: in function `dpp(int, int, int)':
a.cc:(.text+0x13): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cc66Mgtk.o
a.cc:(.text+0x1e): relocation truncated to fit: R_X86_64_PC32 against symbol `A' defined in .bss section in /tmp/cc66Mgtk.o
a.cc:(.text+0xd0): relocation truncated to fit: R_X86_64_PC32 against symbol `x' defined in .bss section in /tmp/cc66Mgtk.o
/tmp/cc66Mgtk.o: in function `main':
a.cc:(.text+0x194): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cc66Mgtk.o
a.cc:(.text+0x1b0): relocation truncated to fit: R_X86_64_PC32 against symbol `A' defined in .bss section in /tmp/cc66Mgtk.o
a.cc:(.text+0x1d8): relocation truncated to fit: R_X86_64_PC32 against symbol `x' defined in .bss section in /tmp/cc66Mgtk.o
a.cc:(.text+0x1f8): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cc66Mgtk.o
/tmp/cc66Mgtk.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0x26b): relocation truncated to fit: R_X86_64_PC32 against symbol `aaaaaaa' defined in .bss section in /tmp/cc66Mgtk.o
collect2: error: ld returned 1 exit status
|
s314070772
|
p04015
|
C++
|
s
|
a.cc:1:1: error: 's' does not name a type
1 | s
| ^
|
s444392492
|
p04015
|
C++
|
s
|
a.cc:1:1: error: 's' does not name a type
1 | s
| ^
|
s298236543
|
p04015
|
C++
|
#include<bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f3f3f3f3fLL
#define rep(i,a,b) for(register ll i=(a);i<=(b);i++)
#define dep(i,a,b) for(register ll i=(a);i>=(b);i--)
using namespace std;
const int maxn=50+5;
const int maxm=5000+5;
//const double pi=acos(-1.0);
//const double eps=1e-9;
const ll mo=1e9+7;
int n,m,k;
int a[maxn];
int ans,tmp,cnt;
ll dp[maxn][2510];
char s[maxn];
ll power(ll a,ll n)
{
ll sum=1;
while(n)
{
if(n&1) sum=sum*a%mo;
n>>=1;
a=a*a%mo;
}
return sum;
}
int main()
{
while(scanf("%d%d",&n,&m)!=EOF)
{
int sum=0;
rep(i,1,n)
{
scanf("%d",&a[i]);
sum+=a[i];
}
memset(dp,-1,sizeof(dp));
dp[0][0]=1;
rep(i,1,n)
{
dep(k,i-1,0)
dep(j,sum,a[i])
if(dp[k][j-a[i]]!=-1){
dp[k+1][j]=max(dp[k+1][j],0);
dp[k+1][j]+=dp[k][j-a[i]];
//if(j==18)
//cout<<k<<" * "<<i<<" "<<dp[k][j-a[i]]<<endl;
}
}
//rep(i,1,n)
//rep(j,0,sum)
//cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
ll ans=0;
rep(i,1,n)
if(i*m<=sum&&dp[i][i*m]>0){
ans+=dp[i][i*m];
//cout<<i<<" "<<i*m<<" "<<dp[i][i*m]<<endl;
}
printf("%lld\n",ans);
}
return 0;
}
|
a.cc: In function 'int main()':
a.cc:33:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
33 | rep(i,1,n)
| ^
a.cc:4:36: note: in definition of macro 'rep'
4 | #define rep(i,a,b) for(register ll i=(a);i<=(b);i++)
| ^
a.cc:40:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
40 | rep(i,1,n)
| ^
a.cc:4:36: note: in definition of macro 'rep'
4 | #define rep(i,a,b) for(register ll i=(a);i<=(b);i++)
| ^
a.cc:42:17: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
42 | dep(k,i-1,0)
| ^
a.cc:5:36: note: in definition of macro 'dep'
5 | #define dep(i,a,b) for(register ll i=(a);i>=(b);i--)
| ^
a.cc:43:17: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
43 | dep(j,sum,a[i])
| ^
a.cc:5:36: note: in definition of macro 'dep'
5 | #define dep(i,a,b) for(register ll i=(a);i>=(b);i--)
| ^
a.cc:45:31: error: no matching function for call to 'max(long long int&, int)'
45 | dp[k+1][j]=max(dp[k+1][j],0);
| ~~~^~~~~~~~~~~~~~
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:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:45:31: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
45 | dp[k+1][j]=max(dp[k+1][j],0);
| ~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:45:31: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
45 | dp[k+1][j]=max(dp[k+1][j],0);
| ~~~^~~~~~~~~~~~~~
a.cc:55:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
55 | rep(i,1,n)
| ^
a.cc:4:36: note: in definition of macro 'rep'
4 | #define rep(i,a,b) for(register ll i=(a);i<=(b);i++)
| ^
|
s418393150
|
p04015
|
C
|
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint LINF = 1e18;
lint digit_sum(lint n, lint b) {
lint res = 0;
while (n > 0) {
res += n % b;
n /= b;
}
return res;
}
int main() {
lint n, s;
cin >> n >> s;
lint ans;
if (n == s) {
ans = n + 1;
} else {
ans = LINF;
for (lint b = 2; b * b <= n; b++) {
if (digit_sum(n, b) == s) {
ans = min(ans, b);
}
}
for (lint p = 1; p * p < n; p++) {
if ((n - s) % p == 0) {
lint b = lint(1) + (n - s) / p;
if (0 <= p and p < b and 0 <= s - p and s - p < b) {
ans = min(ans, b);
}
}
}
}
if (ans == LINF) {
cout << -1 << endl;
} else {
cout << ans << endl;
}
return 0;
}
|
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
1 | #include <bits/stdc++.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
|
s018977517
|
p04015
|
C++
|
hard
|
a.cc:1:1: error: 'hard' does not name a type
1 | hard
| ^~~~
|
s272455932
|
p04015
|
C++
|
#include <bits/stdc++.h>
using namespace std;
long long dp[60][60][2600];
int main() {
long long N,A;
cin >> N >> A;
vector<long long> x(N+10);
for(int i=1;i<=N;i++)cin >> x[i];
dp[0][0][0]=1;
for(int i=1;i<=N;i++){
for(int j=1;j<=i;j++){
for(int k=1;k<=N*A;k++){
dp[i][j-1][k]=dp[i-1][j-1][k];
if(i>j && j>=x[i]){dp[i][j][k]=dp[i-1][j-1][k]+dp[i-1][j-1][k-x[i]];}
}
}
}
long long cnt=0;
for(int i=1;i<=N;i++){
for(int j=1;j<=i;j++){
for(int k=1;k<=N*A;k++){
if(j*A==dp[i][j][k]){cnt+=dp[i][j][k];}
}
}
}
cout << cnt << endl;
|
a.cc: In function 'int main()':
a.cc:27:23: error: expected '}' at end of input
27 | cout << cnt << endl;
| ^
a.cc:5:12: note: to match this '{'
5 | int main() {
| ^
|
s689733413
|
p04015
|
Java
|
public class Main {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
int N = keyboard.nextInt();
int A = keyboard.nextInt();
int[] in = new int[N];
for(int i=0; i < N; i++) {
in[i] = keyboard.nextInt();
}
for (int i = 0; i < N; i++) {
in[i] -= A;
}
long[][] masu = new long[51][5001];
masu[0][2500] = 1;
for(int j = 1; j < N+1; j++) {
for(int k = 0; k < 5001; k++) {
if(k-in[j-1] >= 0 && k-in[j-1] <= 5000) {
masu[j][k] += masu[j-1][k-in[j-1]];
masu[j][k] += masu[j-1][k];
}
}
}
System.out.println(masu[N][2500]-1);
keyboard.close();
}
}
|
Main.java:4: error: cannot find symbol
Scanner keyboard = new Scanner(System.in);
^
symbol: class Scanner
location: class Main
Main.java:4: error: cannot find symbol
Scanner keyboard = new Scanner(System.in);
^
symbol: class Scanner
location: class Main
2 errors
|
s825756887
|
p04015
|
C++
|
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0))
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0))
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a))
#define Reverse(a) reverse(All(a))
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define Lower(a,t) lower_bound(All(a),t)
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
struct UnionFind {
vector<int> par; // par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2
UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
for(int i = 0; i < N; i++) par[i] = i;
}
int root(int x) { // データxが属する木の根を再帰で得る:root(x) = {xの木の根}
if (par[x] == x) return x;
return par[x] = root(par[x]);
}
void unite(int x, int y) { // xとyの木を併合
int rx = root(x); //xの根をrx
int ry = root(y); //yの根をry
if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時:xの根rxをyの根ryにつける
}
bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
int rx = root(x);
int ry = root(y);
return rx == ry;
}
};
int nienu(int n){
int ans = 1;
REP(i,n){
ans *= 2;
}
return ans;
}
signed main(){
int n,a;
cin >> n >> a;
vec(b,55);
vec(c,55);
REP(i,n){
int t;
cin >> t;
if(t-a>0){
b[t-a]++;
}
else{
c[a-t]++;
}
}
int kake = nienu(c[0]);
int ans_t = 1;
FOR(i,1,n){
ans_t += a[i]*b[i];
}
ans_t *= kake;
ans_t--;
cout << ans_t << endl;
return 0;
}
void Debug(auto a){
cout << "{ ";
for(auto b: a){
cout << b << " ";
}
cout << "}" << endl;
}
|
a.cc:18:12: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
18 | void Debug(auto a);
| ^~~~
a.cc: In function 'int main()':
a.cc:71:19: error: invalid types 'long long int[long long int]' for array subscript
71 | ans_t += a[i]*b[i];
| ^
a.cc: At global scope:
a.cc:84:12: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
84 | void Debug(auto a){
| ^~~~
|
s562348502
|
p04015
|
C++
|
#include <iostream>
#include <stdio.h>
#define maxn 51
#define maxsum 5000
using namespace std;
int N, A;
// dp[i][j][k] = j carti din primele i carti care dau suma k
// dp[1][0][0] = 1
// dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - v[i]]
long long dp[maxn][maxn][maxsum];
int v[maxn];
int main()
{
int mini = 100;
long long rez = 0;
scanf("%d %d", &N, &A);
for (int i = 1; i <= N; ++i) {
scanf("%d", &v[i]);
mini = min(v[i], mini);
// dp[i][1][v[i]] = 1;
dp[i][0][0] = 1;
}
dp[0][0][0] = 1;
for (int i = 1; i <= N; ++i) {
for (int j = 1; j <= i; ++j) {
for (int k = 0; k <= maxsum; ++k) {
dp[i][j][k] = dp[i - 1][j][k];
if (k - v[i] >= 0) {
dp[i][j][k] += dp[i - 1][j - 1][k - v[i]];
}
}
}
for (long long i = 1; i <= N; ++i) {
rez += dp[N][i][i * A];
}
printf("%lld", rez);
return 0;
}
|
a.cc: In function 'int main()':
a.cc:39:2: error: expected '}' at end of input
39 | }
| ^
a.cc:14:1: note: to match this '{'
14 | {
| ^
|
s292401590
|
p04015
|
C++
|
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
//using
using VI = vector<int>;
using VVI = vector<VI>;
using VS = vector<string>;
using PII = pair<int, int>;
using LL = long long;
//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
//constant
const int INF = 1 << 29;
const double EPS = 1e-10;
const double PI = acos(-1.0);
//debug
#define dump(x) cout << #x << " = " << (x) << endl;
int main() {
int N, A;
cin >> N >> A;
VI x(N);
REP(i, N) cin >> x[i];
sort(x.begin(), x.end());
vector<set<int>> sum;
int ans = 0;
REP(i, N) {
REP(j, sum.size()) { //j個選んだときの合計値がsetとしてsumに入っている.
sum[j];
}
}
cout << cost << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:45:12: warning: ignoring return value of 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = std::set<int>; _Alloc = std::allocator<std::set<int> >; reference = std::set<int>&; size_type = long unsigned int]', declared with attribute 'nodiscard' [-Wunused-result]
45 | sum[j];
| ^
In file included from /usr/include/c++/14/vector:66,
from /usr/include/c++/14/queue:63,
from a.cc:7:
/usr/include/c++/14/bits/stl_vector.h:1128:7: note: declared here
1128 | operator[](size_type __n) _GLIBCXX_NOEXCEPT
| ^~~~~~~~
a.cc:48:11: error: 'cost' was not declared in this scope; did you mean 'cosl'?
48 | cout << cost << endl;
| ^~~~
| cosl
|
s064836531
|
p04015
|
C++
|
//#include<stdio.h>
//#include<stdlib.h>
//#include<string.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=55;
int main()
{
int n;
int a;
//for(auto &a:b)
//存在n*n种组合方法,求解满足条件的方法,遍历?
cin>>n>>a;
int b[N][N*N]={0};
int p;
ll cnt=0;//计算方法数
b[0][0]=1;
for(int i=1; i<=n; i++)
{
cin>>p;
for(int j=i-1; j>=0; j--)
{
for(int k=0; k<=N*j; k++)
{
b[j+1][p+k]+=b[j][k];//将每一种可能加到一个p+k,使得每一个可能的和的地方数组储存的数字都为1
}
}
}
for(int i=1; i<=n; i++)
{
cnt+=b[i][i*a];//若是i*a处不为0则说明p+k可以加到这个位置
}
cout<<cnt<<endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:14:13: error: 'a\U0000ff1b' was not declared in this scope
14 | cin>>n>>a;
| ^~~
a.cc:18:9: error: 'b' was not declared in this scope
18 | b[0][0]=1;
| ^
|
s819053508
|
p04015
|
C++
|
//#include<stdio.h>
//#include<stdlib.h>
//#include<string.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=60;
int main()
{
int n;
int a;
//for(auto &a:b)
//存在n*n种组合方法,求解满足条件的方法,遍历?
cin>>n>>a;
int b[N][N*N]={0};
int p;
ll cnt=0;//计算方法数
b[0][0]=1;
for(int i=1; i<=n; i++)
{
cin>>p;
for(int j=i-1; j>=0; j--)
{
for(int k=0; k<=N*j; k++)
{
b[j+1][p+k]+=b[j][k];//将每一种可能加到一个p+k,使得每一个可能的和的地方数组储存的数字都为1
}
}
}
for(int i=1; i<=n; i++)
{
cnt+=b[i][i*a];//若是i*a处不为0则说明p+k可以加到这个位置
}
cout<<cnt<<endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:14:13: error: 'a\U0000ff1b' was not declared in this scope
14 | cin>>n>>a;
| ^~~
a.cc:18:9: error: 'b' was not declared in this scope
18 | b[0][0]=1;
| ^
|
s549225635
|
p04015
|
C++
|
#include <bits/stdc++.h>
using namespace std;
LL dp[51][51][2501];
int main()
{
//freopen("In.txt" , "r" , stdin);
int N , A;
cin >> N >> A;
vector<int> a(N);
for(auto &x : a)
cin >> x;
dp[0][0][0] = 1;
for(int i = 0; i < N; i++)
{
for(int picked = 0; picked <= 50; picked++)
{
for(int sum = 0; sum <= i * 50; sum++)
{
dp[i + 1][picked + 1][sum + a[i]] +=
dp[i][picked][sum];
dp[i + 1][picked][sum] += dp[i][picked][sum];
}
}
}
LL ans = 0;
for(int picked = 1; picked <= N; picked++)
ans += dp[N][picked][picked * A];
cout << ans;
return 0;
}
|
a.cc:3:1: error: 'LL' does not name a type
3 | LL dp[51][51][2501];
| ^~
a.cc: In function 'int main()':
a.cc:12:9: error: 'dp' was not declared in this scope; did you mean 'dup'?
12 | dp[0][0][0] = 1;
| ^~
| dup
a.cc:25:9: error: 'LL' was not declared in this scope
25 | LL ans = 0;
| ^~
a.cc:27:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
27 | ans += dp[N][picked][picked * A];
| ^~~
| abs
a.cc:28:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
28 | cout << ans;
| ^~~
| abs
|
s331060390
|
p04015
|
C++
|
#include <bits/stdc++.h>
using namespace std;
#define vong1(i,a,b) for(int i=a;i<b;i++)
int N, A;
int x[50];
long p[100][100]10000];
//-----------------------------------------------------------------
int main()
{
cin >> N >> A;
vong1(i, 0, N) cin >> x[i];
p[0][0][0] = 1;
vong1(i, 0, N)
{
vong1(j, 0, N)
{
vong1(k, 0, 2500)
{
if(p[i][j][k])
{
p[i + 1][j][k] += p[i][j][k];
p[i + 1][j + 1][k + x[i]] += p[i][j][k];
}
}
}
}
long ans = 0;
vong1(i, 1, N + 1) ans += p[N][i][i*A];
cout << ans << endl;
}
|
a.cc:6:17: error: expected initializer before numeric constant
6 | long p[100][100]10000];
| ^~~~~
a.cc: In function 'int main()':
a.cc:14:9: error: 'p' was not declared in this scope
14 | p[0][0][0] = 1;
| ^
|
s951801750
|
p04015
|
C++
|
#include <bits/stdc++.h>
using namespace std;
#define vong1(i,a,b) for(int i=a;i<b;i++)
int N, A;
int x[50];
long p[51][51][3010];
//-----------------------------------------------------------------
int main()
{
cin >> N >> A;
vong1(i, 0, N) cin >> x[i];
p[0][0][0] = 1;
vong1(i, 0, N)
{
vong1(j, 0, N)
{
vong1(k, 0, 2500)
{
if(p[i][j][k])]
{
p[i + 1][j][k] += p[i][j][k];
p[i + 1][j + 1][k + x[i]] += p[i][j][k];
}
}
}
}
long ans = 0;
vong1(i, 1, N + 1) ans += p[N][i][i*A];
cout << ans << endl;
}
|
a.cc: In function 'int main()':
a.cc:21:47: error: expected primary-expression before ']' token
21 | if(p[i][j][k])]
| ^
|
s481142531
|
p04015
|
C++
|
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
int main()
{
ll n,a,i,j,k;
cin>>n>>a;
ll x[n+1];
for(i=1;i<=n;i++)
{
cin>>x[i];
}
ll dp[51][51][2501];
for(i=0;i<=2500;i++)
{
dp[0][0][i] = 0;
}
for(i=1;i<=n;i++)
{
for(k=0;k<=2500;k++)
{
ll count = 0;
for(j=1;j<=i;j++)
{
if(x[j]==k)
count++;
}
dp[i][1][k] = count;
}
}
for(i=2;i<=n;i++)
{
for(j=2;j<=i;j++)
{
for(k=0;k<=2500;k++)
{
dp[i][j][k] = max(dp[i][j][k],dp[i-1][j][k]+dp[i-1][j-1][max(0LL,k-x[i])]);
/*if(dp[i][j][k]>0 && j==2 && k==8)
{
cout<<i<<" "<<j<<" "<<k<<" "<<dp[i][j][k]<<endl;
}*/
}
}
}
ll ans = 0;
for(i=1;i<=n;i++)
{
ans += dp[n][i][a*i];
// cout<<dp[n][i][a*i]<<" ";
}
cout<<ans<<endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:38:77: error: no matching function for call to 'max(long long int, ll)'
38 | dp[i][j][k] = max(dp[i][j][k],dp[i-1][j][k]+dp[i-1][j-1][max(0LL,k-x[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:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:38:77: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'll' {aka 'long long unsigned int'})
38 | dp[i][j][k] = max(dp[i][j][k],dp[i-1][j][k]+dp[i-1][j-1][max(0LL,k-x[i])]);
| ~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:38:77: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
38 | dp[i][j][k] = max(dp[i][j][k],dp[i-1][j][k]+dp[i-1][j-1][max(0LL,k-x[i])]);
| ~~~^~~~~~~~~~~~
|
s479700595
|
p04015
|
C++
|
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
int N,A;
ll dp[51][2501],ans;
vector<int> a(N);
int main()
{
cin>>N>>A;
for (int& x: a) cin>>x;
dp[0][0]=1;
for (int x: a)
{
for (int k=50;k>=0;k--)
for (int y=0;y<=2500;y++)
{
if (!dp[k][y]) continue; //dp[k][y]表示 取其中k张卡片,总和为y的方案数
dp[k+1][y+t]+=dp[k][y];
}
}
for (int k=1;k<=50;k++)
for (int y=0;y<=2500;y++)
if (k*A==y) ans+=dp[k][y];
cout<<ans;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:20:43: error: 't' was not declared in this scope
20 | dp[k+1][y+t]+=dp[k][y];
| ^
|
s829359010
|
p04015
|
C++
|
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=1e5+5,L=20;
typedef long long ll;
int a[N];
int p[N][L];
int main()
{
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++){
scanf("%d",&a[i]);
}
int L;
scanf("%d",&L);
for(int i=1,j=1;i<=n;i++){
while(x[j]+L<x[i])
j++;
p[i][0]=j;
}
for(int i=1;i<=n;i++)
for(int j=1;(1<<j)<=i;j++)
p[i][j]=p[p[i][j-1]][j-1];
int q;
scanf("%d",&q);
while(q--){
int l,r;
scanf("%d%d",&l,&r);
if(l>r)
swap(l,r);
int g=0;
while(1<<g<=r)
g--;
int ans=0;
for(int i=g;i>=0;i--)
if(p[r][j]>=l)
r=p[r][j],ans+=1<<i;
if(r>l)
ans++;
printf("%d\n",ans);
}
}
|
a.cc: In function 'int main()':
a.cc:19:15: error: 'x' was not declared in this scope
19 | while(x[j]+L<x[i])
| ^
a.cc:38:21: error: 'j' was not declared in this scope
38 | if(p[r][j]>=l)
| ^
|
s173366051
|
p04015
|
C++
|
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>
using namespace std;
typedef long long int ll;
#define all(x) x.begin(),x.end()
const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;
int main()
{
ll n,a;
cin >> n >> a;
vector<ll>x(n+1);
for(int i = 1; i <= n; i++){
cin >> x[i];
}
ll dp[51][51][50*50+1] = {0};
for(int i = 0; i <= n; i++){
dp[i][0][0]=1;
}
for(int i = 1; i <= n; i++){
for(int j = 1; j <= n; j++){
for(int k = 0; k <=; k++){
if(k-x[i] >= 0){
dp[i][j][k] = dp[i-1][j-1][k-x[i]] + dp[i-1][j][k];
}else{
dp[i][j][k] = dp[i-1][j][k];
}
}
}
}
ll ans = 0;
for(int j = 1; j <= n; j++){
//cout << ans << endl;
ans += dp[n][j][j*a];
}
cout << ans << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:38:44: error: expected primary-expression before ';' token
38 | for(int k = 0; k <=; k++){
| ^
|
s824283274
|
p04015
|
C++
|
#pragma GCC optimize("O3")
#include <iostream>
#include <cstdio>
#include <cstring>
#include <list>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#define in(x) scanf("%d",&x)
#define ein(x) ~scanf("%d",&x)
#define inl(x) scanf("%lld",&x)
#define ins(x) scanf("%s",x)
#define inf(x) scanf("%lf",&x)
#define inc(x) scanf("%c",&x)
#define gc() getchar()
#define out(x) printf("%d\n",x)
#define outl(x) printf("%lld\n",x)
#define od(x, y) printf("%d %d\n",x,y)
#define ms(x) memset(x,0,sizeof(x))
#define msc(x, n) memset(x,n,sizeof(x))
#define cp(x) while(!x.empty())x.pop()
#define rep(i, a, b) for(int i=a;i<b;++i)
#define rvep(i, a, b) for(int i=a;i>=b;--i)
#define elif else if
#define el else
#define wl(x) while(x)
#define sn scanf
#define bl bool
#define mp make_pair
#define pii pair<int,int>
#define rtn return
#define ope operator
#define cst const
#define it int
#define cr char
#define ctn continue
#define stt struct
#define il inline
#define tpl template
#define cl class
#define db double
#define sf(x) sizeof(x)
#define vt void
#define pf printf
typedef long long ll;
using namespace std;
cst it INF = 0x3f3f3f3f;
/*
* 输入挂
* 场场AK buff
*/
class endln {
};
class iofstream {
private:
it idx;
bl eof;
cr buf[100000], *ps, *pe;
cr bufout[100000], outtmp[50], *pout, *pend;
il vt rnext() {
if (++ps == pe)
pe = (ps = buf) + fread(buf, sf(cr), sf(buf) / sf(cr), stdin), eof = true;
if (ps == pe)
eof = false;
}
il vt write() {
fwrite(bufout, sf(cr), pout - bufout, stdout);
pout = bufout;
}
public:
iofstream(char *in = NULL, char *out = NULL) : idx(-1), eof(true) {
ps = buf, pe = buf + 1;
pout = bufout, pend = bufout + 100000;
if (in)
freopen(in, "r", stdin);
if (out)
freopen(out, "w", stdout);
}
tpl<cl T>
il bl fin(T &ans) {
#ifdef ONLINE_JUDGE
ans = 0;
T f = 1;
if (ps == pe)
{
eof=false;
rtn false;//EOF
}
do
{
rnext();
if ('-' == *ps) f = -1;
} wl(!isdigit(*ps) && ps != pe);
if (ps == pe)
{
eof=false;
rtn false;//EOF
}
do
{
ans = (ans << 1) + (ans << 3) + *ps - 48;
rnext();
} wl(isdigit(*ps) && ps != pe);
ans *= f;
#else
cin >> ans;
#endif
rtn true;
}
tpl<cl T>
il bl fdb(T &ans) {
#ifdef ONLINE_JUDGE
ans = 0;
T f = 1;
if (ps == pe) rtn false;//EOF
do
{
rnext();
if ('-' == *ps) f = -1;
} wl(!isdigit(*ps) && ps != pe);
if (ps == pe) rtn false;//EOF
do
{
ans = ans*10 + *ps - 48;
rnext();
} wl(isdigit(*ps) && ps != pe);
ans *= f;
if(*ps=='.')
{
rnext();
T small=0;
do
{
small=small*10+*ps-48;
rnext();
}wl(isdigit(*ps)&&ps!=pe);
wl(small>=1)
{
small/=10;
}
ans+=small;
}
#else
cin >> ans;
#endif
rtn true;
}
/*
* 输出挂
* 超强 超快
*/
il bl out_char(cst cr c) {
#ifdef ONLINE_JUDGE
*(pout++) = c;
if (pout == pend) write();
write();
#else
cout << c;
#endif
rtn true;
}
il bl out_str(cst cr *s) {
#ifdef ONLINE_JUDGE
wl(*s)
{
*(pout++) = *(s++);
if (pout == pend) write();
}
write();
#else
cout << s;
#endif
rtn true;
}
tpl<cl T>
il bl out_double(T x, it idx) {
char str[50];
string format = "%";
if (~idx) {
format += '.';
format += (char) (idx + '0');
}
format += "f";
sprintf(str, format.c_str(), x);
out_str(str);
}
tpl<cl T>
il bl out_int(T x) {
#ifdef ONLINE_JUDGE
if (!x)
{
out_char('0');
rtn true;
}
if (x < 0) x = -x, out_char('-');
it len = 0;
wl(x)
{
outtmp[len++] = x % 10 + 48;
x /= 10;
}
outtmp[len] = 0;
for (it i = 0, j = len - 1; i < j; i++, j--) swap(outtmp[i], outtmp[j]);
out_str(outtmp);
#else
cout << x;
#endif
rtn true;
}
tpl<cl T>
il bl out_intln(T x) {
#ifdef ONLINE_JUDGE
out_int(x),out_char('\n');
write();
#else
cout << x << endl;
#endif
rtn true;
}
tpl<cl T>
il bl out_doubleln(T x, it idx) {
out_double(x, idx), out_char('\n');
}
il iofstream &ope<<(cst db &x) {
out_double(x, idx);
rtn *this;
}
il iofstream &ope<<(cst it &x) {
out_int(x);
rtn *this;
}
il iofstream &ope<<(cst unsigned long long &x) {
out_int(x);
rtn *this;
}
il iofstream &ope<<(cst unsigned &x) {
out_int(x);
rtn *this;
}
il iofstream &ope<<(cst long &x) {
out_int(x);
rtn *this;
}
il iofstream &ope<<(cst ll &x) {
out_int(x);
rtn *this;
}
il iofstream &ope<<(cst endln &x) {
out_char('\n');
rtn *this;
}
il iofstream &ope<<(cst cr *x) {
out_str(x);
rtn *this;
}
il iofstream &ope<<(cst string &x) {
out_str(x.c_str());
rtn *this;
}
il iofstream &ope<<(cst char &x) {
out_char(x);
rtn *this;
}
il bl setw(it x) {
if (x >= 0) {
idx = x;
rtn true;
}
rtn false;
}
il iofstream &ope>>(it &x) {
if (!fin(x))eof = false;
rtn *this;
}
il iofstream &ope>>(ll &x) {
if (!fin(x))eof = false;
rtn *this;
}
il iofstream &ope>>(db &x) {
if (!fdb(x))eof = false;
rtn *this;
}
il iofstream &ope>>(float &x) {
if (!fdb(x))eof = false;
rtn *this;
}
il iofstream &ope>>(unsigned &x) {
if (!fin(x))eof = false;
rtn *this;
}
il iofstream &ope>>(unsigned long long &x) {
if (!fin(x))eof = false;
rtn *this;
}
il ope bl() {
rtn eof;
}
il cr getchar() {
#ifdef ONLINE_JUDGE
if (ps == pe){
eof=false;//EOF
rtn 0;
}
rnext();
if(ps+1==pe)
eof=false;
rtn *ps;
#else
rtn std::getchar();
#endif
}
il iofstream &ope>>(char *str) {
#ifdef ONLINE_JUDGE
if (ps == pe){
eof=false;//EOF
rtn *this;
}
do
{
rnext();
} wl(isspace(*ps)&&iscntrl(*ps) && ps != pe);
if (ps == pe){
eof=false;//EOF
rtn *this;
}
do
{
*str=*ps;
++str;
rnext();
} wl(!(isspace(*ps)||iscntrl(*ps)) && ps != pe);
*str='\0';
rtn *this;
#else
cin >> str;
rtn *this;
#endif
}
il iofstream &ope>>(string &str) {
#ifdef ONLINE_JUDGE
str.clear();
if (ps == pe){
eof=false;//EOF
rtn *this;
}
do
{
rnext();
} wl(isspace(*ps)&&iscntrl(*ps) && ps != pe);
if (ps == pe){
eof=false;//EOF
rtn *this;
}
do
{
str+=*ps;
rnext();
} wl(!(isspace(*ps)||iscntrl(*ps)) && ps != pe);
rtn *this;
#else
cin >> str;
rtn *this;
#endif
}
il iofstream &getline(char *str) {
#ifdef ONLINE_JUDGE
if (ps == pe){
eof=false;//EOF
rtn *this;
}
do
{
rnext();
*str=*ps;
}while(*ps!='\n'&&ps!=pe&&str++);
*str='\0';
rtn *this;
#else
gets(str);
rtn *this;
#endif
}
il bl endfile() {
rtn eof;
}
};
static iofstream fin;
static endln ln;
class range {
public:
class iterator {
friend class range;
public:
int operator*() const { return i_; }
iterator &operator++() {
++i_;
return *this;
}
iterator operator++(int) {
iterator copy(*this);
++i_;
return copy;
}
bool operator==(const iterator &other) const { return i_ == other.i_; }
bool operator!=(const iterator &other) const { return i_ != other.i_; }
protected:
iterator(int start) : i_(start) {}
private:
int i_;
};
iterator begin() const { return begin_; }
iterator end() const { return end_; }
range(int begin, int end) : begin_(begin), end_(end) {}
private:
iterator begin_;
iterator end_;
};
template<typename T>
class reverse_iterator_class {
public:
explicit reverse_iterator_class(const T &t) : t(t) {}
typename T::const_reverse_iterator begin() const { return t.rbegin(); }
typename T::const_reverse_iterator end() const { return t.rend(); }
private:
const T &t;
};
using ll = long long;
template<typename T>
reverse_iterator_class<T> reverse(const T &t) {
return reverse_iterator_class<T>(t);
}
using LL = long long;
const LL mod = 1e9 + 7;
int x[100000];
int r[17][100000];
int main() {
int n;
fin>>n;
for (auto i:range(0, n)) {
fin>>x[i];
}
int l, q;
fin>>l>>q;
for (auto i:range(0, n)) {
r[0][i] = upper_bound(x, x + n, x[i] + l) - x - 1;
}
for (int i = 1; i < 17; i++) {
for (auto j:range(0, n)) {
r[i][j] = r[i - 1][r[i - 1][j]];
}
}
for (auto i:range(0, q)) {
int a, b;
fin>>a>>b;
a--;
b--;
if (a > b)swap(a, b);
int cnt = 0;
for (int i = 16; i >= 0; i--) {
if (r[i][a] < b) {
a = r[i][a];
cnt += 1 << i;
}
}
fin<<cnt+1<<ln;
}
}
|
a.cc: In member function 'bool iofstream::out_double(T, int)':
a.cc:205:5: warning: no return statement in function returning non-void [-Wreturn-type]
205 | }
| ^
a.cc: In member function 'bool iofstream::out_doubleln(T, int)':
a.cc:245:5: warning: no return statement in function returning non-void [-Wreturn-type]
245 | }
| ^
a.cc: In member function 'iofstream& iofstream::getline(char*)':
a.cc:424:9: error: 'gets' was not declared in this scope; did you mean 'getw'?
424 | gets(str);
| ^~~~
| getw
|
s488364661
|
p04015
|
C++
|
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<stdlib.h>
#include<stack>
using namespace std;
const int N=1e5+50;
const int INF=0x3f3f3f;
long long dp[N][N];
long long sum;
int main()
{
int n,m,a,b;
scanf("%d%d",&n,&m);
dp[0][0]=1;
sum=0;
for(int i=1;i<=n;i++)
{
scanf("%d",&b);
for(int j=i;j>=0;j--)
{
for(int k=m*n;k>=b;k--)
{
dp[j][k]+=dp[j-1][k-b];
}
}
}
for(int i=1;i<=n;i++)
sum+=dp[i][i*m];
printf("%lld\n",sum);
return 0;
}
|
/tmp/cc74N2Xa.o: in function `main':
a.cc:(.text+0x35): relocation truncated to fit: R_X86_64_PC32 against symbol `sum' defined in .bss section in /tmp/cc74N2Xa.o
a.cc:(.text+0x16b): relocation truncated to fit: R_X86_64_PC32 against symbol `sum' defined in .bss section in /tmp/cc74N2Xa.o
a.cc:(.text+0x175): relocation truncated to fit: R_X86_64_PC32 against symbol `sum' defined in .bss section in /tmp/cc74N2Xa.o
a.cc:(.text+0x188): relocation truncated to fit: R_X86_64_PC32 against symbol `sum' defined in .bss section in /tmp/cc74N2Xa.o
collect2: error: ld returned 1 exit status
|
s829519730
|
p04015
|
C++
|
///
// File: c.go
// Author: ymiyamoto
//
// Created on Sat Feb 24 18:11:43 2018
//
package main
import (
"fmt"
)
func main() {
var N, A int
fmt.Scan(&N, &A)
cards := make([]int, N)
for i := 0; i < N; i++ {
fmt.Scan(&cards[i])
}
dp := make([][][]int64, N+1)
for i := range dp {
dp[i] = make([][]int64, N+1)
for j := range dp[i] {
dp[i][j] = make([]int64, 251)
}
}
dp[0][0][0] = 1
for i := 0; i < N; i++ {
for j := 0; j < N; j++ {
for k := 0; k <= 250; k++ {
if k+cards[i] <= 250 {
dp[i+1][j+1][k+cards[i]] += dp[i][j][k]
}
dp[i+1][j][k] += dp[i][j][k]
}
}
}
var count int64 = 0
for i := 1; i <= N; i++ {
count += dp[N][i][A*i]
}
fmt.Println(count)
}
|
a.cc:7:1: error: 'package' does not name a type
7 | package main
| ^~~~~~~
|
s225151048
|
p04015
|
C++
|
//In the name of God
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n , A , a[60] , dp[60][60][3000];
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> A;
for(int i=1 ; i <= n ; i++)
cin >> a[i];
dp[0][0][0] = 1;
for(int i=1 ; i <= n ; i++){
dp[i][0][0] = 1;
for(int j=1 ; j <= i ; j++)
for(int k=1 ; k < 2800 ; k++){
dp[i][j][k] = dp[i-1][j][k];
if(k >= a[i])
dp[i][j][k] += dp[i-1][j-1][k - a[i]];
}
}
int res = 0;
for(int i=1 ; i <= n ; i++)
res += dp[n][i][i*A];
cout << res;
}
~
|
a.cc:31:2: error: expected class-name at end of input
31 | ~
| ^
|
s987957144
|
p04015
|
C++
|
#include <iostream>
#include <vector>
using namespace std;
int dp[50][50][50 * 50];
int main(void) {
int N, A;
cin >> N >> A;
vector<int> x;
x.push_back(0);
for (int i = 0; i < N; ++i) {
int x_in;
cin >> x_in;
x.push_back(x_in);
}
int X = *max_element(x.begin(), x.end());
for (int j = 0; j <= N; ++j) {
for (int k = 0; k <= N; ++k) {
for (int s = 0; s <= N * X; ++s) {
if (j == 0 && k == 0 && s == 0) {
dp[j][k][s] = 1;
} else if (j >= 1 && s < x[j]) {
dp[j][k][s] = dp[j - 1][k][s];
} else if (j >= 1 && k >= 1 && s >= x[j]) {
dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k - 1][s - x[j]];
} else {
dp[j][k][s] = 0;
}
}
}
}
long long num = 0;
for (int k = 1; k <= N; ++k) {
num += dp[N][k][k * A];
}
cout << num << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:19:14: error: 'max_element' was not declared in this scope
19 | int X = *max_element(x.begin(), x.end());
| ^~~~~~~~~~~
|
s283941895
|
p04015
|
C++
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> int_pair;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
const int N=50;
const int NX = 2500;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int n,a,x[N+1];
int dp[N+1][N+1][NX+1];
cin >> n >> a;
FOR(i,1,n+1)cin >> x[i];
FOR(j,0,n+1){
FOR(k,0,n+1){
FOR(s,0,n*50+1){
if(j==0 && k==0 && s==0)dp[0][0][0]=1;
else if(j>=1 && s<x[j])
dp[j][k][s]=dp[j-1][k][s];
else if(j>=1 && k>=1 && s>=x[j])
dp[j][k][s]=dp[j-1][k][s]+dp[j-1][k-1][s-x[j]];
else dp[j][k][s]=0;
}
}
}
unsigned ll ans=0;
FOR(k,1,n+1){
ans += dp[n][k][k*a];
}
cout << ans << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:29:21: error: expected initializer before 'ans'
29 | unsigned ll ans=0;
| ^~~
a.cc:31:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
31 | ans += dp[n][k][k*a];
| ^~~
| abs
a.cc:33:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
33 | cout << ans << endl;
| ^~~
| abs
|
s585992950
|
p04015
|
C++
|
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,a;
cin>>n>>a;
vector<int>x;
x.resize(n);
for(auto&m:x)cin>>m;
vector<map<int,vector<int>>> map_(n+1);
vector<int> z(1,-1);
map_.at(0).insert(make_pair(0,z));
long long intsum=0;
for(int m=0;m<n;++m){
for(auto&t:map_.at(m)){
for(int v=0;v<n;++v){
vector<int>vec=t.second;
if(find(vec.begin(),vec.end(),v)==vec.end()||vec.size()==1){
vec.pop_back();
vec.push_back(v);
sort(vec.begin(),vec.end());
vec.push_back(-1);
bool flag=true;
for(auto &c:map_.at(m+1))if(c.second==vec)flag=false;
if(flag){
for(auto&m:vec)cout<<m<<" ";cout<<m+1<<" "<<t.first+x.at(v)<<endl;
map_.at(m+1).insert(make_pair(t.first+x.at(v),vec));
// cout << t.first+x.at(v)<<endl;
if((t.first+x.at(v)*1.0)/((m+1)*1.0)==a){
++sum;
cout<<"seikai"<<endl;
}
}
}
}
}
}
cout<<sum<<endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:32:31: error: 'sum' was not declared in this scope
32 | ++sum;
| ^~~
a.cc:40:11: error: 'sum' was not declared in this scope
40 | cout<<sum<<endl;
| ^~~
|
s821910251
|
p04015
|
C++
|
#include <map>
#include <algorithm>
#include <cassert>
#include <climits>
#include <complex>
#include <cstdio>
#include <string>
#include <iostream>
#include <queue>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
#define DEBUG(X) cerr<<" "<<#X<<" = "<<X<<endl;
#define DUMP(A, n) for (auto x=begin(A); x!=begin(A)+n;x++){cout <<*x<< ' ';} cout<<endl;
#define DUMPP(A, n, m) for (auto x=begin(A); x != begin(A)+n;x++) {for (auto y=begin(*x); y != begin(*x)+m;)cout <<*y++<< ' '; cout<<endl;};
#define DUMPM(M) for (auto itr=mp.begin(); itr!=mp.end(); itr++) {cout<<itr->first<<" -> "<<itr->second<<endl;}
#define FOR(i,x,y) for(int i=(x);i<(int)(y);i++)
#define FORP(i,x,y) for(int i=(x);i<=(int)(y);i++)
#define REP(i,y) for(int i=0;i<(int)(y);i++)
#define REPP(i,y) for(int i=1;i<=(int)(y);i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
ll n,s;
ll f(ll b, ll n)
{
if (n >= b)
return (n%b) + f(b, (ll)(n/b));
else
return n;
}
int main() {
cin >> n >> s;
ll nr = sqrt(n);
for(ll b=2;b<=nr;b++)
{
ll sum = f(b, n);
if (sum==s) {
cout << b << endl;
return 0;
}
}
if (s==n)
{
cout << n+1 << endl;
return 0;
}
if (n<s)
{
cout << "-1" << endl;
return 0;
}
for(ll p=1;p<=9;p++)
{
ll q = s-p;
if ((n-q)%p==0&&b=>q&&q>=0) {
ll b = (n-q)/p;
cout << b << endl;
return 0;
}
}
cout << "-1" << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:68:21: error: 'b' was not declared in this scope
68 | if ((n-q)%p==0&&b=>q&&q>=0) {
| ^
a.cc:68:23: error: expected primary-expression before '>' token
68 | if ((n-q)%p==0&&b=>q&&q>=0) {
| ^
a.cc:69:10: error: redeclaration of 'll b'
69 | ll b = (n-q)/p;
| ^
a.cc:68:21: note: '<typeprefixerror>b' previously declared here
68 | if ((n-q)%p==0&&b=>q&&q>=0) {
| ^
|
s430787800
|
p04015
|
C++
|
ll N, A;
cin >> N >> A;
vector<ll> x;
x.pb(0);
rep(i,N){
ll inp; cin >> inp;
x.pb(inp);
}
rep(i,N)dp[i][0][0]=1;//0枚選んで合計0のやつが全部1通り
for(ll i =1;i<=N;i++){
for(ll j = 1;j<=N;j++){
for(ll k = 1;k<=3000;k++){
if(k<x[i])dp[i][j][k]=dp[i-1][j][k];
else dp[i][j][k]=dp[i-1][j][k]+dp[i-1][j-1][k-x[i]];
}
}
}
ll ans =0;
rep(i,N+1){
if (i==0) continue;
ans += dp[N][i][i*A];
}
cout << ans << endl;
return 0;
}
|
a.cc:1:3: error: 'll' does not name a type
1 | ll N, A;
| ^~
a.cc:2:3: error: 'cin' does not name a type
2 | cin >> N >> A;
| ^~~
a.cc:3:3: error: 'vector' does not name a type
3 | vector<ll> x;
| ^~~~~~
a.cc:4:3: error: 'x' does not name a type
4 | x.pb(0);
| ^
a.cc:5:6: error: expected constructor, destructor, or type conversion before '(' token
5 | rep(i,N){
| ^
a.cc:10:6: error: expected constructor, destructor, or type conversion before '(' token
10 | rep(i,N)dp[i][0][0]=1;//0枚選んで合計0のやつが全部1通り
| ^
a.cc:12:3: error: expected unqualified-id before 'for'
12 | for(ll i =1;i<=N;i++){
| ^~~
a.cc:12:15: error: 'i' does not name a type
12 | for(ll i =1;i<=N;i++){
| ^
a.cc:12:20: error: 'i' does not name a type
12 | for(ll i =1;i<=N;i++){
| ^
a.cc:20:3: error: 'll' does not name a type
20 | ll ans =0;
| ^~
a.cc:21:6: error: expected constructor, destructor, or type conversion before '(' token
21 | rep(i,N+1){
| ^
a.cc:25:3: error: 'cout' does not name a type
25 | cout << ans << endl;
| ^~~~
a.cc:27:3: error: expected unqualified-id before 'return'
27 | return 0;
| ^~~~~~
a.cc:28:1: error: expected declaration before '}' token
28 | }
| ^
|
s477890086
|
p04015
|
C++
|
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
int n, a;
ll x[51];
ll dp[51][51][2501]; // i番目までのカードをj枚使って合計をkになるような選び方
cin >> n >> a;
for(int i = 0; i < n; i++) cin >> x[i];
dp[0][0][0] = 1;
for(int i = 0; i < n; i++){
for(int j = 0; j <= i; j++){
for(int k = 0; k <= n*a; k++){
dp[i+1][j+1][k+x[i]] += dp[i][j][k];
dp[i+1][j][k] += dp[i][j][k];
}
}
}
}
ll sum = 0;
for(int i = 1; i <= n; i++){
sum += dp[n][i][i*a];
}
cout << sum << endl;
return 0;
}
|
a.cc:24:3: error: expected unqualified-id before 'for'
24 | for(int i = 1; i <= n; i++){
| ^~~
a.cc:24:18: error: 'i' does not name a type
24 | for(int i = 1; i <= n; i++){
| ^
a.cc:24:26: error: 'i' does not name a type
24 | for(int i = 1; i <= n; i++){
| ^
a.cc:27:3: error: 'cout' does not name a type
27 | cout << sum << endl;
| ^~~~
a.cc:28:3: error: expected unqualified-id before 'return'
28 | return 0;
| ^~~~~~
a.cc:29:1: error: expected declaration before '}' token
29 | }
| ^
|
s642221364
|
p04015
|
C++
|
a#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7
__attribute__((constructor))
void initial() {
cin.tie(0);
ios::sync_with_stdio(false);
}
ll n, a, x[50] = {}, dp[51][51][2501] = {};
int main() {
cin >> n >> a;
for(int i = 0;i < n;i++){
cin >> x[i];
}
dp[0][0][0] = 1;
for(int i = 0;i < n;i++){
for(int j = 0;j < n;j++){
for(int k = 0;k <= 2500;k++){
dp[i+1][j][k] += dp[i][j][k];
if(k-x[i] >= 0)dp[i+1][j+1][k] += dp[i][j][k-x[i]];
}
}
}
ll ans = 0;
for(int i = 1;i <= n && i*a <= 2500;i++){
ans += dp[n][i][i*a];
}
cout << ans << endl;
}
|
a.cc:1:2: error: stray '#' in program
1 | a#include <bits/stdc++.h>
| ^
a.cc:1:1: error: 'a' does not name a type
1 | a#include <bits/stdc++.h>
| ^
a.cc: In function 'void initial()':
a.cc:13:3: error: 'cin' was not declared in this scope
13 | cin.tie(0);
| ^~~
a.cc:14:3: error: 'ios' has not been declared
14 | ios::sync_with_stdio(false);
| ^~~
a.cc: In function 'int main()':
a.cc:20:3: error: 'cin' was not declared in this scope
20 | cin >> n >> a;
| ^~~
a.cc:37:3: error: 'cout' was not declared in this scope
37 | cout << ans << endl;
| ^~~~
a.cc:37:18: error: 'endl' was not declared in this scope
37 | cout << ans << endl;
| ^~~~
|
s075579491
|
p04015
|
C++
|
#include <cstdio>
const int MAXN = 51;
const int ZERO = 2550;
const int MAXM = ZERO * 2;
typedef long long LL;
LL F[2][MAXM];
int main() {
int n, a, i, j, x;
scanf ( "%d%d", &n, &a );
F[0][ZERO] = 1;
for ( i = 1; i <= n; ++i ) {
scanf ( "%d", &x );
x -= A;
for ( j = MAXN; j + MAXN < MAXM; ++j )
F[i & 1][j] = F[ ( i - 1 ) & 1][j] + F[ ( i - 1 ) & 1][j - x];
}
printf ( "%lld\n", F[N & 1][ZERO] - 1 );
}
|
a.cc: In function 'int main()':
a.cc:13:22: error: 'A' was not declared in this scope
13 | x -= A;
| ^
a.cc:17:30: error: 'N' was not declared in this scope
17 | printf ( "%lld\n", F[N & 1][ZERO] - 1 );
| ^
|
s717032720
|
p04015
|
C++
|
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
ll dp[2501][55][55]={0};
int main(){
memset(dp,0,sizeof(dp));
int n,ave; cin>>n>>ave;
ll ans=0;
vi v;
for(int i=0; i<n;i++){
int gotiusa; cin>>gotiusa;
dp[gotiusa][i][1]+=1;
v.push_back(gotiusa);
}
for(int j=0; j<n-1;j++){
for(int k=1; k<51;k++){
for(int i=0; i<2501;i++){
if(!dp[i][j][k])continue;
dp[i][j+1][k]+=dp[i][j][k];
dp[i+v[j+1]][j+1][k+1]+=dp[i][j][k];
}
}
}
for(int i=0; i<2501;i++)
for(int k=1; k<51;k++){
if(dp[i][n-1][k]==0)continue;
else if(i/k==ave&&i%k==0){
ans+=dp[i][n-1][k];
//cout<<i<<" "<<k<<endl;
}
}
cout<<ans<<endl;
}
|
a.cc: In function 'int main()':
a.cc:47:5: error: 'memset' was not declared in this scope
47 | memset(dp,0,sizeof(dp));
| ^~~~~~
a.cc:23:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
22 | #include <stack>
+++ |+#include <cstring>
23 | #define vi vector<int>
|
s901210238
|
p04015
|
C++
|
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
ll dp[2501][55][55];
int main(){
memset(dp,0,sizeof(dp));
int n,ave; cin>>n>>ave;
ll ans=0;
vi v;
for(int i=0; i<n;i++){
int gotiusa; cin>>gotiusa;
dp[gotiusa][i][1]+=1;
v.push_back(gotiusa);
}
for(int j=0; j<n-1;j++){
for(int k=1; k<51;k++){
for(int i=0; i<2501;i++){
if(!dp[i][j][k])continue;
dp[i][j+1][k]+=dp[i][j][k];
dp[i+v[j+1]][j+1][k+1]+=dp[i][j][k];
}
}
}
for(int i=0; i<2501;i++)
for(int k=1; k<51;k++){
if(dp[i][n-1][k]==0)continue;
else if(i/k==ave&&i%k==0){
ans+=dp[i][n-1][k];
//cout<<i<<" "<<k<<endl;
}
}
cout<<ans<<endl;
}
|
a.cc: In function 'int main()':
a.cc:47:5: error: 'memset' was not declared in this scope
47 | memset(dp,0,sizeof(dp));
| ^~~~~~
a.cc:23:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
22 | #include <stack>
+++ |+#include <cstring>
23 | #define vi vector<int>
|
s983308424
|
p04015
|
C++
|
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int dp[2501][55][55];
int main(){
memset(dp,0,sizeof(dp));
int n,ave; cin>>n>>ave;
ll ans=0;
vi v;
for(int i=0; i<n;i++){
int gotiusa; cin>>gotiusa;
dp[gotiusa][i][1]+=1;
v.push_back(gotiusa);
}
for(int j=0; j<n-1;j++){
for(int k=1; k<51;k++){
for(int i=0; i<2501;i++){
if(!dp[i][j][k])continue;
dp[i][j+1][k]+=dp[i][j][k];
dp[i+v[j+1]][j+1][k+1]+=dp[i][j][k];
}
}
}
for(int i=0; i<2501;i++)
for(int k=1; k<51;k++){
if(dp[i][n-1][k]==0)continue;
else if(i/k==ave&&i%k==0){
ans+=dp[i][n-1][k];
//cout<<i<<" "<<k<<endl;
}
}
cout<<ans<<endl;
}
|
a.cc: In function 'int main()':
a.cc:47:5: error: 'memset' was not declared in this scope
47 | memset(dp,0,sizeof(dp));
| ^~~~~~
a.cc:23:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
22 | #include <stack>
+++ |+#include <cstring>
23 | #define vi vector<int>
|
s992724630
|
p04015
|
C++
|
#include <bits/stdc++.h>
#define REP(i, a, b) for (int i = a; i <= b; ++i)
#define PER(i, a, b) for (int i = a; i >= b; --i)
#define RVC(i, S) for (int i = 0; i < S.size(); ++i)
#define mp make_pair
#define pb push_back
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef vector<int> VI;
inline int read(){
int x = 0, ch = getchar(), f = 1;
while (!isdigit(ch)){if (ch == '-') f = -1; ch = getchar();}
while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
return x * f;
}
LL n, s;
VI tmp;
void check(LL x){
tmp.clear();
LL t = n;
while (t){
tmp.pb(t % x);
t /= x;
}
int sum = 0;
RVC(i, tmp) sum += tmp[i];
if (sum == s){
cout << x << endl;
exit(0);
}
}
int main(){
cin >> n >> s;
LL t;
if (n == s){
cout << n + 1 << endl;
return 0;
}
LL ans = 1ll << 60;
for (LL j, t = 1; t <= n; t = j + 1){
LL p = n / t;
j = n / p;
// cerr << p << endl;
if (n + p - s >= 0 && (n + p - s) % p == 0){
LL b = (n + p - s) / p;
if (0 <= p && p < b && 0 <= n - p * b && n - p * b < b){
ans = min(ans, b);
}
return 0;
}
}
if (ans == 1ll << 60){
cout << b << endl;
} else cout << -1 << endl;
return 0;
}
|
a.cc: In function 'int main()':
a.cc:63:25: error: 'b' was not declared in this scope
63 | cout << b << endl;
| ^
|
s049592247
|
p04015
|
Java
|
import java.util.*;
public class Main {
public static long takCards(int[] cards, int avg) {
ArrayList<Integer>[] cache = new ArrayList<Integer>[cards.length];
for (ArrayList<Integer> l : cache)
l = new ArrayList<Integer>();
long count = 0;
for (int i = 1; i <= cards.length; i++)
for (int j = 0; j < cards.length; j++){
ArrayList<Integer> curList = cache[i-1];
if (i == 1) {
curList.add(cards[j]);
if (cards[j] == avg)
count++;
}
else {
ArrayList<Integer> prevList = cache[i-2];
for (int k : prevList){
curList.add(k + cards[j]);
if (k+cards[j] == avg*i)
count++;
}
}
}
return count;
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String firstLine = scanner.nextLine();
String secondLine = scanner.nextLine();
String[] convertedFirst = firstLine.split("\\s+");
int avg = Integer.parseInt(convertedFirst[1]);
String[] convertedSecond = secondLine.split("\\s+");
int[] arr = new int[convertedSecond.length];
for (int i = 0; i < arr.length; i++) {
arr[i] = Integer.parseInt(convertedSecond[i]);
}
System.out.println(takCards(arr, avg));
}
}
|
Main.java:5: error: generic array creation
ArrayList<Integer>[] cache = new ArrayList<Integer>[cards.length];
^
1 error
|
s330784575
|
p04015
|
Java
|
import java.util.*;
public class Main {
public static takCards(int[] cards, int avg) {
ArrayList<Integer>[] cache = new ArrayList<Integer>[cards.length];
for (ArrayList<Integer> l : cache)
l = new ArrayList<Integer>();
long count = 0;
for (int i = 1; i <= cards.length; i++)
for (int j = 0; j < cards.length; j++){
ArrayList<Integer> curList = cache[i-1];
if (i == 1) {
curList.add(cards[j]);
if (cards[j] == avg)
count++;
}
else {
ArrayList<Integer> prevList = cache[i-2];
for (int k : prevList){
curList.add(k + cards[j]);
if (k+cards[j] == avg*i)
count++;
}
}
}
return count;
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String firstLine = scanner.nextLine();
String secondLine = scanner.nextLine();
String[] convertedFirst = firstLine.split("\\s+");
int avg = Integer.parseInt(convertedFirst[1]);
String[] convertedSecond = secondLine.split("\\s+");
int[] arr = new int[convertedSecond.length];
for (int i = 0; i < arr.length; i++) {
arr[i] = Integer.parseInt(convertedSecond[i]);
}
System.out.println(takCards(arr, avg));
}
}
|
Main.java:4: error: invalid method declaration; return type required
public static takCards(int[] cards, int avg) {
^
1 error
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.