#include #include using namespace std; typedef long long int ll; #define rrep(i, m, n) for(int i=m; i> n >> m; g = gcd(n, m); n /= g; m /= g; ll tmp = m; while(m%2==0){ m/=2; cnt[0]+=1; } while(m%5==0){ m/=5; cnt[1]+=1; } if(m!=1){ cout << "-1" << endl; return 0; } m = tmp; if(n%m==0){ while(n%10==0) n/=10; cout << n << endl; return 0; } mmax = max(cnt[0], cnt[1]); mmin = min(cnt[0], cnt[1]); res = (double)n/m; rep(i, mmax-mmin) res *= 10; cout << (ll)res%10 << endl; return 0; } ll gcd(ll a, ll b) { ll tmp; while(b){ tmp = a; a = b; b = tmp%b; } return a; }