题意:
思路:
枚举数字的长度,边枚举边模,如果模的结果是0那就是K的倍数
Code:
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int mxn=1e5+10;
const int mxe=1e5+10;
const int mod=1e9+7;
int K;
void solve(){
cin>>K;
int now=7%K;
for(int len=1;len<=1e6;len++){
if(now%K==0){
cout<<len<<'\n';
return;
}
now=(now*10+7)%K;
}
cout<<-1<<'\n';
}
signed main(){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int __=1;//cin>>__;
while(__--)solve();return 0;
}