-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AtCoder Beginner Contest 182 Tutorial #19
Comments
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 |
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/
The text was updated successfully, but these errors were encountered: