QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#520240#8008. Fortune Wheelhanmm81Compile Error//C++141.9kb2024-08-15 11:56:592024-08-15 11:56:59

Judging History

你现在查看的是最新测评结果

  • [2024-08-15 11:56:59]
  • 评测
  • [2024-08-15 11:56:59]
  • 提交

answer

#include <bits/stdc++.h>
#define int __int128
#define pii pair<int,int>
#define fi first
#define se second
using namespace std;
struct fen{
	int up,down;
	fen(int p=0,int q=1){
		int t = __gcd(p,q);
		p /= t,q /= t;
		up = abs(p),down = abs(q);
		if (p * q < 0) up = -up;
	}
	double show(){
		return 1.0*up/down;
	}
	bool operator>(const fen & a){
		return (up*a.down > a.up*down);
	}
	bool operator<(const fen & a){
		return (up*a.down < a.up*down);
	}
	fen operator+(const fen & a){
		return fen(a.up*down+up*a.down,down*a.down);
	}
	fen operator+=(const fen & a){
		return *this = fen(a.up*down+up*a.down,down*a.down);
	}
	fen operator-(const fen & a){
		return fen(up*a.down-a.up*down,down*a.down);
	}
	fen operator-=(const fen & a){
		return *this = fen(up*a.down-a.up*down,down*a.down);
	}
	fen operator*(const fen & a){
		return fen(a.up*up,down*a.down);
	}
	fen operator*=(const fen & a){
		return *this = fen(a.up*up,down*a.down);
	}
	fen operator/(const fen & a){
		return fen(a.down*up,a.up*down);
	}
	fen operator/=(const fen & a){
		return *this=*this/a;
	}
	
}ans;
int dist[100005],n,x,k,a[505],cnt,pre[100005];
priority_queue<pii> p;
signed main(){
	long long _n,_x,_k,_a;
	cin >> _n >> _x >> _k;n=_n;x=_x;k=_k;
	for (int i = 1;i < n;i++) dist[i] = 0x3f3f3f3f3f3f3f3f;
	for (int i = 1;i <= k;i++) cin >> _a,a[i]=_a;
	dist[0] = 0,p.push({0,0});
	while (!p.empty()){
		pii top = p.top();
		p.pop();
		for (int i = 1;i <= k;i++){
			if (dist[(top.se-a[i]+n)%n] > 1-top.fi) p.push(make_pair(-(dist[(top.se-a[i]+n)%n] = 1-top.fi),(top.se-a[i]+n)%n));
		}
	}
	ans.up = dist[x];
	sort(dist,dist+n),pre[0] = dist[0];
	for (int i = 0;i < n;i++){
		if (i > 0) pre[i] = pre[i-1] + dist[i];
		if (ans > fen(pre[i]+n,i+1)) ans = fen(pre[i]+n,i+1);
	}
	long long up=ans.up,dn=ans.down;
	cout << up << " " << dn;
	return 0;
}

Details

answer.code: In constructor ‘fen::fen(__int128, __int128)’:
answer.code:12:25: error: call of overloaded ‘abs(__int128&)’ is ambiguous
   12 |                 up = abs(p),down = abs(q);
      |                      ~~~^~~
In file included from /usr/include/c++/13/cstdlib:79,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:42,
                 from answer.code:1:
/usr/include/stdlib.h:840:12: note: candidate: ‘int abs(int)’
  840 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |            ^~~
In file included from /usr/include/c++/13/cstdlib:81:
/usr/include/c++/13/bits/std_abs.h:79:3: note: candidate: ‘constexpr long double std::abs(long double)’
   79 |   abs(long double __x)
      |   ^~~
/usr/include/c++/13/bits/std_abs.h:75:3: note: candidate: ‘constexpr float std::abs(float)’
   75 |   abs(float __x)
      |   ^~~
/usr/include/c++/13/bits/std_abs.h:71:3: note: candidate: ‘constexpr double std::abs(double)’
   71 |   abs(double __x)
      |   ^~~
/usr/include/c++/13/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++/13/bits/std_abs.h:56:3: note: candidate: ‘long int std::abs(long int)’
   56 |   abs(long __i) { return __builtin_labs(__i); }
      |   ^~~
answer.code:12:39: error: call of overloaded ‘abs(__int128&)’ is ambiguous
   12 |                 up = abs(p),down = abs(q);
      |                                    ~~~^~~
/usr/include/stdlib.h:840:12: note: candidate: ‘int abs(int)’
  840 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |            ^~~
/usr/include/c++/13/bits/std_abs.h:79:3: note: candidate: ‘constexpr long double std::abs(long double)’
   79 |   abs(long double __x)
      |   ^~~
/usr/include/c++/13/bits/std_abs.h:75:3: note: candidate: ‘constexpr float std::abs(float)’
   75 |   abs(float __x)
      |   ^~~
/usr/include/c++/13/bits/std_abs.h:71:3: note: candidate: ‘constexpr double std::abs(double)’
   71 |   abs(double __x)
      |   ^~~
/usr/include/c++/13/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++/13/bits/std_abs.h:56:3: note: candidate: ‘long int std::abs(long int)’
   56 |   abs(long __i) { return __builtin_labs(__i); }
      |   ^~~