T1U3348 A2-回文数
https://www.luogu.org/problem/show?pid=U3348
考场上钻了牛角尖了,然后0分
#include<cstdio> #include<cmath> using namespace std; typedef long long LL; LL cnt[101]; int ans[101]; int main() { LL n; scanf("%lld",&n); LL now=9; int len; for(len=1;;len++) { if(n>now) n-=now; else break; if(len%2==0) now*=10; } int i=len+1>>1; n--; LL tmp=1; for(int j=1;j<i;j++) tmp*=10; for(int j=1;j<i;j++) { for(int k=(j==1);k<=9;k++) { if(j==1 && k==1) ans[j]=1; if(n>=tmp) ans[j]++,n-=tmp; else break; } tmp/=10; } for(int j=1;j<i;j++) printf("%d",ans[j]); printf("%d",n); if(len%2==0) printf("%d",n); for(int j=i-1;j;j--) printf("%d",ans[j]); }