L1-7 整除光棍
Time limit:400ms
Memory limit:64MB
注意,c++直接不断末尾加一会超时,实际造成的原因是数据溢出,java和python的大数是可以直接过的。
ac代码:
#include<bits/stdc++.h>
using namespace std;
int n,t,note;
int main(){
cin>>n;
t = 1,note = 1;
while(t < n)
t = t * 10 + 1,++note;
while(1){
cout<<t / n;
t %= n;
if(!t)
break;
t = t * 10 + 1;
++note;
}
cout<<" "<<note;
return 0;
}