C. Carrying Conundrum
这样子进位显然奇偶就独立了
我们分别对于奇偶计算方案数 然后乘法法则即可
比如我们现在奇数位num1 偶数位num2
我们的方案就是num1+1 偶数位就是num2+1
然后ans就是(num1+1)*(num2+1)
不过这里还需要-2(我们保证a b都为正数)
因为还会有 num1+num2 0+0
0+0 num1+num2 这两种情况
#include <bits/stdc++.h>
using namespace std;
const int N = 4e5+10;
const int M = 998244353;
const int mod = 20220911;
#define int long long
int up(int a,int b){return a<0?a/b:(a+b-1)/b;}
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define YES cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl;
#define _ 0
#define pi acos(-1)
#define INF 0x3f3f3f3f3f3f3f3f
#define fast ios::sync_with_stdio(false);cin.tie(nullptr);
int change(string s){
int res=0;
for(auto i:s){
res*=10;
res+=i-'0';
}
return res;
}
void solve() {
string s,a,b;cin>>s;
if(s.size() %2) {
for (int i = 0; i < s.size(); i += 2) {
a.push_back(s[i]);
if(i+1<s.size())b.push_back(s[i + 1]);
}
}else{
for (int i = 0; i < s.size(); i += 2) {
b.push_back(s[i]);
if(i+1<s.size())a.push_back(s[i + 1]);
}
}
cout<<(change(a)+1)*(change(b)+1)-2<<endl;
}
signed main(){
fast
int t;t=1;cin>>t;
while(t--) {
solve();
}
return ~~(0^_^0);
}
标签:奇偶,742,const,num1,num2,int,Codeforces,Div,size
From: https://www.cnblogs.com/ycllz/p/16798912.html