submission_id stringlengths 10 10 | problem_id stringlengths 6 6 | language stringclasses 3
values | code stringlengths 1 522k | compiler_output stringlengths 43 10.2k |
|---|---|---|---|---|
s218648162 | p03703 | C++ | #include "bits/stdc++.h"
#include <sys/timeb.h>
#include <fstream>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) a.begin(),a.end()
#define mp make_pair
#define mt make_tuple
#define INF 2000000000
#define INFL 1000000000000000000LL
#define EPS 1e-9
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<P> vP;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<double> > vvd;
typedef vector<vector<P> > vvP;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<P, vector<P>, greater<P> > pqlP;
typedef pair<int, pair<int, int> > Edge;
typedef vector<Edge> vE;
typedef priority_queue<Edge, vector<Edge>, greater<Edge> > pqlE;
template<typename T>
using v = vector<T>;
int main() {
int N, K;
cin >> N >> K;
vll a(N);
vll sum(N + 1);
sum[0] = 0;
rep(i, N) {
cin >> a[i];
a[i] -= K;
sum[i + 1] = sum[i] + a[i];
}
vll pre;
ll ans = 0;
rep(i, N + 1) {
ans += upper_bound(all(pre), sum[i]) - pre.begin();
pre.insert(lower_bound(all(pre, sum[i]), sum[i]), sum[i]);
/*
rep(j, pre.size()) {
cout << pre[j] << ' ';
}cout << endl;
*/
}
cout << ans << endl;
return 0;
} | a.cc:63:55: error: macro "all" passed 2 arguments, but takes just 1
63 | pre.insert(lower_bound(all(pre, sum[i]), sum[i]), sum[i]);
| ^
a.cc:12:9: note: macro "all" defined here
12 | #define all(a) a.begin(),a.end()
| ^~~
a.cc: In function 'int main()':
a.cc:63:40: error: 'all' was not declared in this scope; did you mean 'std::filesystem::perms::all'?
63 | pre.insert(lower_bound(all(pre, sum[i]), sum[i]), sum[i]);
| ^~~
| std::filesystem::perms::all
In file included from /usr/include/c++/14/filesystem:51,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200,
from a.cc:1:
/usr/include/c++/14/bits/fs_fwd.h:158:7: note: 'std::filesystem::perms::all' declared here
158 | all = 0777,
| ^~~
|
s028894615 | p03704 | C++ | #include<bits/stdc++.h>
using namespace std;
long long d,ans,p[20]={1},dx1[20],dx2[20];
vector<long long> v;
void dfs(int nw,int num,vector<pair<long long,long long> >&w,long long val,long long cnt)
{
if(nw==num) {
w.push_back(make_pair(val,cnt));
return;
}
for(int i=-9;i<10;++i)
if(nw==0) dfs(nw+1,num,w,val+v[nw]*i,cnt*dx2[i+10]);
else dfs(nw+1,num,w,val+v[nw]*i,cnt*dx1[i+10]);
}
long long solve(int l)
{
v.clear();
for(int i=0;l-1-i>i;++i)
v.push_back(p[l-1-i]-p[i]);
vector<pair<long long,long long> > v1,v2;
dfs(0,(v.size()+1)/2,v1,0,1);
dfs((v.size()+1)/2,v.size(),v2,0,1);
long long tot=0;
map<long long,long long> mp;
for(int i=0;i<v2.size();++i)
mp[v2[i].first]+=v2[i].second;
for(int i=0;i<v1.size();++i)
tot+=mp[v1[i].first+d]*v1[i].second;
if(l%2) tot*=10;
return tot;
}
int main()
{
cin>>d;
if(d%9)
{
cout<<0;
return 0;
}
for(int i=1;i<20;++i) p[i]=p[i-1]*10;
for(int i=0;i<10;++i)
for(int j=0;j<10;++j)
{
++dx1[i-j+10];
if(i) ++dx2[i-j | a.cc: In function 'int main()':
a.cc:89:32: error: expected ']' at end of input
89 | if(i) ++dx2[i-j
| ^
| ]
a.cc:89:32: error: expected ';' at end of input
89 | if(i) ++dx2[i-j
| ^
| ;
a.cc:89:32: error: expected '}' at end of input
a.cc:85:10: note: to match this '{'
85 | {
| ^
a.cc:89:32: error: expected '}' at end of input
89 | if(i) ++dx2[i-j
| ^
a.cc:65:1: note: to match this '{'
65 | {
| ^
|
s906207172 | p03704 | C++ | #include <iostream>
#include <cstring>
using namespace std;
const int INF=0x3f3f3f3f;
//vector<int>v[maxn];
//map<int,string>mp[maxn];
//queue<int>q[maxn];
long long a[11][11],n,m,an[12],c[11][13],ans;
long long in;
long long abs(int x)
{
if(x<0)
return -x;
return x;
}
long long pow(int x,int y)
{
int sum=1;
for(int i=1;i<=y;i++)
sum*=x;
return sum;
}
string s;
void dfs(int D,int x,long long left)
{
int i;
if(left<0)
return;
// cout<<D<<" "<<x<<" "<<left<<endl;
if(x==D/2)
{
for(i=1;i<=D/2;i++)
an[i]=abs(an[i]);
an[x]=left/a[D][x];
if(left%a[D][x]!=0)
return;
//cout<<an[1]<<endl;
if(D%2==1)
{
long long sum=9-an[1];
// cout<<an[1]<<endl;
for(i=2;i<=D/2;i++)
{
// cout<<an[i]<<endl;
sum*=10-an[i];
}
sum*=10;
ans+=sum;
}
else
{
long long sum=9-an[1];
// cout<<an[1]<<endl;
for(i=2;i<=D/2;i++)
{
sum*=10-an[i];
// cout<<an[i]<<endl;
}
ans+=sum;
}
cout<<endl;
return;
}
for(i=-9;i<=9;i++)
{
//cout<<D<<" "<<x<<" "<<left<<endl;
an[x]=i;
dfs(D,x+1,left-a[D][x]*i);
an[x]=0;
}
}
int main()
{
int i,j,cnt=1;
cin>>s;
n=s.size();
for(i=s.size()-1;i>=0;i--)
{
in+=cnt*(s[i]-'0');
cnt*=10;
}
if(in%9!=0)
{
cout<<"0"<<endl;
return 0;
}
// cout<<n<<" "<<in<<endl;6
for(i=2;i<=10;i++)
{
int x=pow(10,i-1),y=1;
for(j=1;j<=i/2;j++)
{
a[i][j]=x-y;
x/=10;
y*=10;
}
}
for(i=2;i<=10;i++)
for(j=i/2;j>=1;j--)
c[i][j]=c[i][j+1]+a[i][j];
for(i=2;i<=n;i++)
{
memset(an,0,sizeof(an));
if(c[i][1]*9<in)
continue;
dfs(i,1,in);
}
cout<<ans<<endl;
return 0;
}
| a.cc:10:11: error: ambiguating new declaration of 'long long int abs(int)'
10 | long long abs(int x)
| ^~~
In file included from /usr/include/c++/14/cstdlib:79,
from /usr/include/c++/14/ext/string_conversions.h:43,
from /usr/include/c++/14/bits/basic_string.h:4154,
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/stdlib.h:980:12: note: old declaration 'int abs(int)'
980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
| ^~~
|
s543178685 | p03704 | C++ | #include<bits/stdc++.h>
#define int long long
using namespace std;
int d,ans;
int main()
{
cin>>d;
if(d%9)
{
cout<<0;
return 0;
}
d/=9;
return 0;
} | cc1plus: error: '::main' must return 'int'
|
s957499836 | p03704 | C++ | def solve(NUM):
s = str(NUM)
sz = len(str(NUM))
if s=='9':
return '12'
if s=='99':
return '102'
if(s[0]=='9'):
if(s[-1]=='9'):
for i in range(2,sz-1):
if(s[i]!=s[i-1]):
return -1
ans = '1'
for i in range(sz-1):
ans+='0'
ans+='2'
if s[1]==0:
ans = '11'+ans[2:]
return ans
if s[1]==9:
return ans
return -1
else:
return -1
for i in range(10**(sz-1),2*(10**(sz-1))):
ri = int(str(i)[::-1])
if i+NUM==ri:
return str(i)
return -1
D = int(input())
s = solve(D)
if s==-1:
print(0)
else:
n = len(s)
ans = 1
for i in range(n):
j = n-1-i
if j<i:
break
x = int(s[i])
y = int(s[j])
xy = max(x,y)
ans *= 10-xy
print(ans) | a.cc:5:16: warning: multi-character character constant [-Wmultichar]
5 | return '12'
| ^~~~
a.cc:6:11: warning: multi-character character constant [-Wmultichar]
6 | if s=='99':
| ^~~~
a.cc:7:16: warning: multi-character character constant [-Wmultichar]
7 | return '102'
| ^~~~~
a.cc:18:23: warning: multi-character character constant [-Wmultichar]
18 | ans = '11'+ans[2:]
| ^~~~
a.cc:1:1: error: 'def' does not name a type
1 | def solve(NUM):
| ^~~
|
s384591795 | p03704 | C++ | ce
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64
#endif
#include <limits.h>
#include <math.h>
#include <time.h>
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << '\n'
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
#define int long long
#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template <typename T1, typename T2> inline void chmin(T1& a, T2 b) {
if (a > b) a = b;
}
template <typename T1, typename T2> inline void chmax(T1& a, T2 b) {
if (a < b) a = b;
}
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 998244353;
constexpr int MAX = 500050;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll LINF = 1e18 + 1;
constexpr int INF = 1e18 + 1;
int test(int d) {
int ans = 0;
FOR(n, 1, 1e7) {
string s = to_string(n);
VREVERSE(s);
int r = stol(s);
if (r == n + d)ans++;
}
return ans;
}
ll f(ll A, ll t, int fir) {
if (t == 0)return A == 0;
int v = (A % 10 + 10) % 10;//Aの1の位
ll ret = 0;
//+ 0...v
ret += (10 - v - fir)*f((A - t * v) / 10, t / 100, 0);
//- v...9
ret += (v - fir)*f((A + (10 - v)*t) / 10, t / 100, 0);
return ret;
}
void solve() {
ll D; cin >> D;
if (D % 9) { print(0); return; }
D /= 9;
ll ret = 0;
ll p10 = 10;
FOR(i, 2, 19) {
p10 *= 10;
ll tot = (i % 2) ? 10 : 1;//桁数が奇数なら真ん中は何でも良いので×10
ret += tot * f(D, p10 / 10 / 9, 1);
}
print(ret);
}
signed main() {
cin.tie(0);
ios::sync_with_stdio(false);
mt.seed((int)(time(0)));
//int q;
//cin >> q;
//while (q--)
solve();
}
| a.cc:1:1: error: 'ce' does not name a type; did you mean 'pe'?
1 | ce
| ^~
| pe
|
s413788111 | p03704 | C++ | #include<iostream>
#include<cstring>
#include<vector>
using namespace std;
typedef long long LL;
const LL LEN = 6;
LL memo[LEN+1][2][2];
LL d[2*LEN+1];
vector<LL> valid[LEN+1][2][2];
LL s;
int dp(LL i, LL e, LL c)
{
if(!(0 <= e && e <= 1))
return 0;
if(i==s-i-1)
return memo[i][e][c] = c+d[i]==10*e ? 10 : 0;
if(memo[i][e][c]!=-1)
return memo[i][e][c];
if(i+1==s-i-1)
{
LL ans = 0;
for(LL y = 0; y <= 9; y++)
{
if(i==0 && y==0)
continue;
LL x9 = 9*y+10*d[i+1]+d[i]+c-100*e;
if(x9%9==0 && 0 <= x9/9 && x9/9 <= 9)
{
ans++;
valid[i][e][c].push_back(x9/9);
}
}
return memo[i][e][c] = ans;
}
LL ans = 0;
for(LL x = 0; x <= 9; x++)
{
LL y = (x+d[i]+c)%10;
if(i==0 && y==0)
continue;
LL c_ = (x+d[i]+c)/10;
LL e_ = 10*e+x-(y+d[s-i-1]);
ans += dp(i+1,e_,c_);
if(dp(i+1,e_,c_) > 0)
valid[i][e][c].push_back(x);
}
return memo[i][e][c] = ans;
}
LL n[2*LEN+1];
LL count = 0;
void reconstruct(LL i, LL e, LL c)
{
if(!(0 <= e && e <= 1))
return;
if(i > s-i-1)
{
cout<<(++count)<<": ";
for(LL j = s-1; j >= 0; j--)
cout<<n[j];
cout<<endl;
return;
}
if(i==s-i-1)
{
for(LL x = 0; x <= 9; x++)
{
n[i] = x;
reconstruct(i+1,e,c);
}
}
for(const LL& x : valid[i][e][c])
{
LL y = (x+d[i]+c)%10;
LL c_ = (x+d[i]+c)/10;
LL e_ = 10*e+x-(y+d[s-i-1]);
n[i] = x;
n[s-i-1] = y;
reconstruct(i+1,e_,c_);
}
}
LL main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
memset(d,0,sizeof d);
LL D; cin >> D;
for(LL i = 0; D > 0; i++, D/=10)
d[i] = D%10;
LL ans = 0;
for(s = 2; s <= 2*LEN; s++)
{
memset(memo,-1,sizeof memo);
ans += dp(0,0,0);
// if(dp(0,0,0) > 0)
// {
// cout<<dp(0,0,0)<<endl;
// reconstruct(0,0,0);
// }
}
cout<<ans<<endl;
cout<<flush;
return 0;
} | a.cc:81:1: error: '::main' must return 'int'
81 | LL main()
| ^~
|
s324966596 | p03704 | C++ | #include<iostream>
#include<cstring>
#include<vector>
using namespace std;
typedef long long LL;
const LL LEN = 6;
LL memo[LEN+1][2][2];
LL d[2*LEN+1];
vector<LL> valid[LEN+1][2][2];
LL s;
LL dp(LL i, LL e, LL c)
{
if(!(0 <= e && e <= 1))
return 0;
if(i==s-i-1)
return memo[i][e][c] = c+d[i]==10*e ? 10 : 0;
if(memo[i][e][c]!=-1)
return memo[i][e][c];
if(i+1==s-i-1)
{
LL ans = 0;
for(LL y = 0; y <= 9; y++)
{
if(i==0 && y==0)
continue;
LL x9 = 9*y+10*d[i+1]+d[i]+c-100*e;
if(x9%9==0 && 0 <= x9/9 && x9/9 <= 9)
{
ans++;
valid[i][e][c].push_back(x9/9);
}
}
return memo[i][e][c] = ans;
}
LL ans = 0;
for(LL x = 0; x <= 9; x++)
{
LL y = (x+d[i]+c)%10;
if(i==0 && y==0)
continue;
LL c_ = (x+d[i]+c)/10;
LL e_ = 10*e+x-(y+d[s-i-1]);
ans += dp(i+1,e_,c_);
if(dp(i+1,e_,c_) > 0)
valid[i][e][c].push_back(x);
}
return memo[i][e][c] = ans;
}
LL n[2*LEN+1];
LL count = 0;
void reconstruct(LL i, LL e, LL c)
{
if(!(0 <= e && e <= 1))
return;
if(i > s-i-1)
{
cout<<(++count)<<": ";
for(LL j = s-1; j >= 0; j--)
cout<<n[j];
cout<<endl;
return;
}
if(i==s-i-1)
{
for(LL x = 0; x <= 9; x++)
{
n[i] = x;
reconstruct(i+1,e,c);
}
}
for(const LL& x : valid[i][e][c])
{
LL y = (x+d[i]+c)%10;
LL c_ = (x+d[i]+c)/10;
LL e_ = 10*e+x-(y+d[s-i-1]);
n[i] = x;
n[s-i-1] = y;
reconstruct(i+1,e_,c_);
}
}
LL main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
memset(d,0,sizeof d);
LL D; cin >> D;
for(LL i = 0; D > 0; i++, D/=10)
d[i] = D%10;
LL ans = 0;
for(s = 2; s <= 2*LEN; s++)
{
memset(memo,-1,sizeof memo);
ans += dp(0,0,0);
// if(dp(0,0,0) > 0)
// {
// cout<<dp(0,0,0)<<endl;
// reconstruct(0,0,0);
// }
}
cout<<ans<<endl;
cout<<flush;
return 0;
} | a.cc:81:1: error: '::main' must return 'int'
81 | LL main()
| ^~
|
s252388000 | p03704 | C++ | #include<iostream>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<stack>
#include<unordered_map>
#include<bitset>
#include<limits>
#include<complex>
#include<array>
#include<numeric>
#include<functional>
using namespace std;
#define ll long long
#define ull unsigned long long
#define rrep(i,m,n) for(ll (i)=(ll)(m);(i)>=(ll)(n);(i)--)
#define rep(i,m,n) for(ll (i)=(ll)(m);i<(ll)(n);i++)
#define REP(i,n) rep(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
constexpr long double m_pi = 3.1415926535897932L;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1LL << 61;
constexpr long double EPS = 1e-10;
template<typename T> using vector2 = vector<vector<T>>;
template<typename T> using vector3 = vector<vector2<T>>;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
string operator*(const string& s, int k) {
if (k == 0) return "";
string p = (s + s) * (k / 2);
if (k % 2 == 1) p += s;
return p;
}
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
struct Edge {//グラフ
int to, rev; ll cap;
Edge(int _to, ll _cap, int _rev) {
to = _to; cap = _cap; rev = _rev;
}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
void add_edge(Graph& G, int from, int to, ll cap, bool revFlag, ll revCap) {//最大フロー求める Ford-fulkerson
G[from].push_back(Edge(to, cap, (ll)G[to].size()));
if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));//最小カットの場合逆辺は0にする
}
ll max_flow_dfs(Graph& G, ll v, ll t, ll f, vector<bool>& used)
{
if (v == t)
return f;
used[v] = true;
for (int i = 0; i < G[v].size(); ++i) {
Edge& e = G[v][i];
if (!used[e.to] && e.cap > 0) {
ll d = max_flow_dfs(G, e.to, t, min(f, e.cap), used);
if (d > 0) {
e.cap -= d;
G[e.to][e.rev].cap += d;
return d;
}
}
}
return 0;
}
//二分グラフの最大マッチングを求めたりも出来る また二部グラフの最大独立集合は頂点数-最大マッチングのサイズ
ll max_flow(Graph& G, ll s, ll t)//O(V(V+E))
{
ll flow = 0;
for (;;) {
vector<bool> used(G.size());
REP(i, used.size())used[i] = false;
ll f = max_flow_dfs(G, s, t, INF, used);
if (f == 0) {
return flow;
}
flow += f;
}
}
void BellmanFord(Graph& G, ll s, Array& d, Array& negative) {//O(|E||V|)
d.resize(G.size());
negative.resize(G.size());
REP(i, d.size())d[i] = INF;
REP(i, d.size())negative[i] = false;
d[s] = 0;
REP(k, G.size() - 1) {
REP(i, G.size()) {
REP(j, G[i].size()) {
if (d[i] != INF && d[G[i][j].to] > d[i] + G[i][j].cap) {
d[G[i][j].to] = d[i] + G[i][j].cap;
}
}
}
}
REP(k, G.size() - 1) {
REP(i, G.size()) {
REP(j, G[i].size()) {
if (d[i] != INF && d[G[i][j].to] > d[i] + G[i][j].cap) {
d[G[i][j].to] = d[i] + G[i][j].cap;
negative[G[i][j].to] = true;
}
if (negative[i] == true)negative[G[i][j].to] = true;
}
}
}
}
void Dijkstra(Graph& G, ll s, Array& d) {//O(|E|log|V|)
d.resize(G.size());
REP(i, d.size())d[i] = INF;
d[s] = 0;
priority_queue<P, vector<P>, greater<P>> q;
q.push(make_pair(0, s));
while (!q.empty()) {
P a = q.top();
q.pop();
if (d[a.second] < a.first)continue;
REP(i, G[a.second].size()) {
Edge e = G[a.second][i];
if (d[e.to] > d[a.second] + e.cap) {
d[e.to] = d[a.second] + e.cap;
q.push(make_pair(d[e.to], e.to));
}
}
}
}
void WarshallFloyd(Graph& G, Matrix& d) {//O(V^3)
d.resize(G.size());
REP(i, d.size())d[i].resize(G.size());
REP(i, d.size()) {
REP(j, d[i].size()) {
d[i][j] = ((i != j) ? INF : 0);
}
}
REP(i, G.size()) {
REP(j, G[i].size()) {
chmin(d[i][G[i][j].to], G[i][j].cap);
}
}
REP(i, G.size()) {
REP(j, G.size()) {
REP(k, G.size()) {
chmin(d[j][k], d[j][i] + d[i][k]);
}
}
}
}
bool tsort(Graph& graph, Array& order) {//トポロジカルソートO(E+V)
int n = graph.size(), k = 0;
Array in(n);
for (auto& es : graph)
for (auto& e : es)in[e.to]++;
priority_queue<ll, Array, greater<ll>> que;
REP(i, n)
if (in[i] == 0)que.push(i);
while (que.size()) {
int v = que.top();
que.pop();
order.push_back(v);
for (auto& e : graph[v])
if (--in[e.to] == 0)que.push(e.to);
}
if (order.size() != n)return false;
else return true;
}
class Lca {
public:
const int n = 0;
const int log2_n = 0;
std::vector<std::vector<int>> parent;
std::vector<int> depth;
Lca() {}
Lca(const Graph& g, int root)
: n(g.size()), log2_n(log2(n) + 1), parent(log2_n, std::vector<int>(n)), depth(n) {
dfs(g, root, -1, 0);
for (int k = 0; k + 1 < log2_n; k++) {
for (int v = 0; v < (int)g.size(); v++) {
if (parent[k][v] < 0)
parent[k + 1][v] = -1;
else
parent[k + 1][v] = parent[k][parent[k][v]];
}
}
}
void dfs(const Graph& g, int v, int p, int d) {
parent[0][v] = p;
depth[v] = d;
for (auto& e : g[v]) {
if (e.to != p) dfs(g, e.to, v, d + 1);
}
}
int get(int u, int v) {
if (depth[u] > depth[v]) std::swap(u, v);
for (int k = 0; k < log2_n; k++) {
if ((depth[v] - depth[u]) >> k & 1) {
v = parent[k][v];
}
}
if (u == v) return u;
for (int k = log2_n - 1; k >= 0; k--) {
if (parent[k][u] != parent[k][v]) {
u = parent[k][u];
v = parent[k][v];
}
}
return parent[0][u];
}
};
void visit(const Graph& g, int v, vector<vector<int>>& scc, stack<int>& S, vector<int>& inS, vector<int>& low,vector<int>& num, int& time) {
low[v] = num[v] = ++time;
S.push(v); inS[v] = true;
FOR(e, g[v]) {
int w = e->to;
if (num[w] == 0) {
visit(g, w, scc, S, inS, low, num, time);
low[v] = min(low[v], low[w]);
}
else if (inS[w])
low[v] = min(low[v], num[w]);
}
if (low[v] == num[v]) {
scc.push_back(vector<int>());
while (1) {
int w = S.top(); S.pop(); inS[w] = false;
scc.back().push_back(w);
if (v == w) break;
}
}
}
void stronglyConnectedComponents(const Graph& g, vector<vector<int>>& scc) {//強連結成分分解 O(E+V)
const int n = g.size();
vector<int> num(n), low(n);
stack<int> S;
vector<int> inS(n);
int time = 0;
REP(u, n) if (num[u] == 0)
visit(g, u, scc, S, inS, low, num, time);
}
class UnionFind {
vector<int> data;
ll num;
public:
UnionFind(int size) : data(size, -1), num(size) { }
bool unite(int x, int y) {//xとyの集合を統合する
x = root(x); y = root(y);
if (x != y) {
if (data[y] < data[x]) swap(x, y);
data[x] += data[y]; data[y] = x;
}
num -= (x != y);
return x != y;
}
bool findSet(int x, int y) {//xとyが同じ集合か返す
return root(x) == root(y);
}
int root(int x) {//xのルートを返す
return data[x] < 0 ? x : data[x] = root(data[x]);
}
ll size(int x) {//xの集合のサイズを返す
return -data[root(x)];
}
ll numSet() {//集合の数を返す
return num;
}
};
template<typename T, typename F>
class SegmentTree {
private:
T identity;
F merge;
ll n;
vector<T> dat;
public:
SegmentTree(F f, T id,vector<T> v) :merge(f), identity(id) {
int _n = v.size();
n = 1;
while (n < _n)n *= 2;
dat.resize(2 * n - 1, identity);
REP(i, _n)dat[n + i - 1] = v[i];
for (int i = n - 2; i >= 0; i--)dat[i] = merge(dat[i * 2 + 1], dat[i * 2 + 2]);
}
SegmentTree(F f, T id, int _n) :merge(f), identity(id) {
n = 1;
while (n < _n)n *= 2;
dat.resize(2 * n - 1, identity);
}
void set_val(int i, T x) {
i += n - 1;
dat[i] = x;
while (i > 0) {
i = (i - 1) / 2;
dat[i] = merge(dat[i * 2 + 1], dat[i * 2 + 2]);
}
}
T query(int l, int r) {
T left = identity, right = identity;
l += n - 1; r += n - 1;
while (l < r) {
if ((l & 1) == 0)left = merge(left, dat[l]);
if ((r & 1) == 0)right = merge(dat[r - 1], right);
l = l / 2;
r = (r - 1) / 2;
}
return merge(left, right);
}
};
class SumSegTree {
public:
ll n, height;
vector<ll> dat;
// 初期化(_nは最大要素数)
SumSegTree(ll _n) {
n = 1;
height = 1;
while (n < _n) {
n *= 2;
height++;
}
dat = vector<ll>(2 * n - 1, 0);
}
// 場所i(0-indexed)にxを足す
void add(ll i, ll x) {
i += n - 1; // i番目の葉ノードへ
dat[i] += x;
while (i > 0) { // 下から上がっていく
i = (i - 1) / 2;
dat[i] += x;
}
}
// 区間[l,r)の総和
ll sum(ll l, ll r) {
ll ret = 0;
l += n - 1; r += n - 1;
while (l < r) {
if ((l & 1) == 0)ret += dat[l];
if ((r & 1) == 0)ret += dat[r - 1];
l = l / 2;
r = (r - 1) / 2;
}
return ret;
}
};
class RmqTree {
private:
ll _find(ll a, ll b, ll k, ll l, ll r) {
if (r <= a || b <= l)return INF; // 交差しない
if (a <= l && r <= b)return dat[k]; // a,l,r,bの順で完全に含まれる
else {
ll s1 = _find(a, b, 2 * k + 1, l, (l + r) / 2); // 左の子
ll s2 = _find(a, b, 2 * k + 2, (l + r) / 2, r); // 右の子
return min(s1, s2);
}
}
public:
ll n, height;
vector<ll> dat;
// 初期化(_nは最大要素数)
RmqTree(ll _n) {
n = 1;
height = 1;
while (n < _n) {
n *= 2;
height++;
}
dat = vector<ll>(2 * n - 1, INF);
}
// 場所i(0-indexed)をxにする
void update(ll i, ll x) {
i += n - 1; // i番目の葉ノードへ
dat[i] = x;
while (i > 0) { // 下から上がっていく
i = (i - 1) / 2;
dat[i] = min(dat[i * 2 + 1], dat[i * 2 + 2]);
}
}
// 区間[a,b)の最小値。ノードk=[l,r)に着目している。
ll find(ll a, ll b) {
return _find(a, b, 0, 0, n);
}
};
//約数求める //約数
void divisor(ll n, vector<ll>& ret) {
for (ll i = 1; i * i <= n; i++) {
if (n % i == 0) {
ret.push_back(i);
if (i * i != n) ret.push_back(n / i);
}
}
sort(ret.begin(), ret.end());
}
void prime_factorization(ll n, vector<P>& ret) {
for (ll i = 2; i * i <= n; i++) {
if (n % i == 0) {
ret.push_back({ i,0 });
while (n % i == 0) {
n /= i;
ret[ret.size() - 1].second++;
}
}
}
if (n != 1)ret.push_back({ n,1 });
}
ll mod_pow(ll x, ll n, ll mod) {
ll res = 1;
while (n > 0) {
if (n & 1) res = res * x % mod;
x = x * x % mod;
n >>= 1;
}
return res;
}
ll mod_inv(ll x, ll mod) {
return mod_pow(x, mod - 2, mod);
}
class Combination {
public:
Array fact;
Array inv;
ll mod;
ll mod_inv(ll x) {
ll n = mod - 2LL;
ll res = 1LL;
while (n > 0) {
if (n & 1) res = res * x % mod;
x = x * x % mod;
n >>= 1;
}
return res;
}
//if n >= mod use lucas
ll nCr(ll n, ll r) {
if (n < r)return 0;
if (n < mod)return ((fact[n] * inv[r] % mod) * inv[n - r]) % mod;
ll ret = 1;
while (n || r) {
ll _n = n % mod, _r = r % mod;
n /= mod; r /= mod;
(ret *= nCr(_n, _r)) %= mod;
}
return ret;
}
ll nPr(ll n, ll r) {
return (fact[n] * inv[n - r]) % mod;
}
ll nHr(ll n, ll r) {
return nCr(r + n - 1, r);
}
Combination(ll _n, ll _mod) {
mod = _mod;
ll n = min(_n + 1, mod);
fact.resize(n);
fact[0] = 1;
REP(i, n - 1) {
fact[i + 1] = (fact[i] * (i + 1LL)) % mod;
}
inv.resize(n);
inv[n - 1] = mod_inv(fact[n - 1]);
for (int i = n - 1; i > 0; i--) {
inv[i - 1] = inv[i] * i % mod;
}
}
};
ll popcount(ll x) {
x = (x & 0x5555555555555555) + (x >> 1 & 0x5555555555555555);
x = (x & 0x3333333333333333) + (x >> 2 & 0x3333333333333333);
x = (x & 0x0F0F0F0F0F0F0F0F) + (x >> 4 & 0x0F0F0F0F0F0F0F0F);
x = (x & 0x00FF00FF00FF00FF) + (x >> 8 & 0x00FF00FF00FF00FF);
x = (x & 0x0000FFFF0000FFFF) + (x >> 16 & 0x0000FFFF0000FFFF);
x = (x & 0x00000000FFFFFFFF) + (x >> 32 & 0x00000000FFFFFFFF);
return x;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
ll d;
cin >> d;
if (d % 9 != 0) {
cout << 0 << "\n";
return 0;
}
d /= 9;
auto dfs = [](auto dfs, ll p, ll x, ll first)-> ll {
if (x == 0)return p == 0;
ll y = abs(p) % 10;
if (p < 0)y = 10 - y;
ll nxt = x / 100;
ll ret = 0;
ret += (10 - y - first) * dfs(dfs, (p - y * x) / 10, nxt, 0);
ret += (y - first) * dfs(dfs, (p + (10 - y) * x) / 10, nxt, 0);
return ret;
};
ll ans = 0;
rep(i, 2, 19) {
ll x = 1;
REP(j, i - 2)x = x * 10 + 1;
ans+= dfs(dfs, d, x, 1) * (i % 2 == 0 ? 1 : 10) << "\n";
}
cout << ans << "\n";
return 0;
} | a.cc: In function 'int main()':
a.cc:551:65: error: invalid operands of types 'long long int' and 'const char [2]' to binary 'operator<<'
551 | ans+= dfs(dfs, d, x, 1) * (i % 2 == 0 ? 1 : 10) << "\n";
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^~ ~~~~
| | |
| long long int const char [2]
|
s750468572 | p03704 | C++ |
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>
template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
if (lhs > rhs) {
lhs = rhs;
return true;
}
return false;
}
template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
if (lhs < rhs) {
lhs = rhs;
return true;
}
return false;
}
// [l, r) from l to r
struct range {
struct itr {
int i;
constexpr itr(int i_): i(i_) { }
constexpr void operator ++ () { ++i; }
constexpr int operator * () const { return i; }
constexpr bool operator != (itr x) const { return i != x.i; }
};
const itr l, r;
constexpr range(int l_, int r_): l(l_), r(std::max(l_, r_)) { }
constexpr itr begin() const { return l; }
constexpr itr end() const { return r; }
};
// [l, r) from r to l
struct revrange {
struct itr {
int i;
constexpr itr(int i_): i(i_) { }
constexpr void operator ++ () { --i; }
constexpr int operator * () const { return i; }
constexpr bool operator != (itr x) const { return i != x.i; }
};
const itr l, r;
constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
constexpr itr begin() const { return r; }
constexpr itr end() const { return l; }
};
template <class T>
struct fix_point: private T {
explicit constexpr fix_point(T &&func): T(std::forward<T>(func)) { }
template <class... Args>
constexpr decltype(auto) operator () (Args &&... args) const {
return T::operator()(*this, std::forward<Args>(args)...);
}
};
template <class T>
constexpr decltype(auto) make_fix_point(T &&func) {
return fix_point<T>{std::forward<T>(func)};
}
constexpr std::array<long long, 19> calc_pow10() {
std::array<long long, 19> res{};
res[0] = 1;
for (int i: range(1, 19)) {
res[i] = res[i - 1] * 10;
}
return res;
}
constexpr auto pow10 = calc_pow10();
constexpr std::array<std::array<long long, 19>, 19> calc_sum_max() {
std::array<std::array<long long, 19>, 19> res{};
for (int i: range(0, 19)) {
for (int j: revrange(0, i / 2)) {
res[i][j] += pow10[i - j - 1] - pow10[j];
res[i][j] += res[i][j + 1];
}
}
return res;
}
constexpr auto sum_max = calc_sum_max();
int main() {
int D;
std::cin >> D;
long long ans = 0;
for (int digit: range(2, 19)) {
ans += make_fix_point([&](auto dfs, long long cur, int d) -> long long {
int e = digit - d - 1;
if (d > e) {
return (cur == 0 ? 1 : 0);
}
if (d == e) {
return (cur == 0 ? 10 : 0);
}
if (std::abs(cur) > 9 * sum_max[digit][d]) {
return 0;
}
long long base = pow10[e] - pow10[d];
long long res = 0;
auto coeff = [&](int i) { return (d == 0 ? 9 - std::abs(i) : 10 - std::abs(i)); };
for (int i: range(-9, 10)) {
res += dfs(cur - base * i, d + 1) * coeff(i);
}
return res;
})(D, 0);
}
std::cout << ans << '\n';
return 0;
}
| a.cc:70:48: error: return type 'struct std::array<long long int, 19>' is incomplete
70 | constexpr std::array<long long, 19> calc_pow10() {
| ^
a.cc: In function 'constexpr void calc_pow10()':
a.cc:71:29: error: variable 'std::array<long long int, 19> res' has initializer but incomplete type
71 | std::array<long long, 19> res{};
| ^~~
a.cc:7:1: note: 'std::array' is defined in header '<array>'; this is probably fixable by adding '#include <array>'
6 | #include <numeric>
+++ |+#include <array>
7 |
a.cc: At global scope:
a.cc:79:16: error: deduced type 'const void' for 'pow10' is incomplete
79 | constexpr auto pow10 = calc_pow10();
| ^~~~~
a.cc:81:66: error: return type 'struct std::array<std::array<long long int, 19>, 19>' is incomplete
81 | constexpr std::array<std::array<long long, 19>, 19> calc_sum_max() {
| ^
a.cc: In function 'constexpr void calc_sum_max()':
a.cc:82:45: error: variable 'std::array<std::array<long long int, 19>, 19> res' has initializer but incomplete type
82 | std::array<std::array<long long, 19>, 19> res{};
| ^~~
a.cc:82:45: note: 'std::array' is defined in header '<array>'; this is probably fixable by adding '#include <array>'
a.cc: At global scope:
a.cc:92:16: error: deduced type 'const void' for 'sum_max' is incomplete
92 | constexpr auto sum_max = calc_sum_max();
| ^~~~~~~
|
s558418143 | p03704 | C++ | #include <cstdio>
#include <algorithm>
#define R register
#define ll long long
#define int long long
using namespace std;
ll base[40];
ll D;
ll ans=0;
ll st[40];
inline void dfs(int now,int len,ll sum){
if(now==len/2+1){
if(sum!=D) return;
ll tans=st[1]>=0?(9-st[1]):(9+st[1]);
for(R int i=2;i<now;i++) tans=tans*(st[i]>=0?(10-st[i]):(10+st[i]));
ans+=len&1?tans*10:tans;
return ;
}
if(sum+10ll*(base[len-now]-base[now-1])<D) return ;
if(sum-10ll*(base[len-now]-base[now-1])>D) return ;
for(R int ss=-9;ss<=9;ss++){
st[now]=ss;
dfs(now+1,len,sum+st[now]*(base[len-now]-base[now-1]));
}
return ;
}
signed main(){
cin>>D;
int tmp=0;ll d=D;
base[0]=1;
while(d) tmp++,d/=10;
for(R int i=1;i<=18;i++) base[i]=base[i-1]*10;
for(R int i=tmp;i<=18;i++) dfs(1,i,0);
cout<<ans<<endl;
return 0;
} | a.cc: In function 'void dfs(long long int, long long int, long long int)':
a.cc:15:27: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
15 | for(R int i=2;i<now;i++) tans=tans*(st[i]>=0?(10-st[i]):(10+st[i]));
| ^
a.cc:21:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
21 | for(R int ss=-9;ss<=9;ss++){
| ^~
a.cc: In function 'int main()':
a.cc:28:9: error: 'cin' was not declared in this scope
28 | cin>>D;
| ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
2 | #include <algorithm>
+++ |+#include <iostream>
3 | #define R register
a.cc:32:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
32 | for(R int i=1;i<=18;i++) base[i]=base[i-1]*10;
| ^
a.cc:33:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
33 | for(R int i=tmp;i<=18;i++) dfs(1,i,0);
| ^
a.cc:34:9: error: 'cout' was not declared in this scope
34 | cout<<ans<<endl;
| ^~~~
a.cc:34:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:34:20: error: 'endl' was not declared in this scope
34 | 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 <algorithm>
+++ |+#include <ostream>
3 | #define R register
|
s763072553 | p03704 | C++ | #include<bits/stdc++.h>
using namespace std;
#define f1(a,b,c) for(int c=a;c<=b;c++)
#define f2(a,b,c) for(int c=a;c>=b;c--)
#define f3(a,b,c) for(int c=a;c;c=b)
#define so1(a,n) sort(a+1,a+n+1,mycmp);
#define so2(a,n) sort(a+1,a+n+1);
#define re(a,n) reverse(a+1,a+n+1);
#define ll long long
#define itn int
#define ubt int
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
const int twx=+100;
const int inf=0x3f3f3f3f;
ll read()
{
ll sum=0;
ll flag=1;
char c=getchar();
while(c<'0'||c>'9')
{
if(c=='-')
{
flag=-1;
}
c=getchar();
}
while(c>='0'&&c<='9')
{
sum=((sum*10)+c-'0');
c=getchar();
}
return sum*flag;
}
ll POW[twx]={1,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000,10000000000,100000000000,1000000000000,10000000000000,100000000000000,1000000000000000,10000000000000000,100000000000000000,1000000000000000000};
ll d;
ll ans=0;
ll dfs(ll l,ll r,ll d)
{
if(l>=r)
{
if(d==0)
{
return l==r?10:1;
}
return 0;
}
if(d%10==0)
{
if(l!=1)
{
return 10*dfs(l+1,r-1,d/10);
}
return 9*dfs(l+1,r-1,d/10);
}
ll differ=d%10-10;//选取的数一定要使l位进1否则取反之后的必定小与改数,那么显然不可能。所以differ是d%10-10
ll Next=d-differ+differ*POW[r-l];//这里先让d进一位,然后由于对称性,r位+differ=l位+differ所以选择+differ*Power[r-l],这样才能满足对称条件
if(l==1)
{
return(9+differ)*dfs(l+1,r-1,abs(next)/10);
}
return(10+differ)*dfs(l+1,r-1,abs(next)/10);
}
void init()
{
d=read();
f1(2,18,i)
{
ans+=dfs(1,i,d);
}
printf("%lld\n",ans);
}
int main()
{
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
init();
return 0;
} | a.cc: In function 'long long int dfs(long long int, long long int, long long int)':
a.cc:62:41: error: no matching function for call to 'abs(<unresolved overloaded function type>)'
62 | return(9+differ)*dfs(l+1,r-1,abs(next)/10);
| ~~~^~~~~~
In file included from /usr/include/c++/14/valarray:605,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166,
from a.cc:1:
/usr/include/c++/14/bits/valarray_after.h:445:5: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_UnClos<std::_Abs, std::_ValArray, _Tp>, _Tp> std::abs(const valarray<_Tp>&)'
445 | _DEFINE_EXPR_UNARY_FUNCTION(abs, struct std::_Abs)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:445:5: note: template argument deduction/substitution failed:
a.cc:62:41: note: couldn't deduce template parameter '_Tp'
62 | return(9+differ)*dfs(l+1,r-1,abs(next)/10);
| ~~~^~~~~~
/usr/include/c++/14/bits/valarray_after.h:445:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_UnClos<std::_Abs, std::_Expr, _Dom>, typename _Dom::value_type> std::abs(const _Expr<_Dom1, typename _Dom1::value_type>&)'
445 | _DEFINE_EXPR_UNARY_FUNCTION(abs, struct std::_Abs)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:445:5: note: template argument deduction/substitution failed:
a.cc:62:41: note: couldn't deduce template parameter '_Dom'
62 | return(9+differ)*dfs(l+1,r-1,abs(next)/10);
| ~~~^~~~~~
In file included from /usr/include/c++/14/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/complex:892:5: note: candidate: 'template<class _Tp> _Tp std::abs(const complex<_Tp>&)'
892 | abs(const complex<_Tp>& __z) { return __complex_abs(__z.__rep()); }
| ^~~
/usr/include/c++/14/complex:892:5: note: template argument deduction/substitution failed:
a.cc:62:41: note: couldn't deduce template parameter '_Tp'
62 | return(9+differ)*dfs(l+1,r-1,abs(next)/10);
| ~~~^~~~~~
In file included from /usr/include/c++/14/cstdlib:79,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:42:
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
| ^~~
/usr/include/stdlib.h:980:21: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'int'
980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
| ~~~~^~~
In file included from /usr/include/c++/14/cstdlib:81:
/usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)'
137 | abs(__float128 __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:137:18: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to '__float128'
137 | abs(__float128 __x)
| ~~~~~~~~~~~^~~
/usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)'
85 | abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
| ^~~
/usr/include/c++/14/bits/std_abs.h:85:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to '__int128'
85 | abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
| ^
/usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
79 | abs(long double __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:79:19: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long double'
79 | abs(long double __x)
| ~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
75 | abs(float __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:75:13: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'float'
75 | abs(float __x)
| ~~~~~~^~~
/usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
71 | abs(double __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:71:14: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'double'
71 | abs(double __x)
| ~~~~~~~^~~
/usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
61 | abs(long long __x) { return __builtin_llabs (__x); }
| ^~~
/usr/include/c++/14/bits/std_abs.h:61:17: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long long int'
61 | abs(long long __x) { return __builtin_llabs (__x); }
| ~~~~~~~~~~^~~
/usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
56 | abs(long __i) { return __builtin_labs(__i); }
| ^~~
/usr/include/c++/14/bits/std_abs.h:56:12: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long int'
56 | abs(long __i) { return __builtin_labs(__i); }
| ~~~~~^~~
a.cc:64:38: error: no matching function for call to 'abs(<unresolved overloaded function type>)'
64 | return(10+differ)*dfs(l+1,r-1,abs(next)/10);
| ~~~^~~~~~
/usr/include/c++/14/bits/valarray_after.h:445:5: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_UnClos<std::_Abs, std::_ValArray, _Tp>, _Tp> std::abs(const valarray<_Tp>&)'
445 | _DEFINE_EXPR_UNARY_FUNCTION(abs, struct std::_Abs)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:445:5: note: template argument deduction/substitution failed:
a.cc:64:38: note: couldn't deduce template parameter '_Tp'
64 | return(10+differ)*dfs(l+1,r-1,abs(next)/10);
| ~~~^~~~~~
/usr/include/c++/14/bits/valarray_after.h:445:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_UnClos<std::_Abs, std::_Expr, _Dom>, typename _Dom::value_type> std::abs(const _Expr<_Dom1, typename _Dom1::value_type>&)'
445 | _DEFINE_EXPR_UNARY_FUNCTION(abs, struct std::_Abs)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:445:5: note: template argument deduction/substitution failed:
a.cc:64:38: note: couldn't deduce template parameter '_Dom'
64 | return(10+differ)*dfs(l+1,r-1,abs(next)/10);
| ~~~^~~~~~
/usr/include/c++/14/complex:892:5: note: candidate: 'template<class _Tp> _Tp std::abs(const complex<_Tp>&)'
892 | abs(const complex<_Tp>& __z) { return __complex_abs(__z.__rep()); }
| ^~~
/usr/include/c++/14/complex:892:5: note: template argument deduction/substitution failed:
a.cc:64:38: note: couldn't deduce template parameter '_Tp'
64 | return(10+differ)*dfs(l+1,r-1,abs(next)/10);
| ~~~^~~~~~
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
| ^~~
/usr/include/stdlib.h:980:21: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'int'
980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
| ~~~~^~~
/usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)'
137 | abs(__float128 __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:137:18: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to '__float128'
137 | abs(__float128 __x)
| ~~~~~~~~~~~^~~
/usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)'
85 | abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
| ^~~
/usr/include/c++/14/bits/std_abs.h:85:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to '__int128'
85 | abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
| ^
/usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
79 | abs(long double __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:79:19: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long double'
79 | abs(long double __x)
| ~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
75 | abs(float __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:75:13: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'float'
75 | abs(float __x)
| ~~~~~~^~~
/usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
71 | abs(double __x)
| ^~~
/usr/include/c++/14/bits/std_abs.h:71:14: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'double'
71 | abs(double __x)
| ~~~~~~~^~~
/usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
61 | abs(long long __x) { return __builtin_llabs (__x); }
| ^~~
/usr/include/c++/14/bits/std_abs.h:61:17: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long long int'
61 | abs(long long __x) { return __builtin_llabs (__x); }
| ~~~~~~~~~~^~~
/usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
56 | abs(long __i) { return __builtin_labs(__i); }
| ^~~
/usr/include/c++/14/bits/std_abs.h:56:12: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long int'
56 | abs(lo |
s625699293 | p03704 | C++ | #include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = __int128_t;
// using ll = int64_t;
using PLL = P<ll, ll>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename Head, typename... Tail> const Head& var_min(const Head &head, const Tail&... tail) { return min(head, var_min(tail...)); }
template <typename Head, typename... Tail> const Head& var_max(const Head &head, const Tail&... tail) { return max(head, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
void init_io() {
cin.tie(0);
ios_base::sync_with_stdio(false);
cout << fixed << setprecision(30);
}
istream& operator >>(istream &is, ll &a) {
int64_t i;
is >> i;
a = i;
return is;
}
ostream& operator <<(ostream &os, ll a) {
auto i = (int64_t)a;
os << i;
return os;
}
string to_string(ll a) {
string ret;
while(a) {
ll t = a % 10;
a /= 10;
ret += '0' + t;
}
reverse(ALL(ret));
return ret;
}
#define DEBUGGING
#ifdef DEBUGGING
#include "../debug.cpp"
#else
#define DEBUG(...) 0
#endif
V<ll> pow_10(17, 1);
ll dummy0[20] = {};
ll dummy1[20] = {};
ll *cnt_perm = dummy0 + 10;
ll *cnt_perm_ms = dummy1 + 10;
ll calc(ll val, ll dl, ll ds) {
ll *arr = (ds == 0 ? cnt_perm_ms : cnt_perm);
if(dl == ds) return arr[0] * (val == 0);
if(dl < ds) return val == 0;
if(to_string(abs(val)).size() > dl + 1) return 0;
ll mul = pow_10[dl] - pow_10[ds];
ll ret = 0;
for(ll j = -9; j <= 9; j++) {
ll nd = val - mul * j;
ll rec = calc(nd, dl - 1, ds + 1);
ret += rec * arr[j];
}
return ret;
}
int main() {
init_io();
for(ll i = 0; i <= 9; i++) for(ll j = 0; j <= 9; j++) cnt_perm[i - j]++;
for(ll i = 1; i <= 9; i++) for(ll j = 0; j <= 9; j++) cnt_perm_ms[i - j]++;
ll D;
cin >> D;
for(ll i = 1; i < pow_10.size(); i++) pow_10[i] = pow_10[i - 1] * 10;
ll ans = 0;
for(ll d = 1; d <= 18; d++) ans += calc(-D, d, 0);
cout << ans << endl;
return 0;
}
| a.cc:53:10: fatal error: ../debug.cpp: No such file or directory
53 | #include "../debug.cpp"
| ^~~~~~~~~~~~~~
compilation terminated.
|
s591323335 | p03704 | C++ | #include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename Head, typename... Tail> const Head& var_min(const Head &head, const Tail&... tail) { return min(head, var_min(tail...)); }
template <typename Head, typename... Tail> const Head& var_max(const Head &head, const Tail&... tail) { return max(head, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
void init_io() {
cin.tie(0);
ios_base::sync_with_stdio(false);
cout << fixed << setprecision(30);
}
#define DEBUGGING
#ifdef DEBUGGING
#include "../debug.cpp"
#else
#define DEBUG(...) 0
#endif
V<ll> pow_10(15, 1);
ll dummy0[20] = {};
ll dummy1[20] = {};
ll *cnt_perm = dummy0 + 10;
ll *cnt_perm_ms = dummy1 + 10;
ll calc(ll val, ll dl, ll ds) {
if(dl == ds) return 10 * (val == 0);
if(dl < ds) return val == 0;
if(to_string(abs(val)).size() > dl + 1) return 0;
ll mul = pow_10[dl] - pow_10[ds];
ll ret = 0;
for(ll j = -9; j <= 9; j++) {
ll nd = val - mul * j;
ll rec = calc(nd, dl - 1, ds + 1);
ll *arr = (ds == 0 ? cnt_perm_ms : cnt_perm);
ret += rec * arr[j];
}
return ret;
}
int main() {
init_io();
for(ll i = 0; i <= 9; i++) for(ll j = 0; j <= 9; j++) cnt_perm[i - j]++;
for(ll i = 1; i <= 9; i++) for(ll j = 0; j <= 9; j++) cnt_perm_ms[i - j]++;
ll D;
cin >> D;
for(ll i = 1; i < pow_10.size(); i++) pow_10[i] = pow_10[i - 1] * 10;
ll ans = 0;
for(ll d = 1; d <= 15; d++) ans += calc(-D, d, 0);
cout << ans << endl;
return 0;
}
| a.cc:28:10: fatal error: ../debug.cpp: No such file or directory
28 | #include "../debug.cpp"
| ^~~~~~~~~~~~~~
compilation terminated.
|
s066659247 | p03704 | C++ | #include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = (ll)(1e+9) + 7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
ll time10[20];
ll cnt[10];
void init() {
rep(i, 10) {
cnt[i] = 10 - i;
}
time10[0] = 1;
rep1(i, 19) {
time10[i] = time10[i - 1] * 10;
}
}
int main() {
init();
ll d; cin >> d;
ll ans = 0;
Rep1(i,2, 18) {
ll sum = 1; ll c = d;
rep1(j, i / 2) {
ll dif = time10[i - j] - time10[j - 1];
ll r = (c / time10[j - 1]) % 10; r = (r + 10) % 10;
ll t = 10 - r; if (t == 10)t = 0;
c -= t * dif;
if (abs(c) >= dif&&t!=0) {
c += 10 * dif;
t = 10 - t;
else sum *= cnt[t];
}
else {
if (j == 1)sum *= cnt[t] - 1;
else sum *= cnt[t];
}
}
if (i % 2)sum *= 10;
if(!c)ans += sum;
}
cout << ans << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:62:33: error: expected '}' before 'else'
62 | else sum *= cnt[t];
| ^~~~
a.cc:59:50: note: to match this '{'
59 | if (abs(c) >= dif&&t!=0) {
| ^
a.cc:64:25: error: 'else' without a previous 'if'
64 | else {
| ^~~~
a.cc:65:37: error: 'j' was not declared in this scope
65 | if (j == 1)sum *= cnt[t] - 1;
| ^
a.cc:65:55: error: 't' was not declared in this scope
65 | if (j == 1)sum *= cnt[t] - 1;
| ^
a.cc:66:49: error: 't' was not declared in this scope
66 | else sum *= cnt[t];
| ^
a.cc:69:21: error: 'i' was not declared in this scope
69 | if (i % 2)sum *= 10;
| ^
a.cc:69:27: error: 'sum' was not declared in this scope
69 | if (i % 2)sum *= 10;
| ^~~
a.cc:70:21: error: 'c' was not declared in this scope
70 | if(!c)ans += sum;
| ^
a.cc:70:30: error: 'sum' was not declared in this scope
70 | if(!c)ans += sum;
| ^~~
a.cc: At global scope:
a.cc:72:9: error: 'cout' does not name a type
72 | cout << ans << endl;
| ^~~~
a.cc:73:9: error: expected unqualified-id before 'return'
73 | return 0;
| ^~~~~~
a.cc:74:1: error: expected declaration before '}' token
74 | }
| ^
|
s235705854 | p03704 | C++ | #include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int d[30],len,dp[30][30][30];
int DP(int n){
int ret=0;
memset(dp,0,sizeof(dp));
dp[0][0][0]=1;
for(int i=0;i<(n>>1);i++)
for(int j=0;j<10;j++)
for(int k=0;k<10;k++)
if(dp[i][j][k])
for(int x=0;x<10;x++){
int l1=x+d[i+1]+k,y=l1%10,l2=10*j+x-y-d[n-i];
l1/=10;
if(l2<0||l2>9||(!i&&(!x||!y)))
continue;
dp[i+1][l2][l1]+=dp[i][j][k];
}
if(n&1){
int mid=(n+1)>>1;
for(int i=0;i<10;i++)
for(int j=0;j<10;j++)
if(dp[n>>1][i][j])
for(int x=0;x<10;x++){
int y=x+d[mid]+j;
if(x==y%10&&y/10==i)
ret+=dp[n>>1][i][j];
}
}
else
for(int i=0;i<10;i++)
ret+=dp[n>>1][i][i];
return ret;
}
int getans(){
int ret=0;
for(int i=max(2,len);i<=20;i++)
ret+=DP(i);
return ret;
}
void Input(){
char c;
do c=getchar();
while(!isdigit(c));
do{
d[++len]=c^48;
c=getchar();
}while(isdigit(c));
reverse(d+1,d+len+1);
return;
}
int main(){
Input();
printf("%d",getans());
return 0;
} | a.cc: In function 'void Input()':
a.cc:46:16: error: 'isdigit' was not declared in this scope
46 | while(!isdigit(c));
| ^~~~~~~
|
s505865847 | p03704 | C++ | #include<bits/stdc++.h>
using namespace std;
using Int = long long;
Int d;
Int ans=0;
auto getK=[&](Int x,Int k){
while(--k) x/=10;
return x%10;
}
void dfs(Int k,Int p,Int q,Int x,Int y){
if(p>q){
ans+=(x+d==y);
return;
}
if(p==q){
ans+=(x+d==y)*10;
return;
}
Int nk=k+1,np=p*10,nq=q/10;
for(Int i=0;i<10;i++){
Int nx=x+p*i,ny=y+q*i;
Int z=getK(nx+d,k);
nx+=q*z;
ny+=p*z;
if(z==0&&p==1) continue;
if(nx+d+q<ny) continue;
if(nx+d>ny+q) continue;
dfs(nk,np,nq,nx,ny);
}
};
//INSERT ABOVE HERE
signed main(){
cin>>d;
vector<Int> po(20,1);
for(Int i=0;i<18;i++) po[i+1]=po[i]*10;
for(Int i=1;i<18;i++) dfs(1,1,po[i],0,0);
cout<<ans<<endl;
return 0;
}
| a.cc:8:12: error: non-local lambda expression cannot have a capture-default
8 | auto getK=[&](Int x,Int k){
| ^
a.cc:13:1: error: expected ',' or ';' before 'void'
13 | void dfs(Int k,Int p,Int q,Int x,Int y){
| ^~~~
a.cc: In function 'int main()':
a.cc:40:25: error: 'dfs' was not declared in this scope; did you mean 'ffs'?
40 | for(Int i=1;i<18;i++) dfs(1,1,po[i],0,0);
| ^~~
| ffs
|
s267367531 | p03704 | C++ | #include<bits/stdc++.h>
using namespace std;
using Int = long long;
Int d;
Int ans=0;
auto getK=[&](Int x,Int k){
while(--k) x/=10;
return x%10;
};
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
void dfs(Int k,Int p,Int q,Int x,Int y){
if(p>q){
ans+=(x+d==y);
return;
}
if(p==q){
ans+=(x+d==y)*10;
return;
}
Int nk=k+1,np=p*10,nq=q/10;
int a=-1,b=-1:
for(Int i=0;i<10;i++){
Int nx=x+p*i,ny=y+q*i;
Int z=getK(nx+d,k);
nx+=q*z;
ny+=p*z;
if(z==0&&p==1) continue;
if(nx+d+q<ny) continue;
if(nx+d>ny+q) continue;
if(nx+d<=ny) a=i;
if(~b&&nx+d>=ny) b=i;
}
if(~a){
Int nx=x+p*a,ny=y+q*a;
Int z=getK(nx+d,k);
nx+=q*z;
ny+=p*z;
dfs(nk,np,nq,nx,ny);
}
if(~b){
Int nx=x+p*b,ny=y+q*b;
Int z=getK(nx+d,k);
nx+=q*z;
ny+=p*z;
dfs(nk,np,nq,nx,ny);
}
};
//INSERT ABOVE HERE
signed main(){
cin>>d;
vector<Int> po(20,1);
for(Int i=0;i<18;i++) po[i+1]=po[i]*10;
//dfs(1,1,po[16],0,0);
for(Int i=1;i<17;i++) dfs(1,1,po[i],0,0);
cout<<ans<<endl;
return 0;
}
| a.cc:8:12: error: non-local lambda expression cannot have a capture-default
8 | auto getK=[&](Int x,Int k){
| ^
a.cc: In function 'void dfs(Int, Int, Int, Int, Int)':
a.cc:28:16: error: expected ',' or ';' before ':' token
28 | int a=-1,b=-1:
| ^
a.cc:29:15: error: 'i' was not declared in this scope
29 | for(Int i=0;i<10;i++){
| ^
|
s155977561 | p03704 | C++ | #include<bits\stdc++.h>
#define fo(i,j,l) for(int i=j;i<=l;++i)
#define fd(i,j,l) for(int i=j;i>=l;--i)
using namespace std;
typedef long long ll;
ll D;
int y[100],x[100];
inline ll rev(ll o)
{
ll ans=0;
for(;o;o/=10)ans=ans*10+o%10;
return ans;
}
int main()
{
cin>>D;
ll cs=1,K=D,ans=0; int n=0;
for(;K%10==0;K/=10)cs=(cs<<3)+cs;
for(;K;K/=10)++n;
int half=(n+1)>>1,zs=1;
fo(r,1,half)zs*=10;
fo(r,1,zs-1)if(r%10&&(r+D)%10){
ll u=r;
fd(i,n,n-half+1)y[i]=u%10,u/=10;
u=r+D;
fo(i,1,half)x[i]=u%10,u/=10;
if(half*2!=n)
if(x[half]!=y[half])continue;
fo(i,1,half-(half*2!=n))y[i]=x[i];
ll maybe=0;
fo(i,1,n)maybe=maybe*10+y[i];
if(rev(maybe)==maybe+D)++ans;
}
cout<<ans*cs;
} | a.cc:1:9: fatal error: bits\stdc++.h: No such file or directory
1 | #include<bits\stdc++.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
|
s741366050 | p03704 | C++ | #include<stdio.h>
#include<stdlib.h>
#define ll long long
const int Inf=1e9+10;
int gi(){
int sum=0,f=1;char ch=getchar();
while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
while(ch<='9' && ch>='0'){sum=sum*10+ch-'0';ch=getchar();}
return sum*f;
}
int d;
ll ans;
int main(){
freopen("terr.in","r",stdin);
freopen("terr.out","w",stdout);
int i,j,k,n,m;
scanf("%d",&d);
if(d%9){
puts("0");
return 0;
}
d/=9;
ll len=1,ini=0;
for(i=1;i<=18;i++)
sm[i]=sm[i-1]*10;
for(i=1;i<=17;i++){
ll tmp=1,D=d;
ini=ini*10+1;
ll base=ini,lten=len,rten=1;
for(int j=0;j<=(i>>1);j++){
tmp*=10-abs(D%(rten*10)/rten)-(!j?1:0);
D-=base*(D%(rten*10)/rten);
base-=lten+rten;
lten/=10;rten*=10;
}
len*=10;
if(!D)ans+=tmp;
}
printf("%lld\n",ans);
return 0;
}
| a.cc: In function 'int main()':
a.cc:25:17: error: 'sm' was not declared in this scope; did you mean 'm'?
25 | sm[i]=sm[i-1]*10;
| ^~
| m
|
s093352149 | p03704 | C++ | #include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
typedef long long LL;
using namespace std;
LL mi10[20]={1,10,1e+2,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13,1e14,1e15,1e16,1e17};
LL a[10];
int l;
int cnt;
void dfs(int x,LL d,int c){
if (x>l){
if (d==0)cnt+=c;
return;
}
if (d>=1ll*a[x]*10||d<=-1ll*a[x]*10)return;
fo(i,1,9){
if (x==1)dfs(x+1,d-1ll*i*a[x],c*(9-i));
else dfs(x+1,d-1ll*i*a[x],c*(10-i));
}
if (x==1)dfs(x+1,d,c*9);
else dfs(x+1,d,c*10);
fo(i,-9,-1){
if (x==1)dfs(x+1,d-1ll*i*a[x],c*(9+i));
else dfs(x+1,d-1ll*i*a[x],c*(10+i));
}
}
int main(){
int d;
scanf("%d",&d);
int ans=0;
for(int len=2;len<=18;len++){
for(int i=1;i<=len/2;i++)a[i]=mi10[len-i]-mi10[i-1];
l=len/2;
cnt=0;
dfs(1,d,1);
if (len&1)cnt=cnt*10;
ans=ans+cnt;
}
printf("%d\n",ans);
return 0;
} | a.cc:12:19: error: narrowing conversion of '1.0e+2' from 'double' to 'LL' {aka 'long long int'} [-Wnarrowing]
12 | LL mi10[20]={1,10,1e+2,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13,1e14,1e15,1e16,1e17};
| ^~~~
a.cc:12:24: error: narrowing conversion of '1.0e+3' from 'double' to 'LL' {aka 'long long int'} [-Wnarrowing]
12 | LL mi10[20]={1,10,1e+2,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13,1e14,1e15,1e16,1e17};
| ^~~
a.cc:12:28: error: narrowing conversion of '1.0e+4' from 'double' to 'LL' {aka 'long long int'} [-Wnarrowing]
12 | LL mi10[20]={1,10,1e+2,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13,1e14,1e15,1e16,1e17};
| ^~~
a.cc:12:32: error: narrowing conversion of '1.0e+5' from 'double' to 'LL' {aka 'long long int'} [-Wnarrowing]
12 | LL mi10[20]={1,10,1e+2,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13,1e14,1e15,1e16,1e17};
| ^~~
a.cc:12:36: error: narrowing conversion of '1.0e+6' from 'double' to 'LL' {aka 'long long int'} [-Wnarrowing]
12 | LL mi10[20]={1,10,1e+2,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13,1e14,1e15,1e16,1e17};
| ^~~
a.cc:12:40: error: narrowing conversion of '1.0e+7' from 'double' to 'LL' {aka 'long long int'} [-Wnarrowing]
12 | LL mi10[20]={1,10,1e+2,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13,1e14,1e15,1e16,1e17};
| ^~~
a.cc:12:44: error: narrowing conversion of '1.0e+8' from 'double' to 'LL' {aka 'long long int'} [-Wnarrowing]
12 | LL mi10[20]={1,10,1e+2,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13,1e14,1e15,1e16,1e17};
| ^~~
a.cc:12:48: error: narrowing conversion of '1.0e+9' from 'double' to 'LL' {aka 'long long int'} [-Wnarrowing]
12 | LL mi10[20]={1,10,1e+2,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13,1e14,1e15,1e16,1e17};
| ^~~
a.cc:12:52: error: narrowing conversion of '1.0e+10' from 'double' to 'LL' {aka 'long long int'} [-Wnarrowing]
12 | LL mi10[20]={1,10,1e+2,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13,1e14,1e15,1e16,1e17};
| ^~~~
a.cc:12:57: error: narrowing conversion of '1.0e+11' from 'double' to 'LL' {aka 'long long int'} [-Wnarrowing]
12 | LL mi10[20]={1,10,1e+2,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13,1e14,1e15,1e16,1e17};
| ^~~~
a.cc:12:62: error: narrowing conversion of '1.0e+12' from 'double' to 'LL' {aka 'long long int'} [-Wnarrowing]
12 | LL mi10[20]={1,10,1e+2,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13,1e14,1e15,1e16,1e17};
| ^~~~
a.cc:12:67: error: narrowing conversion of '1.0e+13' from 'double' to 'LL' {aka 'long long int'} [-Wnarrowing]
12 | LL mi10[20]={1,10,1e+2,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13,1e14,1e15,1e16,1e17};
| ^~~~
a.cc:12:72: error: narrowing conversion of '1.0e+14' from 'double' to 'LL' {aka 'long long int'} [-Wnarrowing]
12 | LL mi10[20]={1,10,1e+2,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13,1e14,1e15,1e16,1e17};
| ^~~~
a.cc:12:77: error: narrowing conversion of '1.0e+15' from 'double' to 'LL' {aka 'long long int'} [-Wnarrowing]
12 | LL mi10[20]={1,10,1e+2,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13,1e14,1e15,1e16,1e17};
| ^~~~
a.cc:12:82: error: narrowing conversion of '1.0e+16' from 'double' to 'LL' {aka 'long long int'} [-Wnarrowing]
12 | LL mi10[20]={1,10,1e+2,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13,1e14,1e15,1e16,1e17};
| ^~~~
a.cc:12:87: error: narrowing conversion of '1.0e+17' from 'double' to 'LL' {aka 'long long int'} [-Wnarrowing]
12 | LL mi10[20]={1,10,1e+2,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13,1e14,1e15,1e16,1e17};
| ^~~~
|
s377465497 | p03704 | C++ | #include <iostream>
#include <cstdio>
#define my_abs(x) ((x) < 0 ? -(x) : (x))
using namespace std;
typedef long long ll;
ll ans, fact[25];
int arr[25];
inline void chk(int len)
{
// cout << len << " ";
// for (int i = 0; i <= len - 1 >> 1; i++)
// printf("%d", arr[i]);
// printf("\n");
ll res = 9 - my_abs(arr[0]);
for (int i = 1; i <= len - 1 >> 1; i++)
res *= 10 - my_abs(arr[i]);
ans += res;
}
void dfs(int cur, int len, ll rem)
{
if (cur == len >> 1)
{
if (!rem)
{
arr[cur] = 0;
chk(len);
}
return;
}
ll diff = fact[len - cur - 1] - fact[cur];
// cout << cur << " " << len << " " << fact[len - cur - 1] << " " << fact[cur] << endl;
ll r = (rem + diff - 1) / diff, l = rem / diff;
if (-9 <= r && r <= 9)
{
arr[cur] = r;
dfs(cur + 1, len, rem - diff * r);
}
if (l != r && -9 <= l && l <= 9)
{
arr[cur] = l;
dfs(cur + 1, len, rem - diff * l);
}
}
int main()
{
// freopen("ARC075-D.in", "r", stdin);
ll d, x = 1;
int len = 0;
scanf("%lld", &d);
while (x <= d)
{
x *= 10;
len++;
}
fact[0] = 1;
for (int i = 1; i <= 18; i++)
fact[i] = fact[i - 1] * 10;
for (int cnt = len; cnt <= len << 1; cnt++)
{
memset(arr, 0, sizeof(arr));
dfs(0, cnt, d);
}
printf("%lld\n", ans);
return 0;
}
| a.cc: In function 'int main()':
a.cc:60:17: error: 'memset' was not declared in this scope
60 | memset(arr, 0, sizeof(arr));
| ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
2 | #include <cstdio>
+++ |+#include <cstring>
3 | #define my_abs(x) ((x) < 0 ? -(x) : (x))
|
s162692222 | p03704 | C++ | ll D;
ll hoge(ll A,ll t,int first) {
if(t==0) return A==0;
int v=(A%10+10)%10;
ll ret=0;
ret+=(10-v-first)*hoge((A-t*v)/10,t/100,0);
ret+=(v-first)*hoge((A+(10-v)*t)/10,t/100,0);
return ret;
}
void solve() {
int i,j,k,l,r,x,y; string s;
cin>>D;
if(D%9) return _P("0\n");
D/=9;
ll ret=0;
ll p10=10;
for(i=2;i<=18;i++) {
p10*=10;
ll tot=(i%2)?10:1;
ret += tot*hoge(D,p10/10/9,1);
}
cout<<ret<<endl;
} | a.cc:1:1: error: 'll' does not name a type
1 | ll D;
| ^~
a.cc:3:1: error: 'll' does not name a type
3 | ll hoge(ll A,ll t,int first) {
| ^~
a.cc: In function 'void solve()':
a.cc:13:28: error: 'string' was not declared in this scope
13 | int i,j,k,l,r,x,y; string s;
| ^~~~~~
a.cc:15:9: error: 'cin' was not declared in this scope
15 | cin>>D;
| ^~~
a.cc:15:14: error: 'D' was not declared in this scope
15 | cin>>D;
| ^
a.cc:16:24: error: '_P' was not declared in this scope
16 | if(D%9) return _P("0\n");
| ^~
a.cc:18:9: error: 'll' was not declared in this scope; did you mean 'l'?
18 | ll ret=0;
| ^~
| l
a.cc:19:11: error: expected ';' before 'p10'
19 | ll p10=10;
| ^~~~
| ;
a.cc:21:17: error: 'p10' was not declared in this scope
21 | p10*=10;
| ^~~
a.cc:23:19: error: expected ';' before 'tot'
23 | ll tot=(i%2)?10:1;
| ^~~~
| ;
a.cc:24:17: error: 'ret' was not declared in this scope
24 | ret += tot*hoge(D,p10/10/9,1);
| ^~~
a.cc:24:24: error: 'tot' was not declared in this scope
24 | ret += tot*hoge(D,p10/10/9,1);
| ^~~
a.cc:24:28: error: 'hoge' was not declared in this scope
24 | ret += tot*hoge(D,p10/10/9,1);
| ^~~~
a.cc:26:9: error: 'cout' was not declared in this scope
26 | cout<<ret<<endl;
| ^~~~
a.cc:26:15: error: 'ret' was not declared in this scope
26 | cout<<ret<<endl;
| ^~~
a.cc:26:20: error: 'endl' was not declared in this scope
26 | cout<<ret<<endl;
| ^~~~
|
s299867378 | p03704 | C++ | #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
ll ppow[15];
int main() {
ppow[0] = 1;
for (int i = 1; i < 15; i++)ppow[i] = ppow[i - 1] * 10;
ll D; scanf("%lld", &D);
ll ans = 0;
rep(a, 10)rep(b, 10) {
if ((ppow[9] - ppow[8])*(a - b) == D)ans += 9 * ppow[7];
if ((ppow[9] - ppow[7])*(a - b) == D)ans += 9 * ppow[7];
if (b && (ppow[1] - ppow[0])*(a - b) == D)ans++;
if (b && (ppow[2] - ppow[0])*(a - b) == D)ans += 10;
rep(c, 10)rep(d, 10) {
if ((ppow[9] - ppow[6])*(a - b) + (ppow[8] - ppow[7])*(c - d) == D)ans += 9 * ppow[5];
if ((ppow[9] - ppow[5])*(a - b) + (ppow[8] - ppow[6])*(c - d) == D)ans += 9 * ppow[5];
if (b && (ppow[3] - ppow[0])*(a - b) + (ppow[2] - ppow[1])*(c - d) == D)ans++;
if (b && (ppow[4] - ppow[0])*(a - b) + (ppow[3] - ppow[1])*(c - d) == D)ans += 10;
rep(e, 10)rep(f, 10) {
if ((ppow[9] - ppow[4])*(a - b) + (ppow[8] - ppow[5])*(c - d) + (ppow[7] - ppow[6])*(e - f) == D)ans += 9 * ppow[3];
if ((ppow[9] - ppow[3])*(a - b) + (ppow[8] - ppow[4])*(c - d) + (ppow[7] - ppow[5])*(e - f) == D)ans += 9 * ppow[3];
if (b && (ppow[5] - ppow[0])*(a - b) + (ppow[4] - ppow[1])*(c - d) + (ppow[3] - ppow[2])*(e - f) == D)ans++;
if (b && (ppow[6] - ppow[0])*(a - b) + (ppow[5] - ppow[1])*(c - d) + (ppow[4] - ppow[2])*(e - f) == D)ans += 10;
rep(g, 10)rep(h, 10) {
if ((ppow[9] - ppow[2])*(a - b) + (ppow[8] - ppow[3])*(c - d) + (ppow[7] - ppow[4])*(e - f) + (ppow[6] - ppow[5])*(g - h) == D)ans += 9;
if ((ppow[9] - ppow[3])*(a-b)
if (b && (ppow[7] - ppow[0])*(a - b) + (ppow[6] - ppow[1])*(c - d) + (ppow[5] - ppow[2])*(e - f) + (ppow[4] - ppow[3])*(g - h) == D)ans++;
if (b && (ppow[8] - ppow[0])*(a - b) + (ppow[7] - ppow[1])*(c - d) + (ppow[6] - ppow[2])*(e - f) + (ppow[5] - ppow[3])*(g - h) == D)ans += 10;
rep(i,10)rep(j,10){
}
}
}
}
}
printf("%lld\n", ans);
} | a.cc: In function 'int main()':
a.cc:29:70: error: expected ';' before 'if'
29 | if ((ppow[9] - ppow[3])*(a-b)
| ^
| ;
30 | if (b && (ppow[7] - ppow[0])*(a - b) + (ppow[6] - ppow[1])*(c - d) + (ppow[5] - ppow[2])*(e - f) + (ppow[4] - ppow[3])*(g - h) == D)ans++;
| ~~
a.cc:31:41: error: expected primary-expression before 'if'
31 | if (b && (ppow[8] - ppow[0])*(a - b) + (ppow[7] - ppow[1])*(c - d) + (ppow[6] - ppow[2])*(e - f) + (ppow[5] - ppow[3])*(g - h) == D)ans += 10;
| ^~
a.cc:30:179: error: expected ')' before 'if'
30 | if (b && (ppow[7] - ppow[0])*(a - b) + (ppow[6] - ppow[1])*(c - d) + (ppow[5] - ppow[2])*(e - f) + (ppow[4] - ppow[3])*(g - h) == D)ans++;
| ^
| )
31 | if (b && (ppow[8] - ppow[0])*(a - b) + (ppow[7] - ppow[1])*(c - d) + (ppow[6] - ppow[2])*(e - f) + (ppow[5] - ppow[3])*(g - h) == D)ans += 10;
| ~~
a.cc:29:44: note: to match this '('
29 | if ((ppow[9] - ppow[3])*(a-b)
| ^
|
s019212088 | p03704 | C++ | #include<iostream>
#include<queue>
#include<cstdint>
using namespace std;
int rev(int x, int y); // x桁におけるy番目の倍数を求める
int main() {
int D, digit = 0, num, num2, pai;
int64_t count = 0;
queue<pair<int, int64_t> > paturn;
pair<int, int64_t> pat;
cin >> D;
for (int i = D;i > 0;i /= 10) digit ++;
// cout << "digit:" << digit << endl;
for (int i = digit;i <= digit * 2;i ++) { // D~Dの桁の2倍まで
paturn.push(make_pair(0, i % 2 ? 10 : 1));
for (int j = 0;j < i / 2;j ++) { // その桁における組み合わせ数
for (int k = 0;k < pow(2, j);k ++) { // queueの中身
pat = paturn.front();
num = pat.first;
paturn.pop();
pai = (D - num) / rev(i, j); // 最も近い差の値
num2 = num + pai * rev(i, j); // 最も近い差
// cout << "test:" << num2 << "(" << pat.second * (10 - abs(pai) - (j ? 0 : 1)) << ")" << endl;
paturn.push(make_pair(num2, pat.second * (10 - abs(pai) - (j ? 0 : 1))));
if (num2 > D) pai --;
else pai ++;
num2 = num + pai * rev(i, j);
// cout << "test2:" << num2 << "(" << pat.second * (10 - abs(pai) - (j ? 0 : 1)) << ")" << endl;
paturn.push(make_pair(num2, pat.second * (10 - abs(pai) - (j ? 0 : 1))));
}
}
while (!paturn.empty()) {
pat = paturn.front();;
paturn.pop();
if (pat.first == D) count += pat.second;
}
}
cout << count;
return 0;
}
int rev(int x, int y) {
int ret = 0;
for (int i = 0;i < x - y * 2 - 1;i ++) {
ret *= 10;
ret += 9;
}
for (int i = 0;i < y;i ++) {
ret *= 10;
}
return ret;
}
/*
2桁:9(a-b)
3桁:99(a-c)
4桁:999(a-d)+90(b-c)
5桁:9999(a-e)+990(b-d)
6桁:99999(a-f)+9990(b-e)+900(c-d)
…
あるDについて、Dの桁の2倍まで確認する必要がある
この時組み合わせは使う桁の半分(端数切捨て)個ある
*/ | a.cc: In function 'int main()':
a.cc:19:44: error: 'pow' was not declared in this scope
19 | for (int k = 0;k < pow(2, j);k ++) { // queueの中身
| ^~~
|
s053269018 | p03704 | C++ | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<ll,ll>loe,ano,ple;
set<ll>s;
ll d,n=1,o,ans;
ll iabs(ll x)
{
return x<0?-x:x;
}
ll dfs(ll use,ll rest)
{
ll k=ple[(rest%10+10)%10];
if(use<=0)
{
if(rest)
return 0;
else
return 1+(o&1)*9;
}
if(abs(rest)/abs(use)>9)
return 0;
if(k)
{
if(ano[k]<ano[10-k])
return ano[k]*dfs(use/100,(rest-k*use)/10)
else
return ano[10-k]*dfs(use/100,(rest+(10-k)*use)/10);
}
else
return ano[0]*dfs(use/100,rest/10);
}
ll logi(ll use,ll rest)
{
ll k=ple[(rest%10+10)%10];
if(use<=0)
{
if(rest)
return 0;
else
return 1+(o&1)*9;
}
if(abs(rest)/abs(use)>9)
return 0;
if(k)
{
if(loe[k]<loe[10-k])
return loe[k]*dfs(use/100,(rest-k*use)/10)
else
return loe[k-10]*dfs(use/100,(rest+(10-k)*use)/10);
}
else
return loe[0]*dfs(use/100,rest/10);
}
int main(void)
{
//freopen("data4.in","r",stdin);
//freopen("data.out","w",stdout);
ll t=1;
//scanf("%lld",&t);
for(ll i=-8; i<9; i++)
loe[i]=9-iabs(i);
for(ll i=-9; i<10; i++)
ano[i]=10-iabs(i);
for(ll i=0; i<10; i++)
ple[i*9%10]=i;
while(t--)
{
o=0;
ans=0;
n=1;
scanf("%lld",&d);
for(ll i=1; i<=18; i++)
{
o++;
ans+=logi(n-1,d);
n*=10;
}
cout<<ans<<endl;
}
} | a.cc: In function 'll dfs(ll, ll)':
a.cc:26:67: error: expected ';' before 'else'
26 | return ano[k]*dfs(use/100,(rest-k*use)/10)
| ^
| ;
27 | else
| ~~~~
a.cc: In function 'll logi(ll, ll)':
a.cc:48:67: error: expected ';' before 'else'
48 | return loe[k]*dfs(use/100,(rest-k*use)/10)
| ^
| ;
49 | else
| ~~~~
|
s715245181 | p03704 | C++ | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<ll,ll>loe,ano,ple;
set<ll>s;
ll d,n=1,o,ans;
ll iabs(ll x)
{
return x<0?-x:x;
}
ll dfs(ll use,ll rest)
{
ll k=ple[(rest%10+10)%10];
if(use<=0)
{
if(rest)
return 0;
else
return 1+(o&1)*9;
}
if(abs(rest)/abs(use)>9)
return 0;
if(k)
return (k<10-k)*ano[k]*dfs(use/100,(rest-k*use)/10)+(k>=10-k)ano[k-10]*dfs(use/100,(rest+(10-k)*use)/10);
else
return ano[0]*dfs(use/100,rest/10);
}
ll logi(ll use,ll rest)
{
ll k=ple[(rest%10+10)%10];
if(use<=0)
{
if(rest)
return 0;
else
return 1+(o&1)*9;
}
if(abs(rest)/abs(use)>9)
return 0;
if(k)
{
return (k<10-k)*loe[k]*dfs(use/100,(rest-k*use)/10)+(k>=10-k)*loe[k-10]*dfs(use/100,(rest+(10-k)*use)/10);
}
else
return loe[0]*dfs(use/100,rest/10);
}
int main(void)
{
//freopen("data4.in","r",stdin);
//freopen("data.out","w",stdout);
ll t=1;
//scanf("%lld",&t);
for(ll i=-8; i<9; i++)
loe[i]=9-iabs(i);
for(ll i=-9; i<10; i++)
ano[i]=10-iabs(i);
for(ll i=0; i<10; i++)
ple[i*9%10]=i;
while(t--)
{
o=0;
ans=0;
n=1;
scanf("%lld",&d);
for(ll i=1; i<=18; i++)
{
o++;
ans+=logi(n-1,d);
n*=10;
}
cout<<ans<<endl;
}
} | a.cc: In function 'll dfs(ll, ll)':
a.cc:24:78: error: expected ';' before 'ano'
24 | return (k<10-k)*ano[k]*dfs(use/100,(rest-k*use)/10)+(k>=10-k)ano[k-10]*dfs(use/100,(rest+(10-k)*use)/10);
| ^~~
| ;
a.cc:25:9: error: 'else' without a previous 'if'
25 | else
| ^~~~
|
s692186097 | p03704 | C++ | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<ll,ll>loe,ano,ple;
set<ll>s;
ll d,n=1,o;
ll iabs(ll x)
{
return x<0?-x:x;
}
ll dfs(ll use,ll rest)
{
ll k=ple[rest%10];
if(use<=0)
{
if(rest)
return 0;
else
return 1+(o&1&&o!=1)*9;
}
if(k)
return ano[k]*dfs((use+1)/100-1,(rest-k*use)/10)+ano[k-10]*dfs((use+1)/100-1,(rest+(10-k)*use)/10);
else
return ano[0]*dfs((use+1)/100-1,rest/10);
}
ll logi(ll use,ll rest)
{
ll k=ple[rest%10];
if(use<=0)
{
if(rest)
return 0;
else
return 1+(o&1&&o!=1)*9;
}
if(k)
return loe[k]*dfs((use+1)/100-1,(rest-k*use)/10)+loe[k-10]*dfs((use+1)/100-1,(rest+(10-k)*use)/10);
else
return loe[0]*dfs((use+1)/100-1,rest/10);
}
int main(void)
{
for(ll i=-8; i<9; i++)
loe[i]=9-iabs(i);
for(ll i=-9; i<10; i++)
ano[i]=10-iabs(i);
for(ll i=0; i<10; i++)
ple[i*9%10]=i;
scanf("%lld",&d);
while(n<d)
n*=10,o++;
n--;
n/=10;
cout<<logi(n,d);
}v | a.cc:55:2: error: 'v' does not name a type
55 | }v
| ^
|
s825590653 | p03704 | C++ | #include <cmath>
#include <algorithm>
#include <numeric>
#include <string>
using u8t = std::uint64_t;
using i8t = std::int64_t;
#define F(I,N) for(i8t I=0,_N=N;I<_N;I++)
#define R(V) i8t V;std::cin>>V;
#define RV(V,N) std::vector<i8t> V;F(i,N){R(x)V.push_back(x);}
#define RL1(line) std::getline(std::cin,line);
#define RL(line) std::string line;RL0(line)
#define P(X) std::cout<<(X)<<std::endl;
i8t ipow10(i8t x){i8t r=1;F(i,x)r*=10;return r;}
int main() {
R(D);
i8t count = 0;
//i8t dmin = std::ceil(std::log10(D/9+1)+1);//P(dmin);
for(i8t d=2;d<=18;d++){
i8t Dmin=(d&1? 99: 9)*(ipow10(d/2-1));
//std::cout<<d<<":"<<Dmin<<std::endl;
if(D<Dmin&&(d&1)==0)break;
i8t poss = 1;
auto Drest = D;
for(i8t i=0;i<d/2;i++){
i8t mod = ipow10(d-1-2*i)-1;
i8t lsb = (Drest>=0?Drest:-Drest)%10;
i8t c = (10-lsb)%10;
if(Drest>=0){
Drest -= c*mod;
poss *= (i==0? 9: 10) - c;
}else{
Drest += c*mod;
poss *= 10-c;
}
if(poss<=0||Drest%10!=0){poss=0;break;}
Drest/=10;
}
if((d&1)&&d>1)poss*=10;
if(Drest)poss=0;
count+=poss;
}
P(count);
return 0;
} | a.cc:5:18: error: 'uint64_t' in namespace 'std' does not name a type; did you mean 'wint_t'?
5 | using u8t = std::uint64_t;
| ^~~~~~~~
| wint_t
a.cc:6:18: error: 'int64_t' in namespace 'std' does not name a type
6 | using i8t = std::int64_t;
| ^~~~~~~
a.cc:13:1: error: 'i8t' does not name a type; did you mean 'int'?
13 | i8t ipow10(i8t x){i8t r=1;F(i,x)r*=10;return r;}
| ^~~
| int
a.cc: In function 'int main()':
a.cc:8:14: error: 'i8t' was not declared in this scope; did you mean 'int'?
8 | #define R(V) i8t V;std::cin>>V;
| ^~~
a.cc:15:3: note: in expansion of macro 'R'
15 | R(D);
| ^
a.cc:8:25: error: 'cin' is not a member of 'std'
8 | #define R(V) i8t V;std::cin>>V;
| ^~~
a.cc:15:3: note: in expansion of macro 'R'
15 | R(D);
| ^
a.cc:5:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
4 | #include <string>
+++ |+#include <iostream>
5 | using u8t = std::uint64_t;
a.cc:15:5: error: 'D' was not declared in this scope
15 | R(D);
| ^
a.cc:8:30: note: in definition of macro 'R'
8 | #define R(V) i8t V;std::cin>>V;
| ^
a.cc:16:6: error: expected ';' before 'count'
16 | i8t count = 0;
| ^~~~~~
| ;
a.cc:18:10: error: expected ';' before 'd'
18 | for(i8t d=2;d<=18;d++){
| ^~
| ;
a.cc:18:15: error: 'd' was not declared in this scope
18 | for(i8t d=2;d<=18;d++){
| ^
a.cc:19:8: error: expected ';' before 'Dmin'
19 | i8t Dmin=(d&1? 99: 9)*(ipow10(d/2-1));
| ^~~~~
| ;
a.cc:21:10: error: 'Dmin' was not declared in this scope; did you mean 'fmin'?
21 | if(D<Dmin&&(d&1)==0)break;
| ^~~~
| fmin
a.cc:22:8: error: expected ';' before 'poss'
22 | i8t poss = 1;
| ^~~~~
| ;
a.cc:24:12: error: expected ';' before 'i'
24 | for(i8t i=0;i<d/2;i++){
| ^~
| ;
a.cc:24:17: error: 'i' was not declared in this scope
24 | for(i8t i=0;i<d/2;i++){
| ^
a.cc:25:10: error: expected ';' before 'mod'
25 | i8t mod = ipow10(d-1-2*i)-1;
| ^~~~
| ;
a.cc:26:10: error: expected ';' before 'lsb'
26 | i8t lsb = (Drest>=0?Drest:-Drest)%10;
| ^~~~
| ;
a.cc:27:10: error: expected ';' before 'c'
27 | i8t c = (10-lsb)%10;
| ^~
| ;
a.cc:29:18: error: 'c' was not declared in this scope
29 | Drest -= c*mod;
| ^
a.cc:29:20: error: 'mod' was not declared in this scope; did you mean 'modf'?
29 | Drest -= c*mod;
| ^~~
| modf
a.cc:30:9: error: 'poss' was not declared in this scope
30 | poss *= (i==0? 9: 10) - c;
| ^~~~
a.cc:32:18: error: 'c' was not declared in this scope
32 | Drest += c*mod;
| ^
a.cc:32:20: error: 'mod' was not declared in this scope; did you mean 'modf'?
32 | Drest += c*mod;
| ^~~
| modf
a.cc:33:9: error: 'poss' was not declared in this scope
33 | poss *= 10-c;
| ^~~~
a.cc:35:10: error: 'poss' was not declared in this scope
35 | if(poss<=0||Drest%10!=0){poss=0;break;}
| ^~~~
a.cc:38:19: error: 'poss' was not declared in this scope
38 | if((d&1)&&d>1)poss*=10;
| ^~~~
a.cc:39:14: error: 'poss' was not declared in this scope
39 | if(Drest)poss=0;
| ^~~~
a.cc:40:5: error: 'count' was not declared in this scope; did you mean 'std::count'?
40 | count+=poss;
| ^~~~~
| std::count
In file included from /usr/include/c++/14/algorithm:86,
from a.cc:2:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: 'std::count' declared here
101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
| ^~~~~
a.cc:40:12: error: 'poss' was not declared in this scope
40 | count+=poss;
| ^~~~
a.cc:12:19: error: 'cout' is not a member of 'std'
12 | #define P(X) std::cout<<(X)<<std::endl;
| ^~~~
a.cc:42:3: note: in expansion of macro 'P'
42 | P(count);
| ^
a.cc:12:19: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
12 | #define P(X) std::cout<<(X)<<std::endl;
| ^~~~
a.cc:42:3: note: in expansion of macro 'P'
42 | P(count);
| ^
a.cc:42:5: error: 'count' was not declared in this scope; did you mean 'std::count'?
42 | P(count);
| ^~~~~
a.cc:12:26: note: in definition of macro 'P'
12 | #define P(X) std::cout<<(X)<<std::endl;
| ^
/usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: 'std::count' declared here
101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
| ^~~~~
a.cc:12:35: error: 'endl' is not a member of 'std'
12 | #define P(X) std::cout<<(X)<<std::endl;
| ^~~~
a.cc:42:3: note: in expansion of macro 'P'
42 | P(count);
| ^
a.cc:5:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
4 | #include <string>
+++ |+#include <ostream>
5 | using u8t = std::uint64_t;
|
s567199694 | p03704 | C++ | #include <bits/stdc++.h>
using namespace std;
ll bs[20];
ll D,calc0[20], calc[20];
ll a[20],an,ans;
void dfs(int x,ll v,ll c)
{
if(x == an)
{
ans += (v == D) * c;
return;
}
if(abs(v - D) > a[x] * 20)return;
for(int i = 0;i<20;i++)
{
int cnt;
if(!x) cnt = calc0[i];
else cnt = calc[i];
if(!a[x])cnt = i < 10;
if(!cnt) continue;
dfs(x + 1, v + (i - 10) * a[x], c * cnt);
}
}
void solve(int n)
{
an = 0;
for(int i = 0; i < n; i ++)
{
if(i > n - i - 1)break;
a[an ++] = bs[n - i - 1] - bs[i];
}
dfs(0, 0, 1);
}
int main()
{
for(int i = 0; i <= 9; i ++)
for(int j = 0; j <= 9; j ++)
calc[i - j + 10] ++;
for(int i = 0; i <= 9; i ++)
for(int j = 1; j <= 9; j ++)
calc0[i - j + 10] ++;
bs[0] = 1;
for(int i = 1; i < 19; i ++)
bs[i] = bs[i - 1] * 10;
cin >> D;
for(int i = 1; i <= 19; i ++)
solve(i);
cout<<ans<<endl;
return 0;
}
| a.cc:3:1: error: 'll' does not name a type
3 | ll bs[20];
| ^~
a.cc:4:1: error: 'll' does not name a type
4 | ll D,calc0[20], calc[20];
| ^~
a.cc:5:1: error: 'll' does not name a type
5 | ll a[20],an,ans;
| ^~
a.cc:6:16: error: 'll' has not been declared
6 | void dfs(int x,ll v,ll c)
| ^~
a.cc:6:21: error: 'll' has not been declared
6 | void dfs(int x,ll v,ll c)
| ^~
a.cc: In function 'void dfs(int, int, int)':
a.cc:8:17: error: 'an' was not declared in this scope; did you mean 'yn'?
8 | if(x == an)
| ^~
| yn
a.cc:10:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
10 | ans += (v == D) * c;
| ^~~
| abs
a.cc:10:30: error: 'D' was not declared in this scope
10 | ans += (v == D) * c;
| ^
a.cc:13:20: error: 'D' was not declared in this scope
13 | if(abs(v - D) > a[x] * 20)return;
| ^
a.cc:13:25: error: 'a' was not declared in this scope
13 | if(abs(v - D) > a[x] * 20)return;
| ^
a.cc:17:30: error: 'calc0' was not declared in this scope
17 | if(!x) cnt = calc0[i];
| ^~~~~
a.cc:18:28: error: 'calc' was not declared in this scope
18 | else cnt = calc[i];
| ^~~~
a.cc:19:21: error: 'a' was not declared in this scope
19 | if(!a[x])cnt = i < 10;
| ^
a.cc:21:43: error: 'a' was not declared in this scope
21 | dfs(x + 1, v + (i - 10) * a[x], c * cnt);
| ^
a.cc: In function 'void solve(int)':
a.cc:26:9: error: 'an' was not declared in this scope; did you mean 'n'?
26 | an = 0;
| ^~
| n
a.cc:30:17: error: 'a' was not declared in this scope
30 | a[an ++] = bs[n - i - 1] - bs[i];
| ^
a.cc:30:28: error: 'bs' was not declared in this scope; did you mean 'abs'?
30 | a[an ++] = bs[n - i - 1] - bs[i];
| ^~
| abs
a.cc: In function 'int main()':
a.cc:38:25: error: 'calc' was not declared in this scope
38 | calc[i - j + 10] ++;
| ^~~~
a.cc:42:25: error: 'calc0' was not declared in this scope
42 | calc0[i - j + 10] ++;
| ^~~~~
a.cc:44:9: error: 'bs' was not declared in this scope; did you mean 'abs'?
44 | bs[0] = 1;
| ^~
| abs
a.cc:47:16: error: 'D' was not declared in this scope
47 | cin >> D;
| ^
a.cc:50:15: error: 'ans' was not declared in this scope; did you mean 'abs'?
50 | cout<<ans<<endl;
| ^~~
| abs
|
s349727106 | p03704 | C++ | #include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }
const ll INF = 0x3fffffff;
ll pow(int n,unsigned int m,int q=1e9+7){ //n^m%q
if(m==0) return 1;
ll tmp = pow(n,m/2,q);
return ((tmp*tmp)%q)*(m%2?n:1)%q;
}
ll rev(ll N){
ll ret = 0;
while( N ){
ret = ret*10 + N%10;
N /= 10;
}
return ret;
}
int main(){
//ios_base::sync_with_stdio(0);
ll D, rD;
cin >> D;
rD = rev(D);
int K = 0;
while( pow(10,(double)K) < D ) K++;
set<ll> ans;
rep(k,K/2+2) rep(u,K/2+2) rep(i,pow(10,k+1)){
ll res = (i + D);
ll n = 0;
rep(j,u){
n = n*10 + res%10;
res /= 10;
}
n = n*pow(10,k) + (i % pow(10,k));
if( rev(n) == n+D ) ans.insert(n);
if( rev(n+D) == n+D + D ) ans.insert(n+D);
}
cout << ans.size() << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:57:38: error: invalid operands of types 'int' and '__gnu_cxx::__promote<double>::__type' {aka 'double'} to binary 'operator%'
57 | n = n*pow(10,k) + (i % pow(10,k));
| ~ ^ ~~~~~~~~~
| | |
| int __gnu_cxx::__promote<double>::__type {aka double}
|
s944951677 | p03704 | C++ | #include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef vector<pr> Vpr;
typedef pair<ut,ut> prs;
const int SIZE=2005;
const LL p=7+1e9;
const LL INF=1<<30;
const LL INFLL=1LL<<30;
inline void IN(ut &x){cin >> x;}
inline void INA(ut n,ut x[]){REP(i,n) cin >> x[i];}
inline void INE(ut m,VI edges[]){
ut a,b;
REP(i,m){
cin >> a >> b;
edges[a].PB(b);
edges[b].PB(a);
}
}
inline void INEC(ut m,Vpr edges[]){
ut a,b,c;
REP(i,m){
cin >> a >> b >> c;
edges[a].PB(pr(c,b));
edges[b].PB(pr(c,a));
}
}
LL es[20];
LL solve(LL D,LL s,LL t){
if(s==t) return (D==0)*10;
else if(s>t) return D==0;
LL dia=10;
if(s==0) dia--;
LL ans=0;
if(t>=11) ans+=solve(dia-abs(0))*solve(D),s+1,t-1);
else FOR(i,-9,10){
if(dia==9 && i<0) continue;
ans+=(dia-abs(i))*solve(D+(es[s]*i-es[t]*i),s+1,t-1);
// cout << ans<< " "<< D << " " << i <<" " << s << " "<< t<< endl;
}
return ans;
}
string rev(string s){
reverse(ALL(s));
return s;
}
int main(){
LL D;
cin >> D;
//FOR(D,1,10000){
LL ans=0;
es[0]=1;
FOR(i,1,20) es[i]=es[i-1]*10;
FOR(i,1,20) ans+=solve(D,0,i);
int c=0;
REP(i,100000) if(stoi(rev(to_string(i)))-i ==D) c++;
if(c!=ans or D%100==0){
cout << c <<" " << ans << " " << D<< endl;
//cout << ans << endl;
}
//}
return 0;
} | a.cc: In function 'LL solve(LL, LL, LL)':
a.cc:44:29: error: too few arguments to function 'LL solve(LL, LL, LL)'
44 | if(t>=11) ans+=solve(dia-abs(0))*solve(D),s+1,t-1);
| ~~~~~^~~~~~~~~~~~
a.cc:38:4: note: declared here
38 | LL solve(LL D,LL s,LL t){
| ^~~~~
a.cc:44:47: error: too few arguments to function 'LL solve(LL, LL, LL)'
44 | if(t>=11) ans+=solve(dia-abs(0))*solve(D),s+1,t-1);
| ~~~~~^~~
a.cc:38:4: note: declared here
38 | LL solve(LL D,LL s,LL t){
| ^~~~~
|
s626674311 | p03704 | C++ |
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }
const ll INF = 0x3fffffff;
ll rev(ll N){
ll ret = 0;
while( N ){
ret = ret*10 + N%10;
N /= 10;
}
return ret;
}
int main(){
//ios_base::sync_with_stdio(0);
ll D, rD;
cin >> D;
rD = rev(D);
int K = 0;
while( pow(10,(double)K) < D ) K++;
set<ll> ans;
rep(k,K/2+2) rep(u,K/2+2) rep(i,pow(10,(double)k)){
ll res = (i + D);
ll n = 0;
rep(j,u){
n = n*10 + res%10;
res /= 10;
}
n = n*pow(10,(double)k) + (i % (ll)pow(10,(double)k));
if( rev(n) == n+D ) ans.insert(n);
}
cout << ans.size() << endl;
return 0;
}
| a.cc:13:9: error: 'pair' does not name a type
13 | typedef pair<int,int> pii;
| ^~~~
a.cc:14:9: error: 'pair' does not name a type
14 | typedef pair<ll,ll> pll;
| ^~~~
a.cc:19:19: error: 'size_t' has not been declared
19 | template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }
| ^~~~~~
a.cc:19:55: error: 'N' was not declared in this scope
19 | template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }
| ^
a.cc:19:43: error: variable or field 'Fill' declared void
19 | template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }
| ^~~~
a.cc:19:52: error: 'a' was not declared in this scope
19 | template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }
| ^
a.cc:19:55: error: 'N' was not declared in this scope
19 | template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }
| ^
a.cc:19:59: error: expected primary-expression before 'const'
19 | template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }
| ^~~~~
a.cc: In function 'int main()':
a.cc:36:9: error: 'cin' was not declared in this scope
36 | cin >> D;
| ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
+++ |+#include <iostream>
1 |
a.cc:40:16: error: 'pow' was not declared in this scope
40 | while( pow(10,(double)K) < D ) K++;
| ^~~
a.cc:42:9: error: 'set' was not declared in this scope
42 | set<ll> ans;
| ^~~
a.cc:1:1: note: 'std::set' is defined in header '<set>'; this is probably fixable by adding '#include <set>'
+++ |+#include <set>
1 |
a.cc:42:15: error: expected primary-expression before '>' token
42 | set<ll> ans;
| ^
a.cc:42:17: error: 'ans' was not declared in this scope
42 | set<ll> ans;
| ^~~
a.cc:43:41: error: 'pow' was not declared in this scope
43 | rep(k,K/2+2) rep(u,K/2+2) rep(i,pow(10,(double)k)){
| ^~~
a.cc:2:34: note: in definition of macro 'rep'
2 | #define rep(i,n) for(int i=0; i<(n); i++)
| ^
a.cc:54:9: error: 'cout' was not declared in this scope
54 | cout << ans.size() << endl;
| ^~~~
a.cc:54:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:54:31: error: 'endl' was not declared in this scope
54 | cout << ans.size() << endl;
| ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
+++ |+#include <ostream>
1 |
|
s045044167 | p03705 | C++ | #include <bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
ll N, A, B;
cin >> N >> A >> B;
if(A > B) {
cout << 0 << endl;
}
else if(N == 2) {
cout << 1 << endl;
}
else if(N == 1) {
if(A == B) {
cout << 1 << endl;
}
else {
cout << 0 << endl;
}
else {
cout << (B - A) * (N - 2) + 1 << endl;
}
}
| a.cc: In function 'int main()':
a.cc:23:3: error: expected '}' before 'else'
23 | else {
| ^~~~
a.cc:16:19: note: to match this '{'
16 | else if(N == 1) {
| ^
|
s130299312 | p03705 | C++ | #include <bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
ll N, A, B;
cin >> N >> A >> B;
if(A > B) {
cout << 0 << endl;
}
else if(N = 2) {
cout << 1 << endl;
}
else if(N = 1) {
if(A == B) {
cout << 1 << endl;
}
else {
cout << 0 << endl;
}
else {
cout << (B - A) * (N - 2) + 1 << endl;
}
} | a.cc: In function 'int main()':
a.cc:23:3: error: expected '}' before 'else'
23 | else {
| ^~~~
a.cc:16:18: note: to match this '{'
16 | else if(N = 1) {
| ^
|
s412812119 | p03705 | C++ | #include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define SORT(s) sort(s.begin(), s.end())
#define P pair<int, int>
#define mp make_pair
using namespace std;
template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
ostr << "}";
return ostr;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int gcd(int a, int b){
if (a%b == 0) return(b);
else return(gcd(b, a%b));}
int lcm(int a, int b)
{return a * b / gcd(a, b);}
vector<int> uniq(vector<int> vec){
sort(vec.begin(), vec.end());
vec.erase(unique(vec.begin(), vec.end()), vec.end());
return vec;}
vector<ll> divisor(ll n) {
vector<ll> ret;
for(int64_t i = 1; i * i <= n; i++) {
if(n % i == 0) {
ret.push_back(i);
if(i * i != n) ret.push_back(n / i);
}
}
sort(begin(ret), end(ret));
return (ret);
}
void permu(int n){
vector<int> perm(n);
REP(i, n) perm[i] = i;
do{
cout << perm << endl;
}
while (next_permutation(perm.begin(), perm.end()));
return;}
vector<pair<ll, int>> prime_div(ll n){
vector<pair<ll, int>> res;
for (ll i=2; i*i <= n;i++){
if (n%i == 0){
int a = 0;
while(n%i == 0){
n /= i;
a++;
}
pair<ll, int> tmp;
tmp.first = i;
tmp.second = a;
res.push_back(tmp);
}
}
if (n != 1){
pair<ll, int> now;
now.first = n;
now.second = 1;
res.push_back(now);}
return res;
}
// printf("%.10f\n" , ans);
int main(void){
ios::sync_with_stdio(false);
ll n, a, b;
cin >> n >> a >> b;
ll miv = a*(n-1) + b;
ll mxv = a + b*(n-1);
ll ans = max(mxv-miv+1, 0);
cout << ans << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:87:15: error: no matching function for call to 'max(ll, int)'
87 | ll ans = max(mxv-miv+1, 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:87:15: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
87 | ll ans = max(mxv-miv+1, 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:87:15: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
87 | ll ans = max(mxv-miv+1, 0);
| ~~~^~~~~~~~~~~~~~
|
s353135137 | p03705 | C++ | #include<bits/stdc++.h>
using namespace std;
int main(){
long long n,a,b;
cin>>n>>a>>b;
cout<<max((n-2)*(b-a)+1,0)<<endl;
return(0);
} | a.cc: In function 'int main()':
a.cc:6:14: error: no matching function for call to 'max(long long int, int)'
6 | cout<<max((n-2)*(b-a)+1,0)<<endl;
| ~~~^~~~~~~~~~~~~~~~~
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:6:14: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
6 | cout<<max((n-2)*(b-a)+1,0)<<endl;
| ~~~^~~~~~~~~~~~~~~~~
/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:6:14: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
6 | cout<<max((n-2)*(b-a)+1,0)<<endl;
| ~~~^~~~~~~~~~~~~~~~~
|
s109213004 | p03705 | C++ | #include<bits/stdc++.h>
using namespace std;
#define int long long
int main(){
int a,b,c;
cin >> a >> b >> c;
long long mx=c*(a-1)+b;
long long mn=b*(a-1)+c;
cout << mx-mn+1 << endl;
}
| cc1plus: error: '::main' must return 'int'
|
s055183437 | p03705 | C++ | #include<bits/stdc++.h>
using namespace std;
#define int long long
int main(){
int a,b,c;
cin >> a >> b >> c;
int mx=c*(a-1)+b;
int mn=b*(a-1)+c;
cout << mx-mn+1 << endl;
} | cc1plus: error: '::main' must return 'int'
|
s980024835 | p03705 | C++ | n, a, b = map(int, input().split())
print(b + b - a - a + 1) | a.cc:1:1: error: 'n' does not name a type
1 | n, a, b = map(int, input().split())
| ^
|
s338919762 | p03705 | C++ | n, a, b = map(int, input().split())
if a > b:
print(0)
else:
print((n - 2) * (b - a) + 1) | a.cc:1:1: error: 'n' does not name a type
1 | n, a, b = map(int, input().split())
| ^
|
s711505795 | p03705 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int N, A, B;
cin >> N >> A >> B;
if (N == 1 && A == B) cout << 1 << endl;
else if (N == 1) cout << 0 << endl;
else cout << max(0, (N - 2) * (B - A) + 1) << endl;
} | a.cc: In function 'int main()':
a.cc:9:19: error: no matching function for call to 'max(int, long long int)'
9 | else cout << max(0, (N - 2) * (B - A) + 1) << endl;
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
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:9:19: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
9 | else cout << max(0, (N - 2) * (B - A) + 1) << endl;
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/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:9:19: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
9 | else cout << max(0, (N - 2) * (B - A) + 1) << endl;
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
|
s137986616 | p03705 | C++ | #include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> state;
long double pi = acos(-1);
const int INF = 1001001001;
// 最小公倍数を求める
int euqlid (int a, int b){
int temp;
temp = a % b;
if(temp == 0)return b;
return euqlid(b,temp);
}
ll conbination(ll a,ll b){
ll u = 1;
ll d = 1;
while(b != 0){
u *= a;
d *= b;
a--;
b--;
}
return u / d;
}
int strtoint(char s){
return (int(s-'0'));
}
char changeS(char alpha){
if(0x41 <= alpha and alpha <= 0x5A)return (alpha + 0x20);
else if(0x61 <= alpha and alpha <= 0x7A)return (alpha - 0x20);
return alpha;
}
int fact(int n){
if(n == 1)return 1;
return n * fact(n-1);
}
int ceil(int a,int b){
// a/bの切り上げを考える
return (a+b-1)/b;
}
int main() {
int n, a, b;
cin >> n >> a >> b;
ll ub = (n - 1) * b + a;
ll lb = b + (n - 1) * a;
ll ans;
if(b - a < 0 or n = 0)ans = 0;
else if(b != a and n == 1)ans = 0;
else ans = ub - lb + 1;
cout << ans << endl;
}
| a.cc: In function 'int main()':
a.cc:54:16: error: lvalue required as left operand of assignment
54 | if(b - a < 0 or n = 0)ans = 0;
| ~~~~~~~~~~^~~~
|
s325225538 | p03705 | C++ | #include <bits/stdc++.h>
#define REP(i,n) for (int i=0; i<(n); ++i)
#define REPR(i,n,m) for (int i=(n); i>=(m); --i)
using namespace std;
using LL = long long;
using LD = long double;
using PLL = pair<long long, long long>;
using PLD = pair<long double, long double>;
using VLL = vector<long long>;
using VLD = vector<long double>;
using VPLD = vector<PLD>;
const int INF = numeric_limits<int>::max();
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, a, b; cin >> n >> a >> b;
if (a>b) {
cout << 0 << endl;
} else if (n==1&&a!=b) {
cout << 0 << endl;
} else if (n==1&&a==b) {
cout << 1 << endl;
} else {
cout << (b-a)(n-2) + 1 << endl;
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:28:22: error: expression cannot be used as a function
28 | cout << (b-a)(n-2) + 1 << endl;
| ~~~~~^~~~~
|
s456790911 | p03705 | C++ | #include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define vi vector<int>
#define nl endl
#define tc \
ll t; \
cin >> t; \
while (t--)
#define fastio \
ios_base::sync_with_stdio(NULL); \
cin.tie(NULL); \
cout.tie(NULL);
using namespace std;
int main()
{
fastio;
ll n, a, b;
cin >> n >> a >> b;
if((n==1&&a==b)
cout<<"1";
else if(n!=1&&n!=2&&a<=b)
cout<<(n-2)*(b-a)+1;
else cout<<"0";
} | a.cc: In function 'int main()':
a.cc:20:20: error: expected ';' before 'cout'
20 | if((n==1&&a==b)
| ^
| ;
21 | cout<<"1";
| ~~~~
a.cc:22:5: error: expected primary-expression before 'else'
22 | else if(n!=1&&n!=2&&a<=b)
| ^~~~
a.cc:21:19: error: expected ')' before 'else'
21 | cout<<"1";
| ^
| )
22 | else if(n!=1&&n!=2&&a<=b)
| ~~~~
a.cc:20:7: note: to match this '('
20 | if((n==1&&a==b)
| ^
|
s021576131 | p03705 | C | #include<stdio.h>
int main()
{
long long int n, a, b;
scanf("%lld %lld %lld", &n, &a, &b);
if(a>b || (n==1 && a!=b))
{
printf("0");
}
else
{
printf("%lld", (b-a)(n-2)+1);
}
return 0;
} | main.c: In function 'main':
main.c:12:26: error: called object is not a function or function pointer
12 | printf("%lld", (b-a)(n-2)+1);
| ~~^~~
|
s385270782 | p03705 | C++ | #include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
ll n, a, b;
cin >> n >> a >> b;
if(n == 1 and a == b) cout << 1;
else if(n == 1) cout << 0;
else if(a > b) cotu << 0;
else cout << (n-2)*(b-a)+1;
} | a.cc: In function 'int main()':
a.cc:15:24: error: 'cotu' was not declared in this scope
15 | else if(a > b) cotu << 0;
| ^~~~
|
s064707675 | p03705 | C++ | #include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
ll n, a, b;
cin >> n >> a >> b;
if(n == 1 and a == b) cout << 1;
else if(n == 1) cout << 0;
else if(a > b) cotu << 0;
else cout << (b-2)*(b-a)+1;
} | a.cc: In function 'int main()':
a.cc:15:24: error: 'cotu' was not declared in this scope
15 | else if(a > b) cotu << 0;
| ^~~~
|
s163459988 | p03705 | C++ | #include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
ll n, a, b;
cin >> n >> a >> b;
if(a > b) cout << 0;
if(n == 1) {
if(a == b) {
cout << 1;
} else cout << 0;
return 0;
}
ll ans = (b-2)(b-a);
cout << ++ans;
} | a.cc: In function 'int main()':
a.cc:23:23: error: expression cannot be used as a function
23 | ll ans = (b-2)(b-a);
| ~~~~~^~~~~
|
s023230467 | p03705 | C++ | n,a,b = map(int,input().split())
if a > b:
print(0)
exit()
if n == 1:
if a == b:
print(1)
else:
print(0)
exit()
print((b-a)*(n-2)+1)
| a.cc:1:1: error: 'n' does not name a type
1 | n,a,b = map(int,input().split())
| ^
|
s892472839 | p03705 | C++ | #include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;
int main() {
int N, A, B;
cin >> N >> A >> B;
if (A > B) {
printf("0\n");
return 0;
}
if (N == 1) {
printf("%d\n", A == B);
} else if (N == 2) {
printf("1\n");
} else {
printf("%lld\n", (ll)(B - A) * (N - 2) + 1);
}
} | a.cc: In function 'int main()':
a.cc:20:23: error: 'll' was not declared in this scope
20 | printf("%lld\n", (ll)(B - A) * (N - 2) + 1);
| ^~
|
s579688479 | p03705 | C++ | #include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
int n, a, b; cin >> n >> a >> b;
ll ans;
if (a > b) {
ans = 0;
} else {
if (n == 1) {
if (a != b) ans = 0;
else ans = 1;
}
} else {
ll l = a * (n-1) + b;
ll r = b * (n-1) + a;
ans = r - l + 1;
cout << ans << endl;
return 0;
}
} | a.cc: In function 'int main()':
a.cc:18:5: error: 'else' without a previous 'if'
18 | } else {
| ^~~~
|
s063454836 | p03705 | C++ | #include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
int main() {
int N, A, B;
cin >> N >> A >> B;
int C = max(A, B);
int D = min(A, B);
if (N == 1 && A != B) {
cout << 0 << endl;
}
else if (N == 2) {
cout << 1 << endl;
}
else if(C-D+1 < N){
cout << 0 << endl;
else {
cout << ((N - 1) * B + A) - ((N - 1) * A + B) + 1 << endl;
}
} | a.cc: In function 'int main()':
a.cc:35:5: error: expected '}' before 'else'
35 | else {
| ^~~~
a.cc:33:21: note: to match this '{'
33 | else if(C-D+1 < N){
| ^
|
s945433252 | p03705 | C++ | #include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
int main() {
int N, A, B;
cin >> N >> A >> B;
if (N == 1 && A = B) {
cout << 0 << endl;
}
else if (N == 2) {
cout << 1 << endl;
}
else {
cout << ((N - 1) * B + A) - ((N - 1) * A + B) + 1 << endl;
}
} | a.cc: In function 'int main()':
a.cc:25:16: error: lvalue required as left operand of assignment
25 | if (N == 1 && A = B) {
| ~~~~~~~^~~~
|
s144652251 | p03705 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
int N,A,B;
cin>>N>>A>>B;
if(A==B)cout<<1<<endl;
else if(N==1)cout<<0<<endl;
else if(A>B)cout<<0<<endl;
else{
unsigned long long int C=(N-2)*(B-A)+1;
cout<<C<<endl;
} | a.cc: In function 'int main()':
a.cc:12:2: error: expected '}' at end of input
12 | }
| ^
a.cc:3:11: note: to match this '{'
3 | int main(){
| ^
|
s467650568 | p03705 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
int N,A,B;
cin>>N>>A>>B;
if(A==B)cout<<1<<endl;
else if(N==1)cout<<0<<endl;
else if(A>B)cout<<0<<endl;
else{
unsigned long long intC=(N-2)*(B-A)+1;
cout<<C<<endl;
} | a.cc: In function 'int main()':
a.cc:11:11: error: 'C' was not declared in this scope
11 | cout<<C<<endl;
| ^
a.cc:12:2: error: expected '}' at end of input
12 | }
| ^
a.cc:3:11: note: to match this '{'
3 | int main(){
| ^
|
s586232937 | p03705 | C++ | int main(){
ll N,A,B,rs=0,Nans,min,max;
cin >> N >> A >> B;
if(N == 1){
if(A == B)
cout << 1 << endl;
else
cout << 0 << endl;
}else if(A > B){
cout << 0 << endl;
}else{
Nans = N - 2;
max = B * (Nans+1) + A;
min = A * (Nans+1) + B;
rs = max - min + 1;
cout << rs << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:2:5: error: 'll' was not declared in this scope
2 | ll N,A,B,rs=0,Nans,min,max;
| ^~
a.cc:3:5: error: 'cin' was not declared in this scope
3 | cin >> N >> A >> B;
| ^~~
a.cc:3:12: error: 'N' was not declared in this scope
3 | cin >> N >> A >> B;
| ^
a.cc:3:17: error: 'A' was not declared in this scope
3 | cin >> N >> A >> B;
| ^
a.cc:3:22: error: 'B' was not declared in this scope
3 | cin >> N >> A >> B;
| ^
a.cc:7:13: error: 'cout' was not declared in this scope
7 | cout << 1 << endl;
| ^~~~
a.cc:7:26: error: 'endl' was not declared in this scope
7 | cout << 1 << endl;
| ^~~~
a.cc:9:13: error: 'cout' was not declared in this scope
9 | cout << 0 << endl;
| ^~~~
a.cc:9:26: error: 'endl' was not declared in this scope
9 | cout << 0 << endl;
| ^~~~
a.cc:11:9: error: 'cout' was not declared in this scope
11 | cout << 0 << endl;
| ^~~~
a.cc:11:22: error: 'endl' was not declared in this scope
11 | cout << 0 << endl;
| ^~~~
a.cc:13:9: error: 'Nans' was not declared in this scope
13 | Nans = N - 2;
| ^~~~
a.cc:14:9: error: 'max' was not declared in this scope
14 | max = B * (Nans+1) + A;
| ^~~
a.cc:15:9: error: 'min' was not declared in this scope; did you mean 'main'?
15 | min = A * (Nans+1) + B;
| ^~~
| main
a.cc:16:9: error: 'rs' was not declared in this scope
16 | rs = max - min + 1;
| ^~
a.cc:17:9: error: 'cout' was not declared in this scope
17 | cout << rs << endl;
| ^~~~
a.cc:17:23: error: 'endl' was not declared in this scope
17 | cout << rs << endl;
| ^~~~
|
s132195658 | p03705 | Java | import java.io.*;
import java.math.*;
import java.util.*;
public class AGC015APlusB {
public static void main(String[] args) {
FastScanner I = new FastScanner(); //Input
OutPut O = new OutPut(); //Output
long ans = 0;
long N = I.nextLong();
long A = I.nextLong();
long B = I.nextLong();
if (A<=B&&N>=2) {
N-=2;
long lo = N*A;
long hi = N*B;
ans=hi-lo+1;
ans = Math.max(ans, 0);
}else if (N==1&&A==B) ans++;
O.pln(ans);
}
public static long GCD(long a, long b) {
if (a==0||b==0) return Math.max(a,b);
return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
}
public static long FastExp(long base, long exp, long mod) {
long ans=1;
while (exp>0) {
if (exp%2==1) ans*=base;
exp/=2;
base*=base;
base%=mod;
ans%=mod;
}
return ans;
}
public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
static class FastScanner {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st=new StringTokenizer("");
String next() {
while (!st.hasMoreTokens())
try {
st=new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
return st.nextToken();
}
int nextInt() {return Integer.parseInt(next());}
long nextLong() {return Long.parseLong(next());};
}
static class OutPut{
PrintWriter w = new PrintWriter(System.out);
void pln(int x) {w.println(x);w.flush();}
void pln(long x) {w.println(x);w.flush();}
void pln(String x) {w.println(x);w.flush();}
void pln(char x) {w.println(x);w.flush();}
void p(int x) {w.print(x);w.flush();}
void p(long x) {w.print(x);w.flush();}
void p(String x) {w.print(x);w.flush();}
void p(char x) {w.print(x);w.flush();}
}
} | Main.java:4: error: class AGC015APlusB is public, should be declared in a file named AGC015APlusB.java
public class AGC015APlusB {
^
1 error
|
s596918470 | p03705 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
ll n,a,b;
cin >> n >> a >> b;
if((n==1 && a!=b) || a>b){
cout << 0 << endl;
return 0;
}
cout << (b-a)*(n-2)+1 << endl;
}
| a.cc: In function 'int main()':
a.cc:5:2: error: 'll' was not declared in this scope
5 | ll n,a,b;
| ^~
a.cc:6:10: error: 'n' was not declared in this scope; did you mean 'yn'?
6 | cin >> n >> a >> b;
| ^
| yn
a.cc:6:15: error: 'a' was not declared in this scope
6 | cin >> n >> a >> b;
| ^
a.cc:6:20: error: 'b' was not declared in this scope
6 | cin >> n >> a >> b;
| ^
|
s320479564 | p03705 | C++ | #include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vec_input(v) for(auto it=v.begin();it!=v.end();it++){cin>>*it;}
#define vec_output(v) for(auto it=v.begin();it!=v.end();it++){if(it!=v.begin())cout<<" ";cout<<*it;}cout<<endl;
#define vec_debug(v) for(auto it=v.begin();it!=v.end();it++){cerr<<*it<<" ";}cerr<<endl;
#define yn(ans) cout<<(ans?"Yes":"No")<<endl
#define YN(ans) cout<<(ans?"YES":"NO")<<endl
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
template <typename T>T digitsum(T n);
template <typename T>bool isPrime(T n);
template <typename T>vector<pair<T, T>> prime_factor(T n);
long long int intpow(long long int,long long int);
template <typename T>T intlog(T);
long long int combination(long long int,long long int);
long long int arith_sum1(long long int,long long int,long long int);
long long int arith_sum2(long long int,long long int,long long int);
long long int series_sum(long long int);
int main(){
ll n,a,b,ans;
cin>>n>>a>>b;
if(a==b){
cout<<1<<endl;
return 0;
}
if(a>b){
cout<<0<<endl;
return 0;
}
if(n>=3){
cout<<arith_sum1(b-a+1,n-2,-1)<<endl;
}
if(n==2){
cout<<1<<endl;
}
if(n==1){
cout<<0<<endl;
}
} | /usr/bin/ld: /tmp/cc2MMzEO.o: in function `main':
a.cc:(.text+0xeb): undefined reference to `arith_sum1(long long, long long, long long)'
collect2: error: ld returned 1 exit status
|
s359700936 | p03705 | C++ | #include <bits/stdc+.h>
using namespace std;
int main()
{
long long N, A, B, ans;
cin >> N >> A >> B;
if(A>B)
cout << 0;
else if(A==B)
cout << 1;
else
{
if(N==1)
cout << 0;
else if(N==2)
cout << 1;
else
{
ans = B*(N-1)+A - A*(N-1) -B + 1;
cout << ans;
}
}
}
| a.cc:1:10: fatal error: bits/stdc+.h: No such file or directory
1 | #include <bits/stdc+.h>
| ^~~~~~~~~~~~~~
compilation terminated.
|
s675614239 | p03705 | C++ | n,a,b=map(int,input().split())
if a>b:
print(0)
elif n==1 and a!=b:
print(0)
else:
print(b*(n-1)+a-(b+a*(n-1))+1) | a.cc:1:1: error: 'n' does not name a type
1 | n,a,b=map(int,input().split())
| ^
|
s550521917 | p03705 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define int ll
const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)
#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))
// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend() // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define all(x) (x).begin(), (x).end()
//略記
#define pb emplace_back // vectorヘの挿入
#define mp make_pair // pairのコンストラクタ
#define F first // pairの一つ目の要素
#define S second // pairの二つ目の要素
#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)
#define perm(c) \
sort(all(c)); \
for (bool c##p = 1; c##p; \
c##p = next_permutation(all(c))) //順列 123 132 213 231 312 321
#define BIT(n) (1LL << (n))
#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif
//入力高速化
struct IoSetup {
IoSetup() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
cout << fixed << setprecision(20);
}
} iosetup;
template <class T>
inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T>
inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
signed main() {
int A,B,C;
cin >> C >> A >> B;
if(N <= 2 || A >= B){
cout << 0 << endl;
return 0;
}
cout << (B-A)*(C-2)+1 << endl;
} | a.cc: In function 'int main()':
a.cc:86:6: error: 'N' was not declared in this scope
86 | if(N <= 2 || A >= B){
| ^
|
s894431843 | p03705 | C++ | #include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
int N,A,B;
cin >> N >> A >> B;
cout << max((B*(N-1)+A)-(A*(N-1)+B)+1,0) << endl;
}
| a.cc: In function 'int main()':
a.cc:7:16: error: no matching function for call to 'max(long long int, int)'
7 | cout << max((B*(N-1)+A)-(A*(N-1)+B)+1,0) << endl;
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:7:16: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
7 | cout << max((B*(N-1)+A)-(A*(N-1)+B)+1,0) << endl;
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:7:16: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
7 | cout << max((B*(N-1)+A)-(A*(N-1)+B)+1,0) << endl;
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
s150754675 | p03705 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
int64_t N,A,B;
cin>>N>>A>>B;
if(A>B)
cout<<0<<endl;
else
cout<<max((B-A)*(N-2)+1,0)<<endl;
} | a.cc: In function 'int main()':
a.cc:10:14: error: no matching function for call to 'max(int64_t, int)'
10 | cout<<max((B-A)*(N-2)+1,0)<<endl;
| ~~~^~~~~~~~~~~~~~~~~
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:10:14: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'int')
10 | cout<<max((B-A)*(N-2)+1,0)<<endl;
| ~~~^~~~~~~~~~~~~~~~~
/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:10:14: note: mismatched types 'std::initializer_list<_Tp>' and 'long int'
10 | cout<<max((B-A)*(N-2)+1,0)<<endl;
| ~~~^~~~~~~~~~~~~~~~~
|
s783830647 | p03705 | C++ | #include<algorithm>//sort(all(変数),greater<型名>())で降順に、*max_element(all(変数))で最大値を獲得
#include<bits/stdc++.h>
#include<cmath>//切り上げceil(値)
#include<deque>
#include<iomanip>//setprecision(数字)
#include<iostream>
#include<list>
#include<map>
#include<numeric>
// xとyのgcdは__gcd(x,y),xとyのlcmは(x*y)/__gcd、accumulate(all(変数),0)で要素の全加算
#include<queue>//priority_queue<型名> 変数
#include<set>
#include<stack>
#include<string>//変数.substr(どこから,いくつ)
#include<vector>
#define rep(i,n) for(ll i=0; i<n; i++)
#define rrep(i,n) for(ll i=n-1; 0<=i; i--)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF 1e9
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int main(){
int n,a,b; cin >> a >> b >> c;
if(n == 1){
if(a == b){
cout << 1;
}else{
cout << 0;
}
}else{
if(a > b){
cout << 0;
}else{
cout << (n-2)*(b-a)+1;
}
}
cout << "\n";
return 0;
}
| a.cc: In function 'int main()':
a.cc:28:31: error: 'c' was not declared in this scope
28 | int n,a,b; cin >> a >> b >> c;
| ^
|
s562292233 | p03705 | C++ | #pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/tag_and_trait.hpp>
// using namespace __gnu_pbds;
// #include<boost/multiprecision/cpp_int.hpp>
// namespace multiprecisioninteger = boost::multiprecision;
// using cint=multiprecisioninteger::cpp_int;
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
// using llset=tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;
#define For(i,a,b) for(i=a;i<(ll)b;++i)
#define bFor(i,b,a) for(i=b,--i;i>=(ll)a;--i)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N,0)
#define brep1(i,N) bFor(i,N,1)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define eb emplace_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
#define matoutput(v) do{for(auto outimat:v)output(outimat);}while(0)
const ll mod=1000000007;
// const ll mod=998244353;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;}
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;}
void startupcpp(){
cin.tie(0);
ios::sync_with_stdio(false);
cout<<fixed<<setprecision(15);
}
double distance(ddatas x,ddatas y){
double a=x.first-y.first,b=x.second-y.second;
return sqrt(a*a+b*b);
}
ll modinv(ll a) {
ll b=mod,u=1,v=0,t;
while(b){
t=a/b;
a-=t*b; swap(a,b);
u-=t*v; swap(u,v);
}
return (u+mod)%mod;
}
ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}
vec modncrlistp,modncrlistm;
ll modncr(ll n,ll r){
if(n<r)return 0;
ll i,size=modncrlistp.size();
if(size<=n){
modncrlistp.resize(n+1);
modncrlistm.resize(n+1);
if(!size){
modncrlistp[0]=modncrlistm[0]=1;
size++;
}
For(i,size,n+1){
modncrlistp[i]=modncrlistp[i-1]*i%mod;
modncrlistm[i]=modinv(modncrlistp[i]);
}
}
return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}
ll modpow(ll a,ll n){
ll res=1;
while(n>0){
if(n&1)res=res*a%mod;
a=a*a%mod;
n>>=1;
}
return res;
}
ll gcd(ll a,ll b){if(!b)return abs(a);return (a%b==0)?abs(b):gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll countdigits(ll n){
ll ans=0;
while(n){n/=10;ans++;}
return ans;
}
ll sumdigits(ll n){
ll ans=0;
while(n){ans+=n%10;n/=10;}
return ans;
}
void topcoder(vector<int>& v){
string s;
while(1){
cin>>s;
int i=s[0]=='{',x=0;
while(s[i]>='0'&&s[i]<='9'){
x=x*10+s[i]-'0';
++i;
}
v.eb(x);
if(s[i]=='}')break;
}
}
void topcoder(string& s){
string t;
cin>>t;
int i=1;
while(t[i]!='"'){
s+=t[i++];
}
}
int main(){
// startupcpp();
// int codeforces;cin>>codeforces;while(codeforces--){
ll i,j,N,A,B,ans;
cin>>N>>A>>B;
if(N==1){
print((A==B));
return 0;
}
if(A>B){
print(0);
return 0;
}
if(A==B){
print(1);
return 0;
}
print((N-2)*(B-A)+1);
}#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/tag_and_trait.hpp>
// using namespace __gnu_pbds;
// #include<boost/multiprecision/cpp_int.hpp>
// namespace multiprecisioninteger = boost::multiprecision;
// using cint=multiprecisioninteger::cpp_int;
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
// using llset=tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;
#define For(i,a,b) for(i=a;i<(ll)b;++i)
#define bFor(i,b,a) for(i=b,--i;i>=(ll)a;--i)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N,0)
#define brep1(i,N) bFor(i,N,1)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define eb emplace_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
#define matoutput(v) do{for(auto outimat:v)output(outimat);}while(0)
const ll mod=1000000007;
// const ll mod=998244353;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;}
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;}
void startupcpp(){
cin.tie(0);
ios::sync_with_stdio(false);
cout<<fixed<<setprecision(15);
}
double distance(ddatas x,ddatas y){
double a=x.first-y.first,b=x.second-y.second;
return sqrt(a*a+b*b);
}
ll modinv(ll a) {
ll b=mod,u=1,v=0,t;
while(b){
t=a/b;
a-=t*b; swap(a,b);
u-=t*v; swap(u,v);
}
return (u+mod)%mod;
}
ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}
vec modncrlistp,modncrlistm;
ll modncr(ll n,ll r){
if(n<r)return 0;
ll i,size=modncrlistp.size();
if(size<=n){
modncrlistp.resize(n+1);
modncrlistm.resize(n+1);
if(!size){
modncrlistp[0]=modncrlistm[0]=1;
size++;
}
For(i,size,n+1){
modncrlistp[i]=modncrlistp[i-1]*i%mod;
modncrlistm[i]=modinv(modncrlistp[i]);
}
}
return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}
ll modpow(ll a,ll n){
ll res=1;
while(n>0){
if(n&1)res=res*a%mod;
a=a*a%mod;
n>>=1;
}
return res;
}
ll gcd(ll a,ll b){if(!b)return abs(a);return (a%b==0)?abs(b):gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll countdigits(ll n){
ll ans=0;
while(n){n/=10;ans++;}
return ans;
}
ll sumdigits(ll n){
ll ans=0;
while(n){ans+=n%10;n/=10;}
return ans;
}
void topcoder(vector<int>& v){
string s;
while(1){
cin>>s;
int i=s[0]=='{',x=0;
while(s[i]>='0'&&s[i]<='9'){
x=x*10+s[i]-'0';
++i;
}
v.eb(x);
if(s[i]=='}')break;
}
}
void topcoder(string& s){
string t;
cin>>t;
int i=1;
while(t[i]!='"'){
s+=t[i++];
}
}
int main(){
// startupcpp();
// int codeforces;cin>>codeforces;while(codeforces--){
ll i,j,N,A,B,ans;
cin>>N>>A>>B;
if(N==1){
print((A==B));
return 0;
}
if(A>B){
print(0);
return 0;
}
if(A==B){
print(1);
return 0;
}
print((N-2)*(B-A)+1);
} | a.cc:157:2: error: stray '#' in program
157 | }#pragma GCC target("avx")
| ^
a.cc:157:3: error: 'pragma' does not name a type; did you mean '_Pragma'?
157 | }#pragma GCC target("avx")
| ^~~~~~
| _Pragma
a.cc:198:10: error: redefinition of 'const ll mod'
198 | const ll mod=1000000007;
| ^~~
a.cc:42:10: note: 'const ll mod' previously defined here
42 | const ll mod=1000000007;
| ^~~
a.cc:200:10: error: redefinition of 'const ll inf'
200 | const ll inf=1LL<<60;
| ^~~
a.cc:44:10: note: 'const ll inf' previously defined here
44 | const ll inf=1LL<<60;
| ^~~
a.cc:201:14: error: redefinition of 'const long double PI'
201 | const double PI = acos(-1);
| ^~
a.cc:45:14: note: 'const long double PI' previously defined here
45 | const double PI = acos(-1);
| ^~
a.cc:202:14: error: redefinition of 'const long double eps'
202 | const double eps = 1e-9;
| ^~~
a.cc:46:14: note: 'const long double eps' previously defined here
46 | const double eps = 1e-9;
| ^~~
a.cc:203:31: error: redefinition of 'template<class T> bool chmax(T&, T)'
203 | template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;}
| ^~~~~
a.cc:47:31: note: 'template<class T> bool chmax(T&, T)' previously declared here
47 | template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;}
| ^~~~~
a.cc:204:31: error: redefinition of 'template<class T> bool chmin(T&, T)'
204 | template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;}
| ^~~~~
a.cc:48:31: note: 'template<class T> bool chmin(T&, T)' previously declared here
48 | template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;}
| ^~~~~
a.cc:206:6: error: redefinition of 'void startupcpp()'
206 | void startupcpp(){
| ^~~~~~~~~~
a.cc:50:6: note: 'void startupcpp()' previously defined here
50 | void startupcpp(){
| ^~~~~~~~~~
a.cc:212:8: error: redefinition of 'long double distance(ddatas, ddatas)'
212 | double distance(ddatas x,ddatas y){
| ^~~~~~~~
a.cc:56:8: note: 'long double distance(ddatas, ddatas)' previously defined here
56 | double distance(ddatas x,ddatas y){
| ^~~~~~~~
a.cc:217:4: error: redefinition of 'll modinv(ll)'
217 | ll modinv(ll a) {
| ^~~~~~
a.cc:61:4: note: 'll modinv(ll)' previously defined here
61 | ll modinv(ll a) {
| ^~~~~~
a.cc:227:4: error: redefinition of 'll moddevide(ll, ll)'
227 | ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}
| ^~~~~~~~~
a.cc:71:4: note: 'll moddevide(ll, ll)' previously defined here
71 | ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}
| ^~~~~~~~~
a.cc:229:5: error: redefinition of 'vec modncrlistp'
229 | vec modncrlistp,modncrlistm;
| ^~~~~~~~~~~
a.cc:73:5: note: 'vec modncrlistp' previously declared here
73 | vec modncrlistp,modncrlistm;
| ^~~~~~~~~~~
a.cc:229:17: error: redefinition of 'vec modncrlistm'
229 | vec modncrlistp,modncrlistm;
| ^~~~~~~~~~~
a.cc:73:17: note: 'vec modncrlistm' previously declared here
73 | vec modncrlistp,modncrlistm;
| ^~~~~~~~~~~
a.cc:231:4: error: redefinition of 'll modncr(ll, ll)'
231 | ll modncr(ll n,ll r){
| ^~~~~~
a.cc:75:4: note: 'll modncr(ll, ll)' previously defined here
75 | ll modncr(ll n,ll r){
| ^~~~~~
a.cc:249:4: error: redefinition of 'll modpow(ll, ll)'
249 | ll modpow(ll a,ll n){
| ^~~~~~
a.cc:93:4: note: 'll modpow(ll, ll)' previously defined here
93 | ll modpow(ll a,ll n){
| ^~~~~~
a.cc:259:4: error: redefinition of 'll gcd(ll, ll)'
259 | ll gcd(ll a,ll b){if(!b)return abs(a);return (a%b==0)?abs(b):gcd(b,a%b);}
| ^~~
a.cc:103:4: note: 'll gcd(ll, ll)' previously defined here
103 | ll gcd(ll a,ll b){if(!b)return abs(a);return (a%b==0)?abs(b):gcd(b,a%b);}
| ^~~
a.cc:260:4: error: redefinition of 'll lcm(ll, ll)'
260 | ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
| ^~~
a.cc:104:4: note: 'll lcm(ll, ll)' previously defined here
104 | ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
| ^~~
a.cc:262:4: error: redefinition of 'll countdigits(ll)'
262 | ll countdigits(ll n){
| ^~~~~~~~~~~
a.cc:106:4: note: 'll countdigits(ll)' previously defined here
106 | ll countdigits(ll n){
| ^~~~~~~~~~~
a.cc:268:4: error: redefinition of 'll sumdigits(ll)'
268 | ll sumdigits(ll n){
| ^~~~~~~~~
a.cc:112:4: note: 'll sumdigits(ll)' previously defined here
112 | ll sumdigits(ll n){
| ^~~~~~~~~
a.cc:274:6: error: redefinition of 'void topcoder(std::vector<int>&)'
274 | void topcoder(vector<int>& v){
| ^~~~~~~~
a.cc:118:6: note: 'void topcoder(std::vector<int>&)' previously defined here
118 | void topcoder(vector<int>& v){
| ^~~~~~~~
a.cc:287:6: error: redefinition of 'void topcoder(std::string&)'
287 | void topcoder(string& s){
| ^~~~~~~~
a.cc:131:6: note: 'void topcoder(std::string&)' previously defined here
131 | void topcoder(string& s){
| ^~~~~~~~
a.cc:295:5: error: redefinition of 'int main()'
295 | int main(){
| ^~~~
a.cc:139:5: note: 'int main()' previously defined here
139 | int main(){
| ^~~~
|
s453545361 | p03705 | C++ | #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>
#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>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
using namespace std;
int inf = 2147483647;
int64_t inf64 = 9223372036854775807;
int MOD = 1e+7;
signed main() {
cin.tie(0);
ios::sync_with_stdio(false);
int64_t n, a, b;
cin >> n >> a >> b;
int64_t mini = a * n + (b - a);
int64_t maxi = b * n - (b - a);
cout << max(0, (maxi-mini+1)) << endl;
//cout << mini << " " << maxi << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:74:14: error: no matching function for call to 'max(int, int64_t)'
74 | cout << max(0, (maxi-mini+1)) << endl;
| ~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/specfun.h:43,
from /usr/include/c++/14/cmath:3906,
from a.cc:7:
/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:74:14: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'int64_t' {aka 'long int'})
74 | cout << max(0, (maxi-mini+1)) << endl;
| ~~~^~~~~~~~~~~~~~~~~~
/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:17:
/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:74:14: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
74 | cout << max(0, (maxi-mini+1)) << endl;
| ~~~^~~~~~~~~~~~~~~~~~
|
s849994501 | p03705 | C++ | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl;
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;
#define sz(x) (int)(x).size()
#define HOGE cout << "hoge" << endl;
template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}
const int INF = 1e9;
int main(){
ill N, A, B;
cin >> N >> A >> B;
ll ans = (N-2)*(B-A)+1;
if(N==1){
if(A==B) cout << 1 << endl;
else cout << 0 << endl;
}
if(N!=1){
if(A<=B)cout << ans << endl;
else cout << 0 << endl;
}
}
| a.cc: In function 'int main()':
a.cc:32:5: error: 'ill' was not declared in this scope; did you mean 'll'?
32 | ill N, A, B;
| ^~~
| ll
a.cc:33:12: error: 'N' was not declared in this scope
33 | cin >> N >> A >> B;
| ^
a.cc:33:17: error: 'A' was not declared in this scope
33 | cin >> N >> A >> B;
| ^
a.cc:33:22: error: 'B' was not declared in this scope
33 | cin >> N >> A >> B;
| ^
|
s360182066 | p03705 | C++ | #include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define bgn begin()
#define sz size()
#define en end()
#define pb push_back
#define pp() pop_back()
#define V vector
#define P pair
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
#define Q queue
#define pri priority_queue
#define Pri priority_queue<int,vector<int>,greater<int>>
#define PriP priority_queue<P<int,int>,vector<P<int,int>>,greater<P<int,int>>>
#define all(a) (a).begin(),(a).end()
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
int low(V<int> &a,int b){
auto c=lower_bound(a.begin(),a.end(),b);
int d=c-a.bgn;
return d;
}
int upp(V<int> &a,int b){
auto c=upper_bound(a.begin(),a.end(),b);
int d=c-a.bgn;
return d;
}
int wari(int a,int b) {
if(a%b==0)
return a/b;
else
return a/b+1;
}
int keta(int a){
double b=a;
b=log10(b);
int c=b;
return c+1;
}
int souwa(int a){
return a*(a+1)/2;
}
int gcm(int a,int b){
if(a%b==0)
return b;
return gcm(b,a%b);
}
bool prime(int a){
if(a<2)
return false;
else if(a==2)
return true;
else if(a%2==0)
return false;
for(int i=3;i<=sqrt(a)+1;i+=2){
if (a%i==0)
return false;
}
return true;
}
struct Union{
vector<int> par;
Union(int a){
par=vector<int>(a,-1);
}
int find(int a){
if(par[a]<0)
return a;
else
return par[a]=find(par[a]);
}
bool same(int a,int b){
return find(a)==find(b);
}
int Size(int a){
return -par[find(a)];
}
void unite(int a,int b){
a=find(a);
b=find(b);
if(a==b)
return;
if(Size(b)>Size(a))
swap<int>(a,b);
par[a]+=par[b];
par[b]=a;
}
};
int ketas(int a){
string b=to_string(a);
int c=0;
fo(i,keta(a)){
c+=b[i]-'0';
}
return c;
}
bool fe(int a,int b){
a%=10;
b%=10;
if(a==0)
a=10;
if(b==0)
b=10;
if(a>b)
return true;
else
return false;
}
int INF=1000000007;
struct edge{int s,t,d; };
V<int> mojisyu(string a){
V<int> b(26,0);
fo(i,a.sz){
b[a[i]-'a']++;
}
return b;
}
int wa2(int a){
if(a%2==1)
return a/2;
return a/2-1;
}
/*signed main(){
int a,b,c;
cin>>a>>b>>c;
V<V<edge>> d(a);
fo(i,b){
edge e;
cin>>e.s>>e.t>>e.d;
d[e.s].pb(e);
}
V<int> e(a,INF);
e[c]=0;
priority_queue<P<int,int>,V<P<int,int>>,greater<P<int,int>>> f;
f.push({0,c});
int h=INF;
while(!f.empty()){
P<int,int> g;
g=f.top();
f.pop();
int v = g.second, i = g.first;
for(edge l : d[v]){
if(e[l.t] > i + l.d){
e[l.t] = i + l.d;
f.push({i+l.d , l.t});
}
}
}
fo(i,a){
if(e[i]==INF)
cout<<"INF"<<endl;
else
cout<<e[i]<<endl;
}
}
?*/
int nCr(int n,int r){
int a=1;
r=min(r,n-r);
for(int i=n;i>n-r;i--){
a*=i;
a/=n-i+1;
}
return a;
}
/*void sea(int x,int y){
if(x<0||a<=x||y<0||b<=y||c[x][y]=='#')
return;
if(d[x][y])
return;
d[x][y]++;
sea(x+1,y);
sea(x-1,y);
sea(x,y+1);
sea(x,y-1);
}*/
int kaijou(int a){
int b=1;
fo(i,a)
b*=i+1;
return b;
}
int nPr(int a,int b){
if(a<b)
return 0;
if(b==0)
return 1;
int c=1;
for(int i=a;i>a-b;i--){
c*=i;
c%=INF;
}
return c;
}
long long modpow(long long a, long long n, long long mod) {
long long res = 1;
while (n > 0) {
if (n & 1) res = res * a % mod;
a = a * a % mod;
n >>= 1;
}
return res;
}
// a^{-1} mod を計算する
long long modinv(long long a, long long mod) {
return modpow(a, mod - 2, mod);
}
int lcm(int a,int b){
int c=modinv(gcm(a,b),INF);
return ((a*c)%INF)*(b%INF)%INF;
}
int MOD=INF;
int fac[1000010], finv[1000010], inv[1000010];
// テーブルを作る前処理
//先にCOMinit()で前処理をする
//ABC145D
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for(int i=2;i<1000010;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;
}
}
// 二項係数計算
int COM(int n,int k){
if(n<k)
return 0;
if(n<0||k<0)
return 0;
return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
bool naka(int a,int b,V<V<char>> c){
return (a>=0&&b>=0&&a<c.sz&&b<c[0].sz);
}
V<P<int,int>> mawari8={{0,-1},{0,1},{1,0},{-1,0},{-1,-1},{1,1},{1,-1},{-1,-1}};
int inf=1000000000000000007;
/*
signed main(){
int a,b,c;
cin>>a>>b>>c;
V<V<edge>> d(a);
fo(i,b){
edge e;
cin>>e.s>>e.t>>e.d;
d[e.s].pb(e);
}
V<int> e(a,INF);
e[c]=0;
priority_queue<P<int,int>,V<P<int,int>>,greater<P<int,int>>> f;
f.push({0,c});
int h=INF;
while(!f.empty()){
P<int,int> g;
g=f.top();
f.pop();
int v = g.second, i = g.first;
for(edge l : d[v]){
if(e[l.t] > i + l.d){
e[l.t] = i + l.d;
f.push({i+l.d , l.t});
}
}
}
fo(i,a){
if(e[i]==INF)
cout<<"INF"<<endl;
else
cout<<e[i]<<endl;
}
}*/
V<P<int,int>> mawari4={{0,-1},{0,1},{1,0},{-1,0}};
//最短経路の表 a(全部INFで初期化)
//縦横 x,y
//迷路 f
//スタートsx,sy
//ゴールgx,gy
//文字はgから使おうね
/*int bfs_haba(){
Q<P<int,int>> b;
a[sx][sy]=0;
b.push({sx,sy});
while(!b.empty()){
P<int,int> c=b.front();
b.pop();
if(c.fi==gx&&c.se==gy){
break;
}
fo(i,4){
int d=c.fi+mawari4[i].fi;
int e=c.se+mawari4[i].se;
if(0<=d&&0<=e&&d<x&&e<y&&f[d][e]!='#'&&a[d][e]==INF){
b.push({d,e});
a[d][e]=1+a[c.fi][c.se];
}
}
}
return a[gx][gy];
}*/
V<int> onajibubun(string a){
V<int> b(a.sz);
for(int i=1,j=0;i<a.sz;i++){
if(i+b[i-j]<j+b[j])
b[i]=b[i-j];
else{
int c=max<int>(0,j+b[j]-i);
while(i+c<a.sz&&a[c]==a[i+c])
c++;
b[i]=c;
j=i;
}
}
b[0]=a.sz;
return b;
}
//各頂点ごとにどこに辺が出てるかの表がc
//各頂点ごとの色を表すV<int>(頂点数max)のcolorを用意する
//aはどこ塗るか、bは何で塗るかなので、(0,1,c)でよぶとおけ
V<int> color(205);
bool nibu_hantei(int a,int b,V<V<int>> c){
color[a]=b;
fo(i,c[a].sz){
if(b==color[c[a][i]])
return false;
if(color[c[a][i]]==0&&!nibu_hantei(c[a][i],-b,c))
return false;
}
return true;
}
//aは頂点数
//nibu_hanteiの上にcolorを用意する
//各頂点ごとにどこに辺が出てるかの表がc
bool renketujanai_nibu_hantei(int a,V<V<int>> c){
fo(i,a){
if(color[i]==0){
if(!nibu_hantei(i,1,c))
return false;
}
}
return true;
}
struct segmin{
vector<int> seg;
int b;
segmin(V<int> a){
b=1;
while(b<a.sz)
b*=2;
seg=vector<int>(2*b-1,inf);
fo(i,a.sz){
seg[i+b-1]=a[i];
}
for(int i=b-2;i>=0;i--){
seg[i]=min(seg[2*i+1],seg[2*i+2]);
}
}
void update(int i,int a){
i+=b-1;
seg[i]=a;
while(i){
i=(i-1)/2;
seg[i]=min(seg[2*i+1],seg[2*i+2]);
}
}
//最初呼び出すときは要求区間x,y+1(yは添え字+1)とa=0,l=0,r=INFで
//l,rは探すところ
int getmin(int x,int y,int a,int l,int r){
if(r==INF)
r=b;
if(r<=x||y<=l)
return INF;
if(x<=l&&r<=y)
return seg[a];
int a1=getmin(x,y,2*a+1,l,(l+r)/2);
int a2=getmin(x,y,2*a+2,(l+r)/2,r);
return min(a1,a2);
}
};
struct segadd{
vector<int> seg;
int b;
segadd(V<int> a){
b=1;
while(b<a.sz)
b*=2;
seg=vector<int>(2*b-1,0);
fo(i,a.sz){
seg[i+b-1]=a[i];
}
for(int i=b-2;i>=0;i--){
seg[i]=seg[2*i+1]+seg[2*i+2];
}
}
void update(int i,int a){
i+=b-1;
seg[i]=a;
while(i){
i=(i-1)/2;
seg[i]=seg[2*i+1]+seg[2*i+2];
}
}
//最初呼び出すときは要求区間x,y+1(yは添え字+1)とa=0,l=0,r=INFで
//l,rは探すところ
int getadd(int x,int y,int a,int l,int r){
if(r==INF)
r=b;
if(r<=x||y<=l)
return 0;
if(x<=l&&r<=y)
return seg[a];
int a1=getadd(x,y,2*a+1,l,(l+r)/2);
int a2=getadd(x,y,2*a+2,(l+r)/2,r);
return a1+a2;
}
};
//12だったら{(2,2),(3,1)}って返してくれるはず
V<P<int,int>> factorize(int n){
V<P<int,int>> res;
for(int i=2; i*i<=n; i++){
if(n%i)
continue;
res.emplace_back(i,0);
while(n%i==0){
n/=i;
res.back().second++;
}
}
if(n!=1)
res.emplace_back(n,1);
return res;
}
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
signed main(){
int n, a. b;
cin >> n >> a >> b;
if(n == 1 && a == b){
cout << 1 << endl;
return 0;
}
if(n == 1){
cout << 0 << endl;
return 0;
}
if(n == 2 && a != b){
cout << 2 << endl;
return 0;
}
if(n == 2 && a == b){
cout << 1 << endl;
return 0;
}
cout << (b - a) * (n - 2) + 1 << endl;
} | a.cc: In function 'int main()':
a.cc:451:11: error: expected initializer before '.' token
451 | int n, a. b;
| ^
a.cc:452:15: error: 'a' was not declared in this scope
452 | cin >> n >> a >> b;
| ^
a.cc:452:20: error: 'b' was not declared in this scope
452 | cin >> n >> a >> b;
| ^
|
s221590017 | p03705 | C++ | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
ll N,A,B;
cin >> N >> A >> B;
cout << max(0,(B * (N - 1) + A) - (A * (N - 1) + B) + 1) << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:9:14: error: no matching function for call to 'max(int, ll)'
9 | cout << max(0,(B * (N - 1) + A) - (A * (N - 1) + B) + 1) << endl;
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:9:14: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
9 | cout << max(0,(B * (N - 1) + A) - (A * (N - 1) + B) + 1) << endl;
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:9:14: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
9 | cout << max(0,(B * (N - 1) + A) - (A * (N - 1) + B) + 1) << endl;
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
s048714542 | p03705 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(void)
{
cin.tie(0);
ios::sync_with_stdio(false);
long long int n,a,b;
cin >> n >> a >> b;
long long int hi = (n-1)*b + a;
long long int lo = (n-1)*a + b;
cout << max(0,hi-lo+1) << '\n';
return 0;
} | a.cc: In function 'int main()':
a.cc:16:20: error: no matching function for call to 'max(int, long long int)'
16 | cout << max(0,hi-lo+1) << '\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:16:20: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
16 | cout << max(0,hi-lo+1) << '\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:16:20: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
16 | cout << max(0,hi-lo+1) << '\n';
| ~~~^~~~~~~~~~~
|
s207882898 | p03705 | C++ | #include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
set<ll> st;
void func(int n, int a, int b, ll acc) {
if (n <= 0) {
st.insert(acc);
return;
}
for (int i = a; i <= b; i++) {
func(n - 1, a, b, acc + i);
}
}
int main() {
int n, a, b;
cin >> n >> a >> b;
if (n == 1 && a != b) {
cout << 0 << endl;
return;
} else if ((n == 1 && a == b) || n <= 2) {
cout << 1 << endl;
return;
}
func(n - 2, a, b, a + b);
cout << st.size() << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:24:5: error: return-statement with no value, in function returning 'int' [-fpermissive]
24 | return;
| ^~~~~~
a.cc:27:5: error: return-statement with no value, in function returning 'int' [-fpermissive]
27 | return;
| ^~~~~~
|
s021700775 | p03705 | C++ | #include<iostream>
#include<algorithm>
using namespace std;
int main(void)
{
long long n,a,b;
cin >> n >> a >> b;
cout << max(0,b*(n-1)+a-(a*(n-1)+b)+1);
return 0;
}
| a.cc: In function 'int main()':
a.cc:8:16: error: no matching function for call to 'max(int, long long int)'
8 | cout << max(0,b*(n-1)+a-(a*(n-1)+b)+1);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
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:8:16: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
8 | cout << max(0,b*(n-1)+a-(a*(n-1)+b)+1);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:8:16: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
8 | cout << max(0,b*(n-1)+a-(a*(n-1)+b)+1);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
|
s769968620 | p03705 | C++ | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<double> VL;
typedef vector<string> VS;
typedef vector<PLL> VP;
typedef vector<ll> VLL;
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; } //charを整数に
int main()
{
ll N,A,B;
cin >> N >> A >> B;
else if(N==1){
if(A==B){
cout << 1 << endl;
}
else{
cout << 0 << endl;
}
}
else{
if(A>B){
cout << 0 << endl;
}
else if(A==B){
cout << 1 << endl;
}
else{
cout << (B-A)*(N-2)+1 << endl;
}
}
} | a.cc: In function 'int main()':
a.cc:28:5: error: 'else' without a previous 'if'
28 | else if(N==1){
| ^~~~
|
s050763380 | p03705 | C++ |
#include<iostream>
using namespace std;
int n,a,b;
int main()
{
cin>>n>>a>>b;
if(n==1)
{
if(a==b)
cout<<1;
else cout<<0;
}
else if
{
if(a==b||a>b)cout<<0;
else
{
cout<<(n-1)*b+a-(n-1)*a-b+1;
}
}
}
| a.cc: In function 'int main()':
a.cc:16:9: error: expected '(' before '{' token
16 | {
| ^
| (
|
s118393017 | p03705 | C++ | #include<bits/stdc++.h>
using namespace std;
int main(){
int64_t N,A,B;
cin>>N>>A>>B;
if(N==1){if(A==B)
cout<<1<<endl;
else
cout<<0<<endl;}
ele if(A<=B){ int64_t ans=(N-2)*(B-A)+1;
cout<<ans<<endl;}
else
cout<<0<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:10:2: error: 'ele' was not declared in this scope
10 | ele if(A<=B){ int64_t ans=(N-2)*(B-A)+1;
| ^~~
a.cc:12:3: error: 'else' without a previous 'if'
12 | else
| ^~~~
|
s865441730 | p03705 | C++ | #include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <iomanip>
using namespace std;
using ll = long long;
int main() {
ll n, a, b;
cin >> n >> a >> b;
cout << max(0, b * (n - 1) + a - a * (n - 1) - b + 1) << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:15:20: error: no matching function for call to 'max(int, ll)'
15 | cout << max(0, b * (n - 1) + a - a * (n - 1) - b + 1) << endl;
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:15:20: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
15 | cout << max(0, b * (n - 1) + a - a * (n - 1) - b + 1) << endl;
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:15:20: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
15 | cout << max(0, b * (n - 1) + a - a * (n - 1) - b + 1) << endl;
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
s005647614 | p03705 | C++ | v#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;
#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)
const ll MOD = 1000000007;
const ll INF = (ll) 1e15;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll N, A, B;
cin >> N >> A >> B;
if (A > B || (A != B && N == 1)) {
cout << 0 << endl;
return 0;
}
ll min = A * (N - 1) + B;
ll max = A + B * (N - 1);
cout << max - min + 1LL << endl;
return 0;
} | a.cc:1:2: error: stray '#' in program
1 | v#include <bits/stdc++.h>
| ^
a.cc:1:1: error: 'v' does not name a type
1 | v#include <bits/stdc++.h>
| ^
a.cc:6:9: error: 'pair' does not name a type
6 | typedef pair<ll, ll> pll;
| ^~~~
a.cc: In function 'int main()':
a.cc:16:5: error: 'cin' was not declared in this scope
16 | cin.tie(0);
| ^~~
a.cc:17:5: error: 'ios' has not been declared
17 | ios::sync_with_stdio(false);
| ^~~
a.cc:21:9: error: 'cout' was not declared in this scope
21 | cout << 0 << endl;
| ^~~~
a.cc:21:22: error: 'endl' was not declared in this scope
21 | cout << 0 << endl;
| ^~~~
a.cc:27:5: error: 'cout' was not declared in this scope
27 | cout << max - min + 1LL << endl;
| ^~~~
a.cc:27:32: error: 'endl' was not declared in this scope
27 | cout << max - min + 1LL << endl;
| ^~~~
|
s754111469 | p03705 | C++ |
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.*;
import java.util.stream.IntStream;
import java.util.stream.LongStream;
/**
* https://kenkoooo.com/atcoder/#/contest/show/9b08f47d-6fff-4714-8466-bd445f1efffa
*/
public class Main {
public Main() throws IOException {
}
public static void main(String[] args) throws IOException {
new Main().solve();
}
// private final InputStream in = Files.newInputStream(Paths.get("C:\\Users\\ryo.suzuki\\Downloads\\testcase_20"));
private final InputStream in = System.in;
private final PrintWriter out = new PrintWriter(System.out);
private final byte[] buffer = new byte[1024];
private int ptr = 0;
private int buflen = 0;
private void solve() throws IOException {
try {
// solveA();
// solveB();
solveC();
// solveD();
// solveE();
// solveF();
} finally {
if (in != null) {
in.close();
}
if (out != null) {
out.flush();
out.close();
}
}
}
// mods
long MOD = (long) Math.pow(10, 9) + 7;
/**
* https://atcoder.jp/contests/arc008/tasks/arc008_1
* A - たこ焼き買えるかな?
*/
private void solveA() {
int n = nextInt();
out.println(n / 10 * 100 + Math.min((n % 10) * 15, 100));
}
/**
* https://atcoder.jp/contests/abc120/tasks/abc120_c
* C - Unification
*/
private void solveB() {
String s = next();
int r = 0;
int b = 0;
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) == '0')
r++;
else
b++;
}
out.println(min(r, b) * 2);
}
/**
* https://atcoder.jp/contests/agc015/tasks/agc015_a
* A - A+...+B Problem
*/
private void solveC() {
long n = nextLong();
long a = nextLong();
long b = nextLong();
if (a > b || b - a > n) {
out.println(0);
} else if (a == b) {
out.println(1);
} else {
long min = (n - 1) * a + b;
long max = (n - 1) * b + a;
out.println(max - min + 1);
}
}
/**
* https://atcoder.jp/contests/abc127/tasks/abc127_d
* D - Integer Cards
*/
private void solveD() {
int n = nextInt();
int m = nextInt();
long[] a = LongStream.range(0, n).map(i -> nextLong()).sorted().toArray();
int[][] bc = IntStream.range(0, m).mapToObj(i -> new int[]{nextInt(), nextInt()}).sorted((x, y) -> -Integer.compare(x[1], y[1])).toArray(int[][]::new);
int idx = 0;
for (int[] item : bc) {
int cnt = item[0];
for (int i = 0; i < cnt; i++) {
if (idx >= n)
break;
if (item[1] <= a[idx])
break;
a[idx] = item[1];
idx++;
}
}
out.println(Arrays.stream(a).sum());
}
/**
* https://atcoder.jp/contests/agc032/tasks/agc032_b
* B - Balanced Neighbors
*/
private void solveE() {
}
/**
* https://atcoder.jp/contests/arc028/tasks/arc028_3
* C - 高橋王国の分割統治
*/
private void solveF() {
}
static final long CONST_INF = Long.MAX_VALUE / 4;
private static class VectorCalculation {
/**
* 点Pと線(AB)の距離
*
* @param p
* @param a
* @param b
* @return
*/
private double distanceDotAndLine(DoublePair p, DoublePair a, DoublePair b) {
DoublePair ab = new DoublePair(b.x - a.x, b.y - a.y);
DoublePair ap = new DoublePair(p.x - a.x, p.y - a.y);
// ベクトルAB、APの外積の絶対値が平行四辺形Dの面積になる
double d = Math.abs(crossVector(ab, ap));
double l = distanceVertex(a, b); // AB間の距離
double h = d / l;
return h;
}
/**
* 2点間距離
*
* @param p1
* @param p2
* @return
*/
private double distanceVertex(DoublePair p1, DoublePair p2) {
double dx = p1.x - p2.x;
double dy = p1.y - p2.y;
return Math.sqrt(dx * dx + dy * dy);
}
/**
* ベクトル外積
*
* @param vl
* @param vr
* @return
*/
private double crossVector(DoublePair vl, DoublePair vr) {
return vl.x * vr.y - vl.y * vr.x;
}
}
private static class DoublePair implements Comparable<DoublePair> {
double x;
double y;
public DoublePair(double k, double v) {
this.x = k;
this.y = v;
}
public int compareTo(DoublePair pair) {
return Double.compare(this.y, pair.y);
}
}
private static class SimplePair implements Comparable<SimplePair> {
long k;
long v;
public SimplePair(int k, int v) {
this.k = k;
this.v = v;
}
public SimplePair(long k, long v) {
this.k = k;
this.v = v;
}
public int compareTo(SimplePair pair) {
return Long.compare(this.v, pair.v);
}
}
private static class SimpleGraphNode {
private int n;
private Map<Integer, Integer> childs;
public SimpleGraphNode(int n) {
this.n = n;
childs = new HashMap<Integer, Integer>();
}
public void addChild(int child, int d) {
this.childs.put(child, d);
}
}
private static class SimpleGraph {
private Map<Integer, SimpleGraphNode> graph;
public SimpleGraph(int[][] list) {
graph = new HashMap<Integer, SimpleGraphNode>();
Arrays.stream(list).forEach(l -> {
int a = l[0];
int b = l[1];
int d = l[2];
graph.put(a, graph.getOrDefault(a, new SimpleGraphNode(a)));
graph.get(a).addChild(b, d);
graph.put(b, graph.getOrDefault(b, new SimpleGraphNode(b)));
graph.get(b).addChild(a, d);
});
}
public SimpleGraphNode getNode(int i) {
return graph.getOrDefault(i, new SimpleGraphNode(-1));
}
}
private static class GraphNode {
private long n;
private Map<Long, SimplePair> childs;
public GraphNode(long n) {
this.n = n;
childs = new TreeMap<Long, SimplePair>();
}
/**
* not update
*
* @param child
* @param d
*/
public void addChild(long child, long d) {
this.childs.put(child, this.childs.getOrDefault(child, new SimplePair(child, d)));
}
public SimplePair getChild(long child) {
return this.childs.getOrDefault(child, new SimplePair(child, CONST_INF));
}
}
private static class Graph {
private Map<Long, GraphNode> graph;
int n;
/**
* @param n 頂点数
* @param list
*/
public Graph(int n, int[][] list) {
this.n = n;
graph = new HashMap<Long, GraphNode>();
/*
隣接行列作成
0-indexed
*/
Arrays.stream(list).forEach(l -> {
long a = l[0] - 1;
long b = l[1] - 1;
long d = l[2];
graph.put(a, graph.getOrDefault(a, new GraphNode(a)));
graph.get(a).addChild(b, d);
graph.put(b, graph.getOrDefault(b, new GraphNode(b)));
graph.get(b).addChild(a, d);
});
/*
たどり着けない場所はCONST_INFで埋める
自分へはCOST=0でたどり着ける
*/
for (long i = 0; i < n; i++) {
graph.put(i, graph.getOrDefault(i, new GraphNode(i)));
GraphNode node = graph.get(i);
for (int j = 0; j < n; j++) {
if (i == j)
node.addChild(j, 0L);
else
node.addChild(j, CONST_INF);
}
}
}
/**
* ワーシャルフロイド
*/
public void warshallFloyd() {
for (long k = 0; k < n; k++) {
for (long i = 0; i < n; i++) {
for (long j = 0; j < n; j++) {
long min = Math.min(graph.get(i).getChild(j).v, graph.get(i).getChild(k).v + graph.get(k).getChild(j).v);
graph.get(i).getChild(j).v = min;
}
}
}
}
public void partialUpdateAndWarshallFloyd(long x, long y, long w) {
if (graph.get(x).getChild(y).v > w)
graph.get(x).getChild(y).v = graph.get(y).getChild(x).v = w;
long[] l = {x, y};
for (long k : l) {
for (long i = 0; i < n; i++) {
for (long j = 0; j < n; j++) {
if (graph.get(i).getChild(j).v > graph.get(i).getChild(k).v + graph.get(k).getChild(j).v) {
graph.get(i).getChild(j).v = graph.get(i).getChild(k).v + graph.get(k).getChild(j).v;
}
}
}
}
}
/**
* 2点間の距離
*
* @param from
* @param to
* @return
*/
public long getDistance(long from, long to) {
return graph.get(from).getChild(to).v;
}
}
public long calcSimpleCombination(long n, long m, long CONST_MOD) {
long mole = 1;
for (long i = 1; i <= n + m; i++) {
mole *= i;
mole %= CONST_MOD;
}
long deno = 1;
for (long i = 1; i <= n; i++) {
deno *= i;
deno %= CONST_MOD;
}
for (int i = 1; i <= m; i++) {
deno *= i;
deno %= CONST_MOD;
}
deno = modInverse(deno, CONST_MOD);
return (mole * deno) % CONST_MOD;
}
long abs(double x) {
return (long) Math.abs(x);
}
long round(double x) {
return Math.round(x);
}
long floor(double x) {
return (long) Math.floor(x);
}
long ceil(double x) {
return (long) Math.ceil(x);
}
double sqrt(double x) {
return Math.sqrt(x);
}
double pow(double x, double y) {
return Math.pow(x, y);
}
long pow(long x, long y) {
return (long) Math.pow(x, y);
}
int gcd(int a, int b) {
return b == 0 ? a : gcd(b, a % b);
}
long gcd(long a, long b) {
return b == 0 ? a : gcd(b, a % b);
}
long lcm(long a, long b) {
return a * b / gcd(a, b);
}
public long lcmMod(long... ab) {
Map<Long, Long> ps = new HashMap<Long, Long>();
for (int abl = 0; abl < ab.length; abl++) {
long target = ab[abl];
long l = target;
for (long p = 2; p * p <= l; p++) {
long cnt = 0;
while (target > 1 && target % p == 0) {
cnt++;
target /= p;
}
if (cnt == 0)
continue;
ps.put(p, Long.max(cnt, ps.getOrDefault(p, 0L)));
}
if (target > 1)
ps.put(target, Long.max(1, ps.getOrDefault(target, 0L)));
}
long res = 1L;
for (Map.Entry<Long, Long> e : ps.entrySet()) {
res *= powMod(e.getKey(), e.getValue());
res %= MOD;
}
return res;
}
int upperToInt(char a) {
return a - 'A';
}
int lowerToInt(char a) {
return a - 'a';
}
int numToInt(char a) {
return a - '0';
}
int charToInt(char a) {
return a >= 'a' ? lowerToInt(a) : a >= 'A' ? upperToInt(a) : numToInt(a);
}
char intToUpper(int a) {
return (char) (a + 'A');
}
char intToLower(int a) {
return (char) (a + 'a');
}
char intToNum(int a) {
return (char) (a + '0');
}
void reverse(String array[]) {
String reversed[] = new String[array.length];
for (int i = 0; i < array.length; i++) {
reversed[array.length - i - 1] = array[i];
}
for (int i = 0; i < array.length; i++) {
array[i] = reversed[i];
}
}
void reverse(int array[]) {
int reversed[] = new int[array.length];
for (int i = 0; i < array.length; i++) {
reversed[array.length - i - 1] = array[i];
}
for (int i = 0; i < array.length; i++) {
array[i] = reversed[i];
}
}
void reverse(long array[]) {
long reversed[] = new long[array.length];
for (int i = 0; i < array.length; i++) {
reversed[array.length - i - 1] = array[i];
}
for (int i = 0; i < array.length; i++) {
array[i] = reversed[i];
}
}
void reverse(double array[]) {
double reversed[] = new double[array.length];
for (int i = 0; i < array.length; i++) {
reversed[array.length - i - 1] = array[i];
}
for (int i = 0; i < array.length; i++) {
array[i] = reversed[i];
}
}
void reverse(boolean array[]) {
boolean reversed[] = new boolean[array.length];
for (int i = 0; i < array.length; i++) {
reversed[array.length - i - 1] = array[i];
}
for (int i = 0; i < array.length; i++) {
array[i] = reversed[i];
}
}
void fill(int array[][], int x) {
for (int a[] : array) {
Arrays.fill(a, x);
}
}
void fill(long array[][], long x) {
for (long a[] : array) {
Arrays.fill(a, x);
}
}
void fill(double array[][], double x) {
for (double a[] : array) {
Arrays.fill(a, x);
}
}
void fill(boolean array[][], boolean x) {
for (boolean a[] : array) {
Arrays.fill(a, x);
}
}
void fill(int array[][][], int x) {
for (int a[][] : array) {
fill(a, x);
}
}
void fill(long array[][][], long x) {
for (long a[][] : array) {
fill(a, x);
}
}
void fill(double array[][][], double x) {
for (double a[][] : array) {
fill(a, x);
}
}
void fill(boolean array[][][], boolean x) {
for (boolean a[][] : array) {
fill(a, x);
}
}
long L_INF = (long) 1e18 + 7;
boolean isINF(long a) {
return abs(a) > L_INF / 1000;
}
boolean isPlusINF(long a) {
return a > 0 && isINF(a);
}
boolean isMinusINF(long a) {
return isPlusINF(-a);
}
int I_INF = (int) 1e9 + 7;
boolean isINF(int a) {
return abs(a) > I_INF / 1000;
}
boolean isPlusINF(int a) {
return a > 0 && isINF(a);
}
boolean isMinusINF(int a) {
return isPlusINF(-a);
}
/**
* 指定したx以下の素数をリストアップする
*/
public long[] getPrimesUnderX(long x) {
return LongStream.rangeClosed(2, x)
.filter(i -> LongStream.rangeClosed(2, (long) Math.sqrt(i)).allMatch(j -> i % j != 0)).toArray();
}
public long mod(long i) {
return i % MOD + ((i % MOD) < 0 ? MOD : 0);
}
long powMod(long x, long y) {
if (y == 0) {
return 1;
} else {
long tmp = powMod(x, y / 2);
return mod(mod(tmp * tmp) * (y % 2 == 0 ? 1 : x));
}
}
long inv(long x) {
return powMod(x, MOD - 2);
}
int MAX_FACT = 5_000_100;
long fact[];
long invFact[];
/**
* Combination簡易版
* 5 C 2
* 異なる n個のものから r個を選ぶ組み合わせの総数 nCr を求めます。
* 5!(5*4*3*2*1)
* /
* 2!(2*1) * (5-2)!(3*2*1)
*
* @param n
* @param r
* @return
*/
private long getComb(int n, int r) {
long tmp = 1;
for (int i = 1; i <= r; i++) {
tmp *= n - i + 1;
tmp = mod(tmp);
tmp *= inv(i);
tmp = mod(tmp);
}
return tmp;
}
/**
* 階乗計算の事前累積和
* [1, 1, 2, 3, 4, 5, … FACTORIAL_NUM]
* mod済
*/
void prepareFact() {
fact = new long[MAX_FACT];
Arrays.fill(fact, 0);
invFact = new long[MAX_FACT];
Arrays.fill(invFact, 0);
fact[0] = 1;
int maxIndex = (int) min(MAX_FACT, (int) MOD);
for (int i = 1; i < maxIndex; i++) {
fact[i] = mod(fact[i - 1] * i);
}
invFact[maxIndex - 1] = inv(fact[maxIndex - 1]);
for (int i = maxIndex - 1; i > 0; i--) {
invFact[i - 1] = mod(invFact[i] * i);
}
}
/**
* 順列
* nPk -> n! / (n-k)!
*
* @param n
* @param r
* @return
*/
long permutation(int n, int r) {
if (n < 0 || r < 0 || n < r) {
return 0;
}
return mod(fact[n] * invFact[n - r]);
}
/**
* 組み合わせ
* nCk -> n! / k!・(n-k)!
*
* @param n
* @param r
* @return
*/
long combination(int n, int r) {
if (n < 0 || r < 0 || n < r) {
return 0;
}
return mod(permutation(n, r) * invFact[r]);
}
/**
* 重複組合せ nHr (同次積)
* nHr = (n+r-1)Cr
* 異なるn個のものから重複を許してr個取る組合せの総数
* 例:
* リンゴ,ミカン,牛肉の3種類の果物があります.これらの中から6個の食材を買って帰ります.
* このとき,何通りの買い方がありますか?ただし,含まれない食材があってもよいものとします
*
* @param n
* @param r
* @return
*/
long homogeneousProduct(int n, int r) {
return combination((n - 1) + r, r);
}
/**
* 多項係数
* 文字aをp個,bをq個,cをr個, dをs個 あわせてn個を1列に並べるときの並べ方
* n! / p!・q!・r!・s!
*
* @param n
* @param strNum
* @param mod
* @return
*/
/**
* フェルマーの小定理を用いて逆元を求める。
* ある数xのmod p(pは素数)の逆数x'はx' = x^(p-2)
* 繰り返し二乗法を用いて計算する。
* http://satanic0258.hatenablog.com/entry/2016/04/29/004730
* {@link BigInteger#modInverse(BigInteger)}とどちらが速いか?
*
* @param x
* @return
*/
private long modInverse(long x, long mod) {
long res = 1L;
long k = mod - 2L;
long y = x;
while (k != 0) {
if (k % 2 != 0) {
res = (res * y) % mod;
}
y = (y * y) % mod;
k /= 2;
}
return res;
}
private boolean hasNextByte() {
if (ptr < buflen) {
return true;
} else {
ptr = 0;
try {
buflen = in.read(buffer);
} catch (IOException e) {
e.printStackTrace();
}
if (buflen <= 0) {
return false;
}
}
return true;
}
private int readByte() {
if (hasNextByte())
return buffer[ptr++];
else
return -1;
}
private static boolean isPrintableChar(int c) {
return 33 <= c && c <= 126;
}
private void skipUnprintable() {
while (hasNextByte() && !isPrintableChar(buffer[ptr]))
ptr++;
}
public boolean hasNext() {
skipUnprintable();
return hasNextByte();
}
public int nextInt() {
return Integer.parseInt(next());
}
public double nextDouble() {
return Double.parseDouble(next());
}
public String next() {
if (!hasNext())
throw new NoSuchElementException();
StringBuilder sb = new StringBuilder();
int b = readByte();
while (isPrintableChar(b)) {
sb.appendCodePoint(b);
b = readByte();
}
return sb.toString();
}
public long nextLong() {
if (!hasNext())
throw new NoSuchElementException();
long n = 0;
boolean minus = false;
int b = readByte();
if (b == '-') {
minus = true;
b = readByte();
}
if (b < '0' || '9' < b) {
throw new NumberFormatException();
}
while (true) {
if ('0' <= b && b <= '9') {
n *= 10;
n += b - '0';
} else if (b == -1 || !isPrintableChar(b)) {
return minus ? -n : n;
} else {
throw new NumberFormatException();
}
b = readByte();
}
}
public long min(long... v) {
long min = Long.MAX_VALUE;
for (long i : v) min = Math.min(min, i);
return min;
}
public long max(long... v) {
long max = Long.MIN_VALUE;
for (long i : v) max = Math.max(max, i);
return max;
}
}
| a.cc:2:1: error: 'import' does not name a type
2 | import java.io.IOException;
| ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
3 | import java.io.InputStream;
| ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
4 | import java.io.PrintWriter;
| ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: 'import' does not name a type
5 | import java.math.BigInteger;
| ^~~~~~
a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:6:1: error: 'import' does not name a type
6 | import java.nio.file.Files;
| ^~~~~~
a.cc:6:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:7:1: error: 'import' does not name a type
7 | import java.nio.file.Paths;
| ^~~~~~
a.cc:7:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:8:1: error: 'import' does not name a type
8 | import java.util.*;
| ^~~~~~
a.cc:8:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:9:1: error: 'import' does not name a type
9 | import java.util.stream.IntStream;
| ^~~~~~
a.cc:9:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:10:1: error: 'import' does not name a type
10 | import java.util.stream.LongStream;
| ^~~~~~
a.cc:10:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:15:1: error: expected unqualified-id before 'public'
15 | public class Main {
| ^~~~~~
|
s420324380 | p03705 | C++ | #include <bits/stdc++.h>
using namespace std;
//def
#define debug(x) cout << #x << ": " << x << '\n'
#define out(x) cout << x << '\n'
#define repeat(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define revrepeat(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
constexpr int MOD = 1e9 + 7;
constexpr int INF = __INT_MAX__; // 2^31 - 1
constexpr long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
constexpr int MAX_N = 1e5 + 5;
constexpr double PI = acos(-1);
template <class T>
inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T>
inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
long long fac[MAX_N], finv[MAX_N], inv[MAX_N];
// テーブルを作る前処理 from: https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX_N; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
long long modpow(long long m, long long p) {
if (p == 0) return 1;
if (p % 2)
return m * modpow(m, p - 1) % MOD;
else {
long res = modpow(m, p / 2);
return res * res % MOD;
}
}
// 二項係数計算
long long COM(int n, int k) {
if (n < k) return 0;
if (n < 0 || k < 0) return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// factorial
long long fact(int n) {
if (n == 1) return fac[n] = 1;
if (fac[n]) return fac[n];
return fac[n] = (fact(n - 1) * n) % MOD;
}
// https://qiita.com/drken/items/cce6fc5c579051e64fab
// UnionFind<int> uf(n);
template <class Abel>
struct UnionFind {
vector<int> par;
vector<int> rank;
vector<int> size;
vector<Abel> diff_weight;
UnionFind(int n = 1, Abel SUM_UNITY = 0) {
init(n, SUM_UNITY);
}
void init(int n = 1, Abel SUM_UNITY = 0) {
par.resize(n);
rank.resize(n);
size.resize(n);
diff_weight.resize(n);
for (int i = 0; i < n; ++i)
par[i] = i, rank[i] = 0, size[i] = 1, diff_weight[i] = SUM_UNITY;
}
int root(int x) {
if (par[x] == x) {
return x;
} else {
int r = root(par[x]);
diff_weight[x] += diff_weight[par[x]]; // path compression
return par[x] = r;
}
}
// returns size of connected-tree number
int get_size(int x) {
return size[root(x)];
}
Abel weight(int x) {
root(x);
return diff_weight[x];
}
bool is_same(int x, int y) {
return root(x) == root(y);
}
bool merge(int x, int y, Abel w) {
w += weight(x);
w -= weight(y);
x = root(x);
y = root(y);
if (x == y) return false;
if (rank[x] < rank[y]) swap(x, y), w = -w;
if (rank[x] == rank[y]) ++rank[x];
par[y] = x;
size[x] = size[y] = size[x] + size[y];
diff_weight[y] = w;
return true;
}
Abel diff(int x, int y) {
return weight(y) - weight(x);
}
};
long long gcd(long long a, long long b) {
if (b == 0) return a;
return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
return a / gcd(a, b) * b;
}
// factorization O(sqrt(n))
map<long long, long long> prime_factor(long long n) {
map<long long, long long> res;
for (long long i = 2; i * i <= n; i++) {
while (n % i == 0) {
++res[i];
n /= i;
}
}
if (n != 1) res[n] = 1;
return res;
}
// 回文判定
bool is_palindrome(string const &s) {
return s == string(s.rbegin(), s.rend());
}
vi ans(100005);
vi seen(100005);
void dfs(int curr, int prev, int color, int color_size, vii &node, map<P, int> &dict) {
seen[curr] = true;
ans[dict[P(curr, prev)]] = color;
foreach (e, node[curr]) {
if (!seen[e]) {
color++;
if (color > color_size) color = 1;
dfs(e, curr, color, color_size, node, dict);
}
}
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n, a, b;
cin >> n >> a >> b;
ll ans = 0;
if (n == 1){
if (a != b)
ans = 0;
else
ans = 1;
}
if (n >= 2)
ans = b * (n - 2) - a * (n - 2) + 1;
out(max(0LL, ans);
}
| a.cc:203:2: error: unterminated argument list invoking macro "out"
203 | }
| ^
a.cc: In function 'int main()':
a.cc:202:5: error: 'out' was not declared in this scope
202 | out(max(0LL, ans);
| ^~~
a.cc:202:8: error: expected '}' at end of input
202 | out(max(0LL, ans);
| ^
a.cc:187:12: note: to match this '{'
187 | int main() {
| ^
|
s582361178 | p03705 | C++ | N,A,B=map(int,input().split())
m=A*(N-1)+B
M=A+B*(N-1)
ans=M-m+1
ans=max(ans,0)
print(ans) | a.cc:1:1: error: 'N' does not name a type
1 | N,A,B=map(int,input().split())
| ^
|
s991293984 | p03705 | C++ | #include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#define rip(i,n) for(int i=0;i<n;i++)
#define ll long long
#define lb long double
#define vec vector<int>
using namespace std;
int main() {
int n, a, b;
cin >> n >> a >> b;
if (a > b)cout << "0" << endl;
else if (n == 1) {
if (a == b) {
cout << "1" << endl;
}
else {
cout << "0" << endl;
}
}
else if (n == 2)cout << "2" << endl;
else {
cout << (n - 2)(b - a) + 1 << endl;
}
} | a.cc: In function 'int main()':
a.cc:27:32: error: expression cannot be used as a function
27 | cout << (n - 2)(b - a) + 1 << endl;
| ~~~~~~~^~~~~~~
|
s348408484 | p03705 | C++ | #include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;
vector<int>bitSearch(int bit,int n){
vector<int>S,False(1,-1);
rep(i,n)if(bit&(1<<i))S.push_back(i);
return S;
}
template<typename A,size_t N,typename T>
void Fill(A(&array)[N],const T &val){
fill((T*)array,(T*)(array+N),val);
}
int main(){
ll n, a, b;
cin >> n >> a >> b;
ll l = b + a * (n-1), r = a + b * (n-1);
cout << min(0 , r - l + 1) << endl;
} | a.cc: In function 'int main()':
a.cc:49:16: error: no matching function for call to 'min(int, ll)'
49 | cout << min(0 , r - l + 1) << endl;
| ~~~^~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:49:16: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
49 | cout << min(0 , r - l + 1) << endl;
| ~~~^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
from a.cc:7:
/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:49:16: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
49 | cout << min(0 , r - l + 1) << endl;
| ~~~^~~~~~~~~~~~~~~
|
s660043344 | p03705 | C++ | #include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main() {
ll n,a,b;
cin >> n >> a >> b;
cout << (n-2)*(b-a)+1 << endl;
if(n==1&&a!=b){
cout << 0 << endl;
} | a.cc: In function 'int main()':
a.cc:21:2: error: expected '}' at end of input
21 | }
| ^
a.cc:15:12: note: to match this '{'
15 | int main() {
| ^
|
s408726055 | p03705 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
long long N, A, B;
cin >> N >> A >> B;
if(N == 1 && B != A){
print(0);
return 0;
}else if(N == 1 && A == B){
print(1);
return 0;
}else if(N > 1 && A > B){
print(0);
return 0;
}else{
print((B - A) * (N - 2) + 1);
return 0;
}
}
| a.cc: In function 'int main()':
a.cc:9:3: error: 'print' was not declared in this scope; did you mean 'rint'?
9 | print(0);
| ^~~~~
| rint
a.cc:12:3: error: 'print' was not declared in this scope; did you mean 'rint'?
12 | print(1);
| ^~~~~
| rint
a.cc:15:3: error: 'print' was not declared in this scope; did you mean 'rint'?
15 | print(0);
| ^~~~~
| rint
a.cc:18:3: error: 'print' was not declared in this scope; did you mean 'rint'?
18 | print((B - A) * (N - 2) + 1);
| ^~~~~
| rint
|
s741922532 | p03705 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
ll N, A, B;
cin >> N >> A >> B;
if(N == 1 && B != A){
print(0);
return 0;
}else if(N == 1 && A == B){
print(1);
return 0;
}else if(N > 1 && A > B){
print(0);
return 0;
}else{
print((B - A) * (N - 2) + 1);
return 0;
}
}
| a.cc: In function 'int main()':
a.cc:5:1: error: 'll' was not declared in this scope
5 | ll N, A, B;
| ^~
a.cc:6:8: error: 'N' was not declared in this scope
6 | cin >> N >> A >> B;
| ^
a.cc:6:13: error: 'A' was not declared in this scope
6 | cin >> N >> A >> B;
| ^
a.cc:6:18: error: 'B' was not declared in this scope
6 | cin >> N >> A >> B;
| ^
a.cc:9:3: error: 'print' was not declared in this scope; did you mean 'rint'?
9 | print(0);
| ^~~~~
| rint
a.cc:12:3: error: 'print' was not declared in this scope; did you mean 'rint'?
12 | print(1);
| ^~~~~
| rint
a.cc:15:3: error: 'print' was not declared in this scope; did you mean 'rint'?
15 | print(0);
| ^~~~~
| rint
a.cc:18:3: error: 'print' was not declared in this scope; did you mean 'rint'?
18 | print((B - A) * (N - 2) + 1);
| ^~~~~
| rint
|
s507942012 | p03705 | C++ | #include<bits/stdc++.h>
#include <iostream>
#include <vector>
using namespace std;
int main(){
std::ios::sync_with_stdio(false);
std::cin.tie(0);
long long int a,b,n;
cin>>n>>a>>b;
if(a>b || (n==1 a<b)){
printf("0\n");
}else if(a==b || n==1 || n==2){
printf("1\n");
}else{
printf("%lld\n",(b-a)*(n-2)+1);
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:10:20: error: expected ')' before 'a'
10 | if(a>b || (n==1 a<b)){
| ~ ^~
| )
a.cc:12:6: error: expected ')' before 'else'
12 | }else if(a==b || n==1 || n==2){
| ^~~~
| )
a.cc:10:7: note: to match this '('
10 | if(a>b || (n==1 a<b)){
| ^
|
s285275824 | p03705 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int n,a,b;
cin >> n >> a >> b;
if(n==1){
if(a==b) cout << 1 << endl;
else cout << 0 << endl;
}
else cout << max(0LL,(b-a)*(n-2)+1) << endl;
} | a.cc: In function 'int main()':
a.cc:11:21: error: no matching function for call to 'max(long long int, int)'
11 | else cout << max(0LL,(b-a)*(n-2)+1) << endl;
| ~~~^~~~~~~~~~~~~~~~~~~
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:11:21: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
11 | else cout << max(0LL,(b-a)*(n-2)+1) << endl;
| ~~~^~~~~~~~~~~~~~~~~~~
/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:11:21: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
11 | else cout << max(0LL,(b-a)*(n-2)+1) << endl;
| ~~~^~~~~~~~~~~~~~~~~~~
|
s066060856 | p03705 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int n,a,b;
cin >> n >> a >> b;
if(a>b){
cout << 0 << endl;
return 0;
}
if(n==1&&a==b){
cout << 1 << endl;
return 0;
}
if(n==1&&b!=a){
cout << 0 << endl;
return 0;
}
else{
cout << (b-a)(n-2)+1 << endl;
return 0;
}
} | a.cc: In function 'int main()':
a.cc:20:22: error: expression cannot be used as a function
20 | cout << (b-a)(n-2)+1 << endl;
| ~~~~~^~~~~
|
s826802265 | p03705 | C++ | ト時間: 2017-05-27(土) 21:00 ~ 2017-05-27(土) 22:50 (110分)AtCoderホームへ戻る
トップ
問題
質問
提出
提出結果
順位表
バーチャル順位表
コードテスト
解説
提出 #10808752
ソースコード
Copy
Copy
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#include <cmath>
#include <string>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define Cout(s) cout<<s<<endl
typedef long long ll;
using namespace std;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================
ll a = 0, b = 0, c, d, n, k = 0;
string s, t;
int main()
{
ll n;
cin >> n >> a >> b;
ll ans = b * (n - 1) + a - (a * (n - 1) + b)+1;
if (ans <= 0)
cout << "0" << endl;
else
cout << ans << endl;
return 0;
} | a.cc:11:6: error: stray '#' in program
11 | 提出 #10808752
| ^
a.cc:1:1: error: '\U000030c8\U00006642\U00009593' does not name a type
1 | ト時間: 2017-05-27(土) 21:00 ~ 2017-05-27(土) 22:50 (110分)AtCoderホームへ戻る
| ^~~~~~
In file included from /usr/include/wchar.h:53,
from /usr/include/c++/14/cwchar:44,
from /usr/include/c++/14/bits/postypes.h:40,
from /usr/include/c++/14/iosfwd:42,
from /usr/include/c++/14/ios:40,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:18:
/usr/include/x86_64-linux-gnu/bits/types/mbstate_t.h:6:9: error: '__mbstate_t' does not name a type
6 | typedef __mbstate_t mbstate_t;
| ^~~~~~~~~~~
/usr/include/wchar.h:104:59: error: 'size_t' has not been declared
104 | const wchar_t *__restrict __src, size_t __n)
| ^~~~~~
/usr/include/wchar.h:109:8: error: 'size_t' does not name a type
109 | extern size_t wcslcpy (wchar_t *__restrict __dest,
| ^~~~~~
/usr/include/wchar.h:61:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
60 | # include <bits/types/locale_t.h>
+++ |+#include <cstddef>
61 | #endif
/usr/include/wchar.h:115:8: error: 'size_t' does not name a type
115 | extern size_t wcslcat (wchar_t *__restrict __dest,
| ^~~~~~
/usr/include/wchar.h:115:8: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/wchar.h:126:59: error: 'size_t' has not been declared
126 | const wchar_t *__restrict __src, size_t __n)
| ^~~~~~
/usr/include/wchar.h:133:63: error: 'size_t' has not been declared
133 | extern int wcsncmp (const wchar_t *__s1, const wchar_t *__s2, size_t __n)
| ^~~~~~
/usr/include/wchar.h:142:25: error: 'size_t' has not been declared
142 | size_t __n) __THROW;
| ^~~~~~
/usr/include/wchar.h:150:27: error: 'size_t' has not been declared
150 | size_t __n, locale_t __loc) __THROW;
| ^~~~~~
/usr/include/wchar.h:159:8: error: 'size_t' does not name a type
159 | extern size_t wcsxfrm (wchar_t *__restrict __s1,
| ^~~~~~
/usr/include/wchar.h:159:8: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/wchar.h:174:8: error: 'size_t' does not name a type
174 | extern size_t wcsxfrm_l (wchar_t *__s1, const wchar_t *__s2,
| ^~~~~~
/usr/include/wchar.h:174:8: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/wchar.h:212:8: error: 'size_t' does not name a type
212 | extern size_t wcscspn (const wchar_t *__wcs, const wchar_t *__reject)
| ^~~~~~
/usr/include/wchar.h:212:8: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/wchar.h:216:8: error: 'size_t' does not name a type
216 | extern size_t wcsspn (const wchar_t *__wcs, const wchar_t *__accept)
| ^~~~~~
/usr/include/wchar.h:216:8: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/wchar.h:247:8: error: 'size_t' does not name a type
247 | extern size_t wcslen (const wchar_t *__s) __THROW __attribute_pure__;
| ^~~~~~
/usr/include/wchar.h:247:8: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/wchar.h:265:8: error: 'size_t' does not name a type
265 | extern size_t wcsnlen (const wchar_t *__s, size_t __maxlen)
| ^~~~~~
/usr/include/wchar.h:265:8: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/wchar.h:272:59: error: 'size_t' has not been declared
272 | extern "C++" wchar_t *wmemchr (wchar_t *__s, wchar_t __c, size_t __n)
| ^~~~~~
/usr/include/wchar.h:275:38: error: 'size_t' has not been declared
275 | size_t __n)
| ^~~~~~
/usr/include/wchar.h:283:63: error: 'size_t' has not been declared
283 | extern int wmemcmp (const wchar_t *__s1, const wchar_t *__s2, size_t __n)
| ^~~~~~
/usr/include/wchar.h:288:58: error: 'size_t' has not been declared
288 | const wchar_t *__restrict __s2, size_t __n) __THROW;
| ^~~~~~
/usr/include/wchar.h:292:63: error: 'size_t' has not been declared
292 | extern wchar_t *wmemmove (wchar_t *__s1, const wchar_t *__s2, size_t __n)
| ^~~~~~
/usr/include/wchar.h:296:53: error: 'size_t' has not been declared
296 | extern wchar_t *wmemset (wchar_t *__s, wchar_t __c, size_t __n) __THROW;
| ^~~~~~
/usr/include/wchar.h:302:59: error: 'size_t' has not been declared
302 | const wchar_t *__restrict __s2, size_t __n)
| ^~~~~~
/usr/include/wchar.h:317:27: error: 'mbstate_t' does not name a type
317 | extern int mbsinit (const mbstate_t *__ps) __THROW __attribute_pure__;
| ^~~~~~~~~
/usr/include/wchar.h:321:8: error: 'size_t' does not name a type
321 | extern size_t mbrtowc (wchar_t *__restrict __pwc,
| ^~~~~~
/usr/include/wchar.h:321:8: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/wchar.h:326:8: error: 'size_t' does not name a type
326 | extern size_t wcrtomb (char *__restrict __s, wchar_t __wc,
| ^~~~~~
/usr/include/wchar.h:326:8: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/wchar.h:330:8: error: 'size_t' does not name a type
330 | extern size_t __mbrlen (const char *__restrict __s, size_t __n,
| ^~~~~~
/usr/include/wchar.h:330:8: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/wchar.h:332:8: error: 'size_t' does not name a type
332 | extern size_t mbrlen (const char *__restrict __s, size_t __n,
| ^~~~~~
/usr/include/wchar.h:332:8: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/wchar.h:362:8: error: 'size_t' does not name a type
362 | extern size_t mbsrtowcs (wchar_t *__restrict __dst,
| ^~~~~~
/usr/include/wchar.h:362:8: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/wchar.h:368:8: error: 'size_t' does not name a type
368 | extern size_t wcsrtombs (char *__restrict __dst,
| ^~~~~~
/usr/include/wchar.h:368:8: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/wchar.h:376:8: error: 'size_t' does not name a type
376 | extern size_t mbsnrtowcs (wchar_t *__restrict __dst,
| ^~~~~~
/usr/include/wchar.h:376:8: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/wchar.h:382:8: error: 'size_t' does not name a type
382 | extern size_t wcsnrtombs (char *__restrict __dst,
| ^~~~~~
/usr/include/wchar.h:382:8: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/wchar.h:396:42: error: 'size_t' has not been declared
396 | extern int wcswidth (const wchar_t *__s, size_t __n) __THROW;
| ^~~~~~
/usr/include/wchar.h:695:59: error: 'size_t' has not been declared
695 | const wchar_t *__restrict __src, size_t __n)
| ^~~~~~
/usr/include/wchar.h:718:8: error: '__FILE' does not name a type; did you mean 'EMFILE'?
718 | extern __FILE *open_wmemstream (wchar_t **__bufloc, size_t *__sizeloc) __THROW
| ^~~~~~
| EMFILE
/usr/include/wchar.h:725:19: error: '__FILE' was not declared in this scope; did you mean 'EMFILE'?
725 | extern int fwide (__FILE *__fp, int __mode) __THROW;
| ^~~~~~
| EMFILE
/usr/include/wchar.h:725:27: error: '__fp' was not declared in this scope
725 | extern int fwide (__FILE *__fp, int __mode) __THROW;
| ^~~~
/usr/include/wchar.h:725:33: error: expected primary-expression before 'int'
725 | extern int fwide (__FILE *__fp, int __mode) __THROW;
| ^~~
/usr/include/wchar.h:725:43: error: expression list treated as compound expression in initializer [-fpermissive]
725 | extern int fwide (__FILE *__fp, int __mode) __THROW;
| ^
/usr/include/wchar.h:732:22: error: '__FILE' was not declared in this scope; did you mean 'EMFILE'?
732 | extern int fwprintf (__FILE *__restrict __stream,
| ^~~~~~
| EMFILE
/usr/include/wchar.h:732:30: error: expected primary-expression before '__restrict'
732 | extern int fwprintf (__FILE *__restrict __stream,
| ^~~~~~~~~~
/usr/include/wchar.h:733:22: error: expected primary-expression before 'const'
733 | const wchar_t *__restrict __format, ...)
| ^~~~~
/usr/include/w |
s913321738 | p03705 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
int solve()
{
ll n,a,b;cin>>n>>a>>b;
if(a>b)return 0;
if(a!=b&&n==1)return 0;
if(a==b&&n==1)return 1;
return max(0,(n-2)*(b-a)+1);
}
int main()
{
cin.tie(0);
ios::sync_with_stdio(false);
cout<<solve()<<endl;
return 0;
} | a.cc: In function 'int solve()':
a.cc:13:15: error: no matching function for call to 'max(int, ll)'
13 | return max(0,(n-2)*(b-a)+1);
| ~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h: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:13:15: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
13 | return max(0,(n-2)*(b-a)+1);
| ~~~^~~~~~~~~~~~~~~~~
/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:13:15: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
13 | return max(0,(n-2)*(b-a)+1);
| ~~~^~~~~~~~~~~~~~~~~
|
s269484886 | p03705 | C++ | #include<iostream>
using namespace std;
int n,a,b;
int rs;
bool v[1000000010];
void cdt(int ll,int t)
{
if(t<n)
for(int i=a;i<=b;i++)
cdt(ll+i,t+1);
else
{
if(v[ll]=!=1)
{v[ll]=1;rs++;}
}
}
int main()
{
rs=0;
cin>>n>>a>>b;
if(n==1){if(a==b)rs=1;}
else if(n==2){if(a<b)rs=1;}
else if(n>=3&&a<=b)
{
cdt(a+b,2);
}
cout<<rs<<endl;
}
| a.cc: In function 'void cdt(int, int)':
a.cc:14:26: error: expected primary-expression before '!=' token
14 | if(v[ll]=!=1)
| ^~
|
s021161082 | p03705 | C++ | // 015 AGC A - A+...+B Problem 2017/05/27
#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
using namespace std;
typedef long long int int64;
typedef unsigned long long uint64;
int main(){
int n; cin >> n;
int a , b; cin >> a >> b;
cout << ( b - a)( n - 2 ) + 1 << endl;
}
| a.cc: In function 'int main()':
a.cc:11:21: error: expression cannot be used as a function
11 | cout << ( b - a)( n - 2 ) + 1 << endl;
| ~~~~~~~~^~~~~~~~~
|
s338377120 | p03705 | C++ | //#include<bits/stdc++.h>
#include<cstdio>
#include<cmath>
#include<iostream>
using namespace std;
const int maxn = 1000;
int a[maxn];
int main(){
int n, a, b;
cin >> n >> a >> b;
longlong ans =0;
if(a <= b && n > 1){
ans = (long long )(b-a)*(n-2)+1;
}if(n == 1 && a == b) ans =1;
cout << ans;
return 0;
}
| a.cc: In function 'int main()':
a.cc:13:5: error: 'longlong' was not declared in this scope
13 | longlong ans =0;
| ^~~~~~~~
a.cc:16:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
16 | ans = (long long )(b-a)*(n-2)+1;
| ^~~
| abs
a.cc:18:27: error: 'ans' was not declared in this scope; did you mean 'abs'?
18 | }if(n == 1 && a == b) ans =1;
| ^~~
| abs
a.cc:20:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
20 | cout << ans;
| ^~~
| abs
|
s923764026 | p03705 | C++ | //#include<bits/stdc++.h>
#include<cstdio>
#include<cmath>
#include<iostream>
using namespace std;
const int maxn = 1000;
int a[maxn];
int main(){
int n, a, b;
cin >> n >> a >> b;
longlong ans =0;
if(a <= b && n > 1){
ans = (long long )(b-a)*(n-2)+1
}if(n == 1 && a == b) ans =1;
cout << ans;
return 0;
}
| a.cc: In function 'int main()':
a.cc:13:5: error: 'longlong' was not declared in this scope
13 | longlong ans =0;
| ^~~~~~~~
a.cc:16:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
16 | ans = (long long )(b-a)*(n-2)+1
| ^~~
| abs
a.cc:18:27: error: 'ans' was not declared in this scope; did you mean 'abs'?
18 | }if(n == 1 && a == b) ans =1;
| ^~~
| abs
a.cc:20:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
20 | cout << ans;
| ^~~
| abs
|
s676917487 | p03705 | C++ | #include<bits/stdc++.h>
#define sr register short
#define su unsigned short
#define r register int
#define u unsigned int
#define ll long long
#define llr register long long
#define llu unsigned long long
#define lf double
#define Lf long double
using namespace std;
int main()
{
/*#ifndef ONLINE_JUDGE
freopen("cpp.in","r",stdin);
#endif*/
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
ll n,a,b;
scanf("%lld%lld%lld",&n,&a,&b);
printf("%lld",max(0,(n-2)*(b-a)+1));
puts("");
return 0;
} | a.cc: In function 'int main()':
a.cc:21:22: error: no matching function for call to 'max(int, long long int)'
21 | printf("%lld",max(0,(n-2)*(b-a)+1));
| ~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h: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:21:22: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
21 | printf("%lld",max(0,(n-2)*(b-a)+1));
| ~~~^~~~~~~~~~~~~~~~~
/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:21:22: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
21 | printf("%lld",max(0,(n-2)*(b-a)+1));
| ~~~^~~~~~~~~~~~~~~~~
|
s533832537 | p03705 | C++ | #include <bits/stdc++.h>
using namespace std
int main(){
int N,A,B;cin>>N>>A>>B;
if(A>B)cout<<"0"<<endl;
else if(N==1){
if(A==B)cout<<"1"<<endl;
else cout<<"0"<<endl;
}
else cout<<(N-2)*(B-A)+1<<endl;
} | a.cc:2:20: error: expected ';' before 'int'
2 | using namespace std
| ^
| ;
3 | int main(){
| ~~~
|
s573760258 | p03705 | C++ | #include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <cstring>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <stack>
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,A,B;
scanf("%d%d%d",&N,&A,&B);
if(B-A<0){
printf("0\n");
return 0;
}
if(N==1&&(B-A!=0)){
printf("0\n");
return 0;
}
B=B-A;a
A=0;
long long max=(long long)(N-1)*B,min=(long long)B;
printf("%lld\n",max-min+1);
} | a.cc: In function 'int main()':
a.cc:24:15: error: 'a' was not declared in this scope
24 | B=B-A;a
| ^
|
s577813952 | p03705 | C++ | #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <numeric>
#include <complex>
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
using namespace std;
typedef long long ll;
int main(){
ll n, a, b;
cin >> n >> a >> b;
if(a>b){
cout << 0 << endl;
return 0;
}
else{
cout << max(0,(n-2)*(b-a)+1) << endl;
return 0;
}
}
| a.cc: In function 'int main()':
a.cc:31:20: error: no matching function for call to 'max(int, ll)'
31 | cout << max(0,(n-2)*(b-a)+1) << endl;
| ~~~^~~~~~~~~~~~~~~~~
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:31:20: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
31 | cout << max(0,(n-2)*(b-a)+1) << endl;
| ~~~^~~~~~~~~~~~~~~~~
/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:4:
/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:31:20: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
31 | cout << max(0,(n-2)*(b-a)+1) << endl;
| ~~~^~~~~~~~~~~~~~~~~
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.