Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- message(s) / RUNNING
- Source code
- #include <iostream>
- #include <vector>
- using namespace std;
- int main(){
- unsigned int n,m,t=0,p=1,f=0;
- int k,l=10;
- vector<unsigned int> ost;
- vector<unsigned int> otv;
- cin>>n>>m;
- k=m;
- while(k!=0){
- f++;
- k/=10;
- }
- // cout<<f<<endl;
- ost.push_back(n);
- while(t==0){
- n*=10;
- while(n<m){
- otv.push_back(0);
- ost.push_back(n);
- n*=10;
- }
- ost.push_back(n%m);
- otv.push_back(n/m);
- n=n%m;
- // cout<<"("<<n<<")";
- for(int j=0;(j<ost.size()-1)&&(j<f+2);j++){
- // cout<<n<<" "<<ost[j]<<" "<<j<<endl;
- if(n==ost[j]){
- t=1;
- p=j;
- // cout<<p<<" "<<ost[p]<<" "<<n<<endl;
- break;
- }
- }
- if(n==0){
- t=2;
- break;
- }
- }
- // cout<<p<<" "<<otv[otv.size()-1]<<endl;
- cout<<"0.";
- if(t==1){
- for(unsigned int i=0;i<p;i++){
- cout<<otv[i];
- }
- cout<<"(";
- for(auto i=p;i<otv.size();i++){
- cout<<otv[i];
- }
- cout<<")";
- }
- if(t==2){
- for(unsigned int i=0;i<otv.size();i++){
- cout<<otv[i];
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement