Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
34408 | daimo | 【S】T3 | C++ | 内存超限 | 20 | 2856 MS | 524408 KB | 789 | 2024-11-07 18:40:49 |
#include<bits/stdc++.h> #define int long long using namespace std; map<int,int>mp; int stk[20]; int n; int b[20]; int ans=0; void check(int k){ int len=0; int k2=k; while(k2){ len++,b[len]=k2%10,k2/=10; } for(int i=len,j=1;i>=j;i--,j++){ if(b[i]!=b[j])return; } mp[k]=1; ans+=2; return; } int pw[20]; inline void dfs1(int x,int len){ if(x>n)return; if(x%10!=0&&!mp[x])check(n-x); mp[x]=1; for(int i=0;i<=9;i++)if(!mp[x*10+i+pw[len+1]*i])dfs1(x*10+i+pw[len+1]*i,len+2); return; } signed main(){ //freopen("palindrome.in","r",stdin); //freopen("palindrome.out","w",stdout); ios::sync_with_stdio(0); cin>>n; pw[0]=1; for(int i=1;i<=16;i++)pw[i]=pw[i-1]*10; for(int i=1;i<=9;i++)dfs1(i,1),dfs1(i*11,2); cout<<ans; return 0; }