QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#779120 | #9622. 有限小数 | Yoshinow2001# | Compile Error | / | / | C++20 | 992b | 2024-11-24 17:31:48 | 2024-11-24 17:31:49 |
Judging History
This is the latest submission verdict.
- [2024-11-24 17:31:49]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2024-11-24 17:31:48]
- Submitted
answer
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define endl '\n'
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
#define int long long
typedef pair<int,int> pii;
void solve(){
int a , b;
cin >> a >> b;
int ansx ,ansy;
ansx = b - a;ansy = b;
for(int x = 1 ; x <= 1e16; x *= 2){
for(int y = 1 ; x * y <= 1e16;y *= 5){
int g = ((__int128)a * x * y + b - 1) / (b);
auto c = (__int128)b * g - x * y * a;
auto d = (__int128)b * x * y;
auto gg = gcd(c ,d);
//cout << (int)(c / gg) <<' ' << (int)(d / gg) << endl;
if(c / gg < ansx && d / gg <= (int)1e9){
ansx = c / gg;ansy = d / gg;
}
}
}
cout << ansx <<' ' << ansy << endl;
}
int32_t main(){
fastio;
int T = 1;
cin >> T;
while(T--) solve();
return 0;
}
详细
In file included from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:58, from answer.code:1: /usr/include/c++/13/numeric: In instantiation of ‘constexpr std::common_type_t<_Tp1, _Tp2> std::gcd(_Mn, _Nn) [with _Mn = __int128; _Nn = __int128; common_type_t<_Tp1, _Tp2> = __int128]’: answer.code:21:26: required from here /usr/include/c++/13/numeric:166:21: error: static assertion failed: std::gcd arguments must be integers 166 | static_assert(is_integral_v<_Mn> && is_integral_v<_Nn>, | ^~~~~~~~~~~~~~~~~~ /usr/include/c++/13/numeric:166:21: note: ‘std::is_integral_v<__int128>’ evaluates to false In file included from /usr/include/c++/13/bits/stl_pair.h:60, from /usr/include/c++/13/bits/stl_algobase.h:64, from /usr/include/c++/13/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51: /usr/include/c++/13/type_traits: In instantiation of ‘struct std::make_unsigned<__int128>’: /usr/include/c++/13/type_traits:1983:11: required by substitution of ‘template<class _Tp> using std::make_unsigned_t = typename std::make_unsigned::type [with _Tp = __int128]’ /usr/include/c++/13/numeric:173:24: required from ‘constexpr std::common_type_t<_Tp1, _Tp2> std::gcd(_Mn, _Nn) [with _Mn = __int128; _Nn = __int128; common_type_t<_Tp1, _Tp2> = __int128]’ answer.code:21:26: required from here /usr/include/c++/13/type_traits:1836:62: error: invalid use of incomplete type ‘class std::__make_unsigned_selector<__int128, false, false>’ 1836 | { typedef typename __make_unsigned_selector<_Tp>::__type type; }; | ^~~~ /usr/include/c++/13/type_traits:1744:11: note: declaration of ‘class std::__make_unsigned_selector<__int128, false, false>’ 1744 | class __make_unsigned_selector; | ^~~~~~~~~~~~~~~~~~~~~~~~