Open utterances-bot opened 3 years ago
can you explain F a bit more??
@swapno7064 I have added an example.
why we need to ensure the current sum can be divided by a_{i+1}?
@heyuhhh Because in the future, we can never use numbers less than $a{i+1}$. So if the current value cannot be divided by $a{i+1}$, it will never become 0.
from the above example how come 7 unique value can be generated means we have to find no of unique 'y' above 'X' . so how come 7 will be the answer?? i think only valid unique numbers are 192,216, 190 above 'X= 190'.?? can explain the transition.
@swapno7064 Note that for each number in the intermediate transitions, there is a count of different ways to reach that number.
but the condition says we will use minimum coins like in the given example 108+(236)+(12)=192 only 1 way to reach 192...instead of 12 we cannot use (34)coins ??
@swapno7064 The coefficients can be negative.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vint;
typedef vector<vint> vvint;
typedef vector<bool> vbool;
typedef vector<vbool> vvbool;
typedef pair<ll, ll> iPair;
#define ff first
#define ss second
int main(){
ll n, k = 0;
cin >> n;
vint cnt(3, 0);
while(n){
cnt[(n % 10) % 3]++;
n /= 10;
k++;
}
ll ans = abs(cnt[1] - cnt[2]) % 3;
if(ans <= k - 1){
cout << ans;
}
else
cout << -1;
return 0;
}
Can you tell me why this method won't work?
This is for Problem-C.
AtCoder Beginner Contest 182 Tutorial | CP Wiki
A number can be divided by $3$ if and only if the sum of its digits can be divided by $3$.
https://cp-wiki.vercel.app/en/tutorial/atcoder/ABC182/