#include<iostream> #include<string> using namespace std; int main(){ int T; cin>>T; while(T--){ int p; cin>>p; long long x=0,k=0,d=0; while(true){ if(x==p){ break; } k++; if(k%7==0){ if(k==d+1){ x++; d=k; //cout<<k<<' '<<x<<endl; } else{ x=1; d=k; } } else{ string s =to_string(k); for(int i=0;i<s.size();i++){ if(s[i]=='7'){ if(k==d+1){ x++; d=k; //cout<<d<<' '<<k<<' '<<x<<endl; } else{ x=1; d=k; } break; } } } } cout<<k-p+1<<endl; } } |
Double click to view unformatted code.