@[Ash1mar](/space/show?uid=33266) 其实测试数据范围是2^31-1
by kkksc03 @ 2017-04-12 20:56:04
想用打表,慢慢来
by МiсDZ @ 2017-12-05 17:09:55
```cpp
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
#define Fast register
const int maxn=1e5+3;
#define n (1<<15)+6
inline char getc()
{
static char buf[1<<14],*p1=buf,*p2=buf;
return (p1==p2)&&(p2=(p1=buf)+fread(buf,1,1<<14,stdin),p1==p2)?EOF:*p1++;
}
inline ll read()
{
int data=0,w=1;
char ch=0;
while(ch!='-'&&(ch<'0'||ch>'9'))ch=getc();
if(ch=='-') w=-1,ch=getc();
while(ch>='0'&&ch<='9') data=data*10+ch-'0',ch=getc();
return data*w;
}
ll t,k,N,a[maxn],b[maxn],c[13],d[13],e[13];
inline int get_num(int u)//refers 位数减一
{
return 1.0*log(1.0*u)/log(1.0*10);
}
inline void update(int u)
{
b[u]=u;
// printf("num1:%d\n",b[u]);
int temp=get_num(u),len;
len=u-d[temp];
b[u]+=(ll)(temp*len);
// printf("num2:%d\n",b[u]);
while(temp>1)
b[u]+=(temp-1)*c[temp],temp--;
// printf("num3:%d\n",b[u]);
return;
}
inline void work()
{
for(Fast int i=1;i<10;i++)
{
d[i]=pow(10,i);
c[i]=d[i]-pow(10,i-1);
d[i]--;
}
for(Fast int i=1;i<=n;i++)
{
update(i);
a[i]+=a[i-1]+b[i];
if(a[i]>=(1<<31)-1) {N=i;/*return;*/}
}
N=n;
for(Fast int i=1;i<5;i++)
{
// puts("//This is que_e");
e[i]=a[d[i]];
// printf("%lld ",e[i]);
// putchar(10);
}
return;
}
inline void print(ll *s)
{
for(Fast int i=1;i<N;i++)
printf("%lld ",s[i]);
putchar(10);
return;
}
int main()
{
t=read();
work();
// print(b);
// print(a);
while(t--)
{
k=read();
int lwd=lower_bound(a+1,a+1+N,k)-a;
if(a[lwd]>k) lwd--;
printf("lwd:%d\n",lwd);
printf("a[lwd]:%d\n",a[lwd]);
k%=a[lwd];
// (!k)?lwd:k;
printf("pos:%d\n",k);
}
// printf("%d",N);
return 0;
}
```
by Explorer_CYC @ 2018-04-10 14:34:29