天梯赛训练2 7-6 整除光棍

模拟除法

对大整数除法还不太会
#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n,Len=0,x=0,p=0;
    cin >> n;
    while(++Len)
    {
        x=x*10+1;
        if(p||x/n) //知道第一个不是0的情况
        {
            cout << x/n,p=1;
        }
        x=x%n;
        if(x==0)
            {cout << " " << Len <<endl;break;}
    }
    return 0;
}

原文地址:https://www.cnblogs.com/qq-1585047819/p/10482927.html