题目链接:点击打开链接
思路:模拟除法运算
#include <bits/stdc++.h>
using namespace std;
int main(){
int num;
int temp = 0,cnt = 0;
string s = "";
cin >> num;
do{
cnt++;
temp = temp * 10 + 1;
s.append(1,'0' + (temp / num));
temp = temp % num;
}while(temp > 0);
for(int i = 0;i < s.size();i++){
if(s[i] != '0'){
for(int j = i;j < s.size();j++){
cout<<s[j];
}
break;
}
}
cout << " " << cnt << endl;
return 0;
}