天天看點

L1-046 整除光棍 (20 分)

原題連結

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x;
    cin>>x;
    int n=0,s=0;
    while(n<x)
    {
        n=n*10+1;
        s++;
    }
    while(1)
    {
        cout<<n/x;
        
        if(n%x==0)
        {
            cout<<" "<<s;
            break;
        }
        else
        {
            n=n%x*10+1; 
            s++;  
        }
        
    }
}