[patl1-046]整除光棍
解题关键:模拟除法
#include<cstdio> #include<cstring> #include<algorithm> #include<cstdlib> #include<iostream> #include<cmath> using namespace std; typedef long long ll; char ans[10002]; int main(){ int n; cin>>n; int p=0,now=1; for(int len=1;;len++,now=now*10+1){ if(p||now/n){ ans[p++]='0'+now/n; } now%=n; if(now==0){ printf("%s %d",ans,len); break; } } return 0; }