题意:
给你一个数n,并规定了一种特殊的运算规则,问你有多少种选择使得a,b在该运算规则下相加等于n。
思路:
因为进位不再是向左1位进,而是向左2位进位,因而可以把奇偶位分开来看,将奇数位的数组成一个数字,并得出组成该数字的方法数,偶数位同理,两者相乘-2即为答案(a,b不全为0).
#include<bits/stdc++.h>
#include<ctime>
using namespace std;
#define ll long long
ll a[100];
ll sum[110];
ll res[110];
int main()
{
int t;
cin>>t;
while(t--)
{
memset(sum, 0, sizeof(sum));
ll n;
cin>>n;
ll ans = 1;
int cnt = 0;
while(n)
{
a[++cnt] = n%10;
n/=10;
}
int flag = 0;
for(int i = 1; i <= cnt/2; i++)
{
int op = a[i];
a[i] = a[cnt-i+1];
a[cnt-i+1] = op;
}
ll now = 0;
for(int i = 1; i <= cnt; i += 2)
{
now = now*10+a[i];
}
ans = now+1;
now = 0;
for(int i = 2; i <= cnt; i += 2)
{
now = now*10+a[i];
}
ll ans2 = now+1;
cout<<ans*ans2 - 2<<endl;
}
}