SHARE
TWEET

Untitled

a guest Oct 17th, 2019 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  message(s) / RUNNING
  2. Source code
  3. #include <iostream>
  4. #include <vector>
  5.  
  6. using namespace std;
  7.  
  8. int main(){
  9.     unsigned int n,m,t=0,p=1,f=0;
  10.     int k,l=10;
  11.     vector<unsigned int> ost;
  12.     vector<unsigned int> otv;
  13.     cin>>n>>m;
  14.     k=m;
  15.     while(k!=0){
  16.         f++;
  17.         k/=10;
  18.     }
  19. //  cout<<f<<endl;
  20.     ost.push_back(n);
  21.     while(t==0){
  22.         n*=10;
  23.         while(n<m){
  24.             otv.push_back(0);
  25.             ost.push_back(n);
  26.             n*=10;
  27.         }
  28.         ost.push_back(n%m);
  29.         otv.push_back(n/m);
  30.         n=n%m;
  31. //      cout<<"("<<n<<")";
  32.         for(int  j=0;(j<ost.size()-1)&&(j<f+2);j++){
  33. //          cout<<n<<" "<<ost[j]<<" "<<j<<endl;
  34.             if(n==ost[j]){
  35.                 t=1;
  36.                 p=j;
  37. //              cout<<p<<" "<<ost[p]<<" "<<n<<endl;
  38.                 break;
  39.             }
  40.         }
  41.         if(n==0){
  42.             t=2;
  43.             break;
  44.         }
  45.  
  46.     }
  47. //  cout<<p<<" "<<otv[otv.size()-1]<<endl;
  48.     cout<<"0.";
  49.     if(t==1){
  50.         for(unsigned int i=0;i<p;i++){
  51.             cout<<otv[i];
  52.         }
  53.         cout<<"(";
  54.         for(auto i=p;i<otv.size();i++){
  55.             cout<<otv[i];
  56.         }
  57.         cout<<")";
  58.     }
  59.     if(t==2){
  60.         for(unsigned int i=0;i<otv.size();i++){
  61.             cout<<otv[i];
  62.         }
  63.     }  
  64.  
  65.     return 0;
  66. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top