

AtCoder Beginner Contest 293 Announcement
source link: https://codeforces.com/blog/entry/113780
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

AtCoder Beginner Contest 293 Announcement
We will hold AtCoder Beginner Contest 293.
The point values will be 100-200-300-400-500-500-600-600. We are looking forward to your participation!
21 hour(s) ago, # | What is the counter test case for this problem B's solution? I kept getting WA. ugly code |
-
3 4 1 5 4
For this test case, your code gives wrong answer.
-
- It seems that this test case itself is invalid
- Even if this test case is valid, my code outputs 1 2 5, is it wrong?
-
The number of elements in the answer is actually 3, but your code gives 2.
-
21 hour(s) ago, # | today, re-learn how to sum the Geometric Progression :) good problem |
Can't seem to get D to AC, failed 6 test cases. My idea is to label as blue and as red for and treat it as a graph dfs problem Spoiler |
My solution for each problem are explained below. Spoiler |
-
Can you explain about the 2 by 2 matrix formula in the editorial for problem E? https://atcoder.jp/contests/abc293/editorial/5962
-
can be solved simpler. Let . Then:
If is even .
If is odd .
Write simple recursion.
About problem . I precalculated answers and carefully looked at it. Then I calculated for all integer , which are meaningfull. Then simply tried all numbers in ranges . I have no idea, why it is correct.
-
Oh cool, this is much easier to understand. Thanks! I tried so hard to use the sum formula with mod inverse, little did I know that depending on M, it may not even exist :(
-
Can you help me understand it please please
-
If x = 4: f(x) = a^0 + a^1 + a^2 + a^3 = (a^0 + a^1) + a^2 * (a^0 + a^1) = f(x / 2) + a^(x / 2) * f(x / 2).
If x = 5: f(x) = a^0 + a^1 + a^2 + a^3 + a^4 = a^0 + a^1 * (a^0 + a^1) + a^(x / 2 + 1) * (a^0 + a^1) = 1 + a * f(x / 2) + a^(x / 2 + 1) * f(x / 2).
Hopefully this helps you understand the recursive formula.
-
-
-
define int long long
ll expo(ll a, ll b, ll mod) { ll res = 1; while (b > 0) { if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b = b >> 1; } return res; }
int rec(int a,int n){
if(n==1) return 1; if(n%2==1){ return ((((1+expo(a,(n)/2,m))%m*(rec(a,n/2)%m))%m)+(expo(a,n-1,m)))%m; } else return ((1+expo(a,(n)/2,m))%m*(rec(a,n/2)%m))%m;
my code is failing at two test cases but i don,t know here it is wrong can you help me pls
-
What is reeds sloane template where to find it
-
It's an algorithm that finds linear recurrences given the sequence's first few values. The template is on here but I can assure you there are very few moments when you actually need it to solve a certain task (again, I used it because I was lazy)
-
21 hour(s) ago, # | Solution for problem E using simple recursion Source Submission |
Solution to F: It is possible to write a function that checks if a number x can be written in base b with 1s and 0s like this: Code If the number written in the base b has many digits it means that b is small. If b is large it means that the mask (representation of n in base b) has few digits. By defining the threshold at 6 digits it means that we can check b until . And then we have large b's left (with few digits in the mask). We can check all the masks up to 6 digits and do a binary search to find if there is a b that matches the mask. Total complexity per test case: |
21 hour(s) ago, # | Somehow I used an ugly method to solve problem F (after contest). For some base-b, at first we check all the combination of patterns (1/0)b^0+(1/0)b^1+...(1/0)b^4, and find all the valid b. Then, note that we have at most 10^(18/5) other candidates to check, and it suffices to implement brute-force for this part (this is beacuse we must start from at least b^5, and valid b must satisfy b<=10^3.6). But I think the editorial's idea is better to understand. |
20 hours ago, # | Can anyone explain the winner's (maspy) elegant solution to problem E? https://atcoder.jp/contests/abc293/submissions/39612056
|
-
I think I might have an explanation to the "else" part.
The original problem is equivalent to computing (a/b)%c. Suppose that (a/b)%c=r, then we must have a/b=qc+r, and a=qbc+rb, then we compute a%(bc)=0+rb (because r<c, so rb<rc), and thus r=(a%(bc))/b.
In fact, I decided to use this at first, but I kept getting WA at sample3 so I gave it up.
-
I actually had the same solution: https://atcoder.jp/contests/abc293/submissions/39630645
The idea is that we need to divide by in order to do the geometric sum formula, but the problem is that may not have an inverse mod as we aren't given that is prime and large enough. So, we use the fact that if , then . We calculate the numerator of the geometric sum mod and divide both the residue and modulus by in the end.
You might also notice that doesn't fit in a 32-bit integer, so even using long longs, multiplication will overflow, thus why both I and the person you referenced used Python.
20 hours ago, # | Is it possible to calculate a/b mod m for when b and m are not coprimes? I guess no in general right? (for values up to 10^18 for example). This would help in problem E if I knew I had to come up with a different approach. Is this common, realising you have to have a different approach because a/b is impossible? |
-
What do you mean by . For cases when inverse of modulo exists, then is defined as .
-
Given 3 integers a, b and m 1<=a,b,m<=10^18 — calculate a/b mod (m). That is a divided by b mod m (or a/b%m in modular arithmetic I guess). Is it possible to solve this? Obviously it is possible when b has a modular inverse, but not possible otherwise?
For example 10/2 mod 7 == 5 because the modular inverse of 2 mod 7 is 4. 10*4 mod 7 is 5
And 9/2 mod 7 is 1
And other example is 16/8 mod 8. Obvioulsy 16/8 is 2 and 2 mod 8 is 2. But there is no modular inverse of 8 mod 8.
-
E is tricky that |
19 hours ago, # | How to solve E? |
Recommend
-
13
chokudai's blog
-
9
chokudai's blog
-
10
NEC Programming Contest 2021(AtCoder Beginner Contest 229) Announcement NEC Programming Contest 2021(AtCoder Be...
-
28
chokudai's blog
-
19
chokudai's blog
-
20
chokudai's blog
-
8
Panasonic Programming Contest 2022(AtCoder Beginner Contest 251) Announcement Panasonic Programming Contest 2022(AtCoder Beginner Co...
-
14
Aising Programming Contest 2022(AtCoder Beginner Contest 255) Announcement Aising Programming Contest 2022(AtCoder Beginner Conte...
-
9
chokudai's blog AtCoder Beginner Co...
-
15
LINE Verda Programming Contest(AtCoder Beginner Contest 263) Announcement LINE Verda Programming Contest(AtCoder Beginner Contest...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK