1821A - Matching - CodeForces Solution


combinatorics math *800

Please click on ads to support us..

C++ Code:

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define ft first
#define sd second
#define P pair<ll,ll>
#define TT ll tt;for(cin>>tt;tt--;)
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
const ll N=2e5+5;
const ll NN=1e6+6;
const ll mod=1e9+7;
ll b[NN],a[NN],c[NN];
vector<ll>v;
unordered_map<ll,ll>mp;
string s;
ll n,m;
ll ans=0;
//x,y,z; sum,res,cur,tmp; l,r,ll,rr; p,pp;
//暴力枚举,前缀和,二分,dfs,双指针,差分,并查集,逆元

void solve()
{
	cin>>s;
	m=count(s.begin(),s.end(),'?');
	if(s[0]=='?')ans=pow(10,m-1)*9ll;
	else if(s[0]=='0') ans=0;
	else ans=pow(10,m)*1ll;
	cout<<ans<<'\n';
}
signed main()
{
	IOS;
	TT
	solve();
	return 0;
}


Comments

Submit
0 Comments
More Questions

622B - The Time
1688C - Manipulating History
1169D - Good Triple
1675B - Make It Increasing
588A - Duff and Meat
1541B - Pleasant Pairs
1626B - Minor Reduction
1680A - Minimums and Maximums
1713A - Traveling Salesman Problem
1713B - Optimal Reduction
1710A - Color the Picture
1686B - Odd Subarrays
251A - Points on Line
427C - Checkposts
1159A - A pile of stones
508A - Pasha and Pixels
912A - Tricky Alchemy
1249A - Yet Another Dividing into Teams
1713C - Build Permutation
1699A - The Third Three Number Problem
1617B - GCD Problem
841A - Generous Kefa
1690B - Array Decrements
1692C - Where's the Bishop
104A - Blackjack
1438A - Specific Tastes of Andre
1711C - Color the Picture
1194C - From S To T
110B - Lucky String
1114A - Got Any Grapes