結果
| 問題 |
No.1842 Decimal Point
|
| コンテスト | |
| ユーザー |
milanis48663220
|
| 提出日時 | 2022-02-18 23:21:57 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 279 ms / 2,000 ms |
| コード長 | 3,063 bytes |
| コンパイル時間 | 1,333 ms |
| コンパイル使用メモリ | 116,916 KB |
| 最終ジャッジ日時 | 2025-01-28 00:42:41 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 5 |
ソースコード
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <functional>
#include <cassert>
#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
typedef __int128_t ll;
template<typename T>
vector<vector<T>> vec2d(int n, int m, T v){
return vector<vector<T>>(n, vector<T>(m, v));
}
template<typename T>
vector<vector<vector<T>>> vec3d(int n, int m, int k, T v){
return vector<vector<vector<T>>>(n, vector<vector<T>>(m, vector<T>(k, v)));
}
template<typename T>
void print_vector(vector<T> v, char delimiter=' '){
if(v.empty()) {
cout << endl;
return;
}
for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter;
cout << v.back() << endl;
}
__int128 parse(string &s) {
__int128 ret = 0;
for (int i = 0; i < s.length(); i++)
if ('0' <= s[i] && s[i] <= '9')
ret = 10 * ret + s[i] - '0';
return ret;
}
istream & operator >> (istream &in, __int128_t &m){
string s; cin >> s;
m = parse(s);
return in;
}
ostream &operator<<(std::ostream &dest, __int128_t value) {
ostream::sentry s(dest);
if (s) {
__uint128_t tmp = value < 0 ? -value : value;
char buffer[128];
char *d = end(buffer);
do {
--d;
*d = "0123456789"[tmp % 10];
tmp /= 10;
} while (tmp != 0);
if (value < 0) {
--d;
*d = '-';
}
int len = end(buffer) - d;
if (dest.rdbuf()->sputn(d, len) != len) {
dest.setstate(ios_base::badbit);
}
}
return dest;
}
ll mod_pow(ll a, ll n, ll mod) {
ll ans = 1;
while (n > 0) {
if (n&1) ans = (ans*a)%mod;
a = (a*a)% mod;
n >>= 1;
}
return ans;
}
void solve(){
ll a, b, c; cin >> a >> b >> c;
while(b%2 == 0){
if(a%2 == 0){
a /= 2;
}else{
a *= 5;
c--;
}
b /= 2;
}
while(b%5 == 0){
if(a%5 == 0){
a /= 5;
}else{
a *= 2;
c--;
}
b /= 5;
}
// cout << a << ' ' << b << ' ' << c << endl;
if(c <= 0){
ll x = a/b;
while(c != 0) {
x /= 10;
c++;
}
cout << x%10 << endl;
return;
}
ll x = (a*mod_pow(10, c, b))%b;
int r = (10-x%10)%10;
for(int i = 0; i < 10; i++){
if((b*i)%10 == r){
cout << i << endl;
}
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout << setprecision(10) << fixed;
int t; cin >> t;
while(t--) solve();
}
milanis48663220