Автор ArshiaDadras, 23 месяца назад, По-английски

👋 Salam, Codeforces!

We are thrilled to invite you to the Rayan Programming Contest 2024 - Selection (Codeforces Round 989, Div. 1 + Div. 2).

The Selection Round is a rated contest for Div. 1 + Div. 2, taking place on Nov/30/2024 17:35 (Moscow time). The problems for this round were crafted and prepared by ArshiaDadras, MohammadParsaElahimanesh, AmShZ, AmirrzwM, and Keshi.

The top 60 trusted participants (with a maximum of three from each country) will qualify for the onsite Final Round in Tehran, in Spring 2025. An additional quota is reserved for the host country. Hotel accommodation, local transportation, and meals will be provided to all finalists. More details about the final contest will be available on the Rayan website.

🏆 Selection Round Prizes:

  • The top 50 participants will receive T-shirts. 👕
  • Additionally, 50 random participants from ranks 51-1000 will also receive T-shirts.

🏅 Final Round Prizes:

  • 1st place: $15,000 💵
  • 2nd place: $10,000 💵
  • 3rd place: $5,000 💵
  • 4th–6th places: $2,000 each
  • 7th–10th places: $1,000 each

🙏 Special Thanks:

We would like to extend our deepest gratitude to:

📊 Score distribution: $$$500 - 750 - 1500 - 1500 - 2000 - (2000 + 2000) - (3000 + 3000) - 5000$$$

We look forward to seeing you both online and onsite!

Good Luck & Have Fun! 🎉

📝 Note: Editorial just published here! 🚀🍿


🔔 Update: The official announcement for the Rayan 2025 World Finals has just been published! 🎉 You can read all the details about the onsite event in Tehran, November 25–29, 2025, in Arpa’s blog. For registration, schedule, and more information, please visit the Rayan website. Make sure to check it out if you’re among the top 1000 in the Selection Round! 🚀

  • Проголосовать: нравится
  • +546
  • Проголосовать: не нравится

»
23 месяца назад, скрыть # |
 
Проголосовать: нравится +17 Проголосовать: не нравится

Auto comment: topic has been updated by ArshiaDadras (previous revision, new revision, compare).

»
23 месяца назад, скрыть # |
← Rev. 2  
Проголосовать: нравится +43 Проголосовать: не нравится

As a tester, I didn't know I could have won $15,000 (just needed to beat a certain Belarusian...)

Y'all should give it a shot!!! Good luck.

»
23 месяца назад, скрыть # |
← Rev. 2  
Проголосовать: нравится +21 Проголосовать: не нравится

As an author, please give me T-shirt too.

»
23 месяца назад, скрыть # |
← Rev. 2  
Проголосовать: нравится -114 Проголосовать: не нравится

I predict tourist will fall below 4000.

Edit after round: everyone who downvoted this should apologize to me in DMs.

»
23 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Nice! This must be one of the rounds of all time, I'm so excited to see my teachers' round ;)

»
23 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

"The top 60 trusted participants (with a maximum of three from each country)"

How will you enforce this?

  • »
    »
    23 месяца назад, скрыть # ^ |
     
    Проголосовать: нравится +14 Проголосовать: не нравится

    We will start inviting participants from the top of the list while considering the country limit (a maximum of three participants per country) until we fill all 60 spots. Each invited participant will have a specific time frame to confirm their attendance. If someone declines or cannot attend, their spot will be given to the next eligible participant from the scoreboard who meets the criteria.

»
23 месяца назад, скрыть # |
 
Проголосовать: нравится +24 Проголосовать: не нравится

As a tester, this is the $$$4^{th}$$$ time in a row I found at least one problem in the round I tested really satisfying, and I hope people would feel the same.

»
23 месяца назад, скрыть # |
 
Проголосовать: нравится +34 Проголосовать: не нравится

I love Persian contests!

»
23 месяца назад, скрыть # |
 
Проголосовать: нравится +14 Проголосовать: не нравится

As a tester I wish good luck to everyone!

»
23 месяца назад, скрыть # |
 
Проголосовать: нравится +35 Проголосовать: не нравится

As a tester, I can confirm that I tested this round.

»
23 месяца назад, скрыть # |
 
Проголосовать: нравится +20 Проголосовать: не нравится

As a tester, I liked to test my first round! :)

PS: If you win $15,000, please give me the T-Shirt, hahaha

»
23 месяца назад, скрыть # |
 
Проголосовать: нравится -19 Проголосовать: не нравится

Final Round Prizes: 1st place: $15,000 2nd place: $10,000 3rd place: $5,000 4th–6th places: $2,000 each 7th–10th places: $1,000 each

^^^

How much will you win? They're really rich...

(This is my first comment on CodeForces so if you think I'm wrong please politely scold me)

  • »
    »
    23 месяца назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    If you look at their website, the onsite part is sponsored by a university and from what I can tell an entire ministry, and these prizes are for the onsite part. This round is only a selection round before the onsite one.

»
23 месяца назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

as a persian, i can confirm i ain't winning shit

»
23 месяца назад, скрыть # |
 
Проголосовать: нравится +5 Проголосовать: не нравится

W salam

»
23 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I'm quite interested that, is there any special about the sponsor? why does this contest appears on the top bar?

»
23 месяца назад, скрыть # |
 
Проголосовать: нравится +37 Проголосовать: не нравится

tourist will destroy this contest to earn money

»
23 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

As a participant, I will participate!

BTW, what watch are you wearing, sir ?! ArshiaDadras

»
23 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Do you arrange this every year?

»
23 месяца назад, скрыть # |
 
Проголосовать: нравится -14 Проголосовать: не нравится

this round will make tourist get back to gm i guess. lol

»
23 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I'm just looking at the rewards knowing I won't be even close to top 10 :/

»
23 месяца назад, скрыть # |
 
Проголосовать: нравится +4 Проголосовать: не нравится

if there are $$$50$$$ russians above me and all of them refuse to go to the onsite, will i be invited?

»
23 месяца назад, скрыть # |
 
Проголосовать: нравится +14 Проголосовать: не нравится

As an Iranian, this really makes me proud!

  • »
    »
    23 месяца назад, скрыть # ^ |
    ← Rev. 3  
    Проголосовать: нравится +14 Проголосовать: не нравится

    And I would like to thank the medalists who designed the questions and all the people involved and hardworking in this event!

    I think it is a good thing that the famous programmers of Codeforces come to our country.

    I hope to see the tourist here!

»
23 месяца назад, скрыть # |
 
Проголосовать: нравится +41 Проголосовать: не нравится

The same day as chinese NOIP! Hoping we all have good performance in the both round!

»
23 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Is this round rated?? as normal cf contest

participation is enough for registration or i have to register on website or something??

»
23 месяца назад, скрыть # |
 
Проголосовать: нравится +7 Проголосовать: не нравится

Time Conflict with ICPC Regionals QAQ

»
23 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Salaam too.

»
23 месяца назад, скрыть # |
 
Проголосовать: нравится +14 Проголосовать: не нравится

As a tester, I wish everyone good luck! :)

»
22 месяца назад, скрыть # |
 
Проголосовать: нравится -20 Проголосовать: не нравится

Мы Русские, захватим планету, сша следующие

»
22 месяца назад, скрыть # |
 
Проголосовать: нравится -16 Проголосовать: не нравится

teams or no?

»
22 месяца назад, скрыть # |
 
Проголосовать: нравится +22 Проголосовать: не нравится

Rayan Gosling Round

»
22 месяца назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

Wish tourist back 4000++ once more.. yo yo

»
22 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

rainboy orz (Problem H).

»
22 месяца назад, скрыть # |
← Rev. 2  
Проголосовать: нравится +42 Проголосовать: не нравится

Seems orzdevinwang will become tourist soon!
...Why does the sentence sounds that strange.

»
22 месяца назад, скрыть # |
 
Проголосовать: нравится +6 Проголосовать: не нравится

I said D > C;

»
22 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

What is the case in E where a solution exists for both k and n being odd and k < n?

»
22 месяца назад, скрыть # |
 
Проголосовать: нравится +17 Проголосовать: не нравится

C was so annoying to solve. Forgot one edge case and spent all my contest time on it, leaving no time for D :(

»
22 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

How to solve E?

  • »
    »
    22 месяца назад, скрыть # ^ |
    ← Rev. 2  
    Проголосовать: нравится +21 Проголосовать: не нравится
    Spoiler
»
22 месяца назад, скрыть # |
 
Проголосовать: нравится -68 Проголосовать: не нравится

Sooo nice E! Though it contains some casework, there is a beautiful construction method.

  • »
    »
    22 месяца назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    Can you share it with us common folk?

    • »
      »
      »
      22 месяца назад, скрыть # ^ |
       
      Проголосовать: нравится +9 Проголосовать: не нравится

      We treat $$$n=1$$$, $$$k=1$$$, $$$k=n!$$$, $$$k \gt n!$$$ first.
      Let's define $$$i$$$ th permutation as the permutation when we call next_permutation for $$$(1,2,\dots,n)$$$, $$$i-1$$$ times.
      First we construct for even $$$k$$$. We can just take $$$i$$$ th permutation $$$p$$$ and $$$(n!)+1-i$$$ th permutation $$$q$$$ together. (actually, $$$p_i = n+1-q_i$$$)
      For even $$$n$$$, if $$$k$$$ is odd, the answer is No (because $$$k \times \frac{(n+1)n}{2}$$$ isn't divisible by $$$n$$$)
      Now, we construct, for odd $$$n$$$, $$$k=3$$$. This can be done by this method (as an example, let $$$n=7$$$).

      • $$$(1,2,3,4,5,6,7)$$$
      • $$$(4,5,6,7,1,2,3)$$$ (left shift $$$\frac{n-1}{2}$$$ times)
      • $$$(7,5,3,1,6,4,2)$$$ (make sum = $$$3 \times \frac{n+1}{2}$$$)

      At last, we construct, for general odd $$$k$$$. We ignore following pairs:

      • $$$(1,2,3,4,5,6,7)$$$ and $$$(7,6,5,4,3,2,1)$$$
      • $$$(4,5,6,7,1,2,3)$$$ and $$$(4,3,2,1,7,6,5)$$$
      • $$$(7,5,3,1,6,4,2)$$$ and $$$(1,3,5,7,2,4,6)$$$

      At the current state, we can take $$$\frac{n!}{2} - 3$$$ pairs. After that, just add $$$k=3$$$. Then, we can construct for $$$3 \le k \le n!-3$$$.

      • »
        »
        »
        »
        22 месяца назад, скрыть # ^ |
         
        Проголосовать: нравится +3 Проголосовать: не нравится

        tysm

      • »
        »
        »
        »
        22 месяца назад, скрыть # ^ |
         
        Проголосовать: нравится +1 Проголосовать: не нравится

        wow! That left shift (n-1)/2 is insane, Any inspiration to come up with that?

        • »
          »
          »
          »
          »
          22 месяца назад, скрыть # ^ |
           
          Проголосовать: нравится +54 Проголосовать: не нравится

          I saw this problem and immediately coded brute force for $$$n=5$$$ and $$$k=3$$$ and the first one that came out was that construction

        • »
          »
          »
          »
          »
          22 месяца назад, скрыть # ^ |
           
          Проголосовать: нравится 0 Проголосовать: не нравится

          It comes by try & error so I can't tell exact step, but I tried to match $$$(1,4,7)$$$ first, suddenly cames up my construction.

          Maybe $$$(1,2,3,4,5,6,7)$$$ + (shift) leads the difference of the sum of two permutation $$$+2, +2, \dots, +2, -n+2, +2, \dots, +2$$$ (and under odd $$$n$$$, this works) is the decent way?

        • »
          »
          »
          »
          »
          22 месяца назад, скрыть # ^ |
          ← Rev. 3  
          Проголосовать: нравится 0 Проголосовать: не нравится

          I didn't manage to solve E during contest (I was really close, but I missed a few simple cases, like n = 1 and forgot about the cap for evens). I did get something very close. But basically once you realise that you can do all evens up to n! you can come up easily with "maybe if I can figure out a solution for 3 then it will work". And then you realise that you are looking for something that once you add 1 2 3 ... n it makes the same thing, you get the idea that you make something where the sum increases by 1 every time. I still had some trouble, but then I thought it would be easier if I just do every 2.

          So for every 2 I could do for 7:

          4 5 6 7

          1 2 3 4

          that would add up to 5 7 9 11

          and then the rest complete the sequence. So my own solution for 7 was:

          4 1 5 2 6 3 7

          1 5 2 6 3 7 4

          7 6 5 4 3 2 1

          Then it's somewhat obvious that 4 = 7 / 2 + 1. Then it was easily expandable as start for n / 2 + 1 for the first one.

  • »
    »
    22 месяца назад, скрыть # ^ |
     
    Проголосовать: нравится +8 Проголосовать: не нравится

    why is this getting downvoted

»
22 месяца назад, скрыть # |
← Rev. 2  
Проголосовать: нравится +20 Проголосовать: не нравится

Nothing could be worse than losing rating on my birthday :(

Edit: problems are nice, I choked on H with some cases like 1 3 105 63 45 and what I missed is just enumerating the GCD of all picked numbers...

»
22 месяца назад, скрыть # |
 
Проголосовать: нравится +92 Проголосовать: не нравится

AT 2:53 OF CONTEST TIME THE DIFFERENCE BETWEEN TOURIST AND ORZDEVINWANG WAS 32 POINTS. TOURIST NEEDED TO HACK SOMEONE AND HE MANAGED TO DO SO 8 SECONDS BEFORE THE END OF THE CONTEST!!!!!! BUT ORZDEVINWANG SOLVED G2 3 MINUTES BEFORE THE END OF THE CONTEST, SECURING THE FIRST PLACE!!!!! WHAT A DRAMA OMGOMGOMGOMGOMGOMGOMGOMGOMGOMGOMGOGMOG

»
22 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

The problems were nice, though I feel like I solved something very similar to F a long time ago on Codeforces (I didn't have time to solve it though, I spent too long on implementing D and E). Also, they have very nice pictures :D Do you think that they are AI generated? They are very intricate but I don't see any obvious AI artifacts. Otherwise, big respect to the artist who made them.

»
22 месяца назад, скрыть # |
 
Проголосовать: нравится +21 Проголосовать: не нравится

orz orzdevinwang. Also IF orzdevinwang didn't solve G2, then tourist would have won by doing a successful hacking attempt at the last minute, that's crazy.

»
22 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Is it true that in H the max size of the answer is 3? And does it have randomized solution?

  • »
    »
    22 месяца назад, скрыть # ^ |
     
    Проголосовать: нравится +18 Проголосовать: не нравится

    The max size of the answer is 6. let $$$x=2\cdot3\cdot5\cdot7\cdot11\cdot13$$$, then $$${\frac{x}{2},\frac{x}{3},\frac{x}{5},\frac{x}{7},\frac{x}{11},\frac{x}{13}}$$$ is a valid set

  • »
    »
    22 месяца назад, скрыть # ^ |
    ← Rev. 4  
    Проголосовать: нравится +14 Проголосовать: не нравится

    Here is the rough sketch for H.

    This is how we can characterize all possible linearly independent sets $$$a$$$.

    First find a set of distinct primes $$$p_1,p_2,\ldots,p_k$$$ and let the gcd of all the $$$a$$$ be $$$g$$$. We will write $$$P = \prod p_i$$$ as the product of all the primes here.

    Then we can construct a linearly independent set $$$a_1,a_2,\ldots,a_k$$$ where $$$a_i$$$ is a multiple of $$$\frac{gP}{p_i}$$$ but not $$$gP$$$.

    For each linearly independent set, you can find a corresponding $$$(g,p_1,p_2,\ldots,p_k)$$$ that satisfy the above constraint.

    Then after brute forcing everything, you realize the the number of possible $$$(g,p_1,p_2,\ldots,p_k)$$$ with $$$k \geq 3$$$, $$$g \mid P$$$ and $$$\frac{gP}{\min(p_i)} \leq 10^5$$$ is at most 500k or something. So you brute force everything. I had to use a bunch of constant opts to pass because my code is shit.

    Checking answer is at least $$$2$$$ can be done in $$$O(n \log n)$$$.

»
22 месяца назад, скрыть # |
 
Проголосовать: нравится +31 Проголосовать: не нравится

What's with the constraint of A? I see a lot of people passed it with brute forcing, but they're quite close to the time limit, while I got TLE and I suspect it's because I used long long instead of int.

I don't see why it couldn't be much higher so that no brute force solution could pass, or be much lower so that every brute force solution could pass.

»
22 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Why are there few pretests on problem D and E? I'm worried that my solution won't pass the system tests.

»
22 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

How to solve F? I cant find any clear approach to solve this problem

  • »
    »
    22 месяца назад, скрыть # ^ |
    ← Rev. 3  
    Проголосовать: нравится +11 Проголосовать: не нравится

    Firstly, for simplicity, redefine the special conditions to be in terms of the number of rubies/sapphires in your satchel (not chest). Then add dummy states $$$(0, 0)$$$ and $$$(n, m)$$$ for convenience (we won't double value at these though).

    Define dp states to be $$$dp[i]$$$, which is the total sum of value of your satchel across all ways you can reach the state defined by the $$$i$$$-th condition.

    To solve this dp you will firstly need to define some ordering on the conditions so that when evaluating some dp state, all the states that it depends on have already been evaluated. Just sort by $$$x + y$$$.

    Then, the transition from state $$$i$$$ to state $$$j$$$ will correspond to the ways you can go from state $$$i$$$ to state $$$j$$$ without visiting any other special condition state in between.

    Computing the number of ways you can go from state $$$i$$$ to state $$$j$$$ (where $$$i$$$ occurs before $$$j$$$ in the topological ordering) without visiting any intermediate special condition state is easy and can be done using inclusion exclusion in $$$O(n^3)$$$. Call this $$$w[i][j]$$$.

    Also define the total number of ways for us to go from state $$$i$$$ to $$$j$$$ to be $$$g[i][j]$$$. This can be computed in $$$O(1)$$$ using simple combinatorics.

    Define the addition in value for going from state $$$i$$$ to state $$$j$$$ without any intermediate doubling to be some $$$h[i][j]$$$.

    Then, the dp formulation for state $$$i$$$ is:

    $$$dp_i = 2 \cdot \sum{dp_j * w[j][i] + g[0][j] * w[j][i] * h[j][i]}$$$

    (where $j$ occurs before $$$i$$$ in the topological sort)

    All states will be evaluated in $$$O(n^2)$$$.

    The final answer is the value of the dp state corresponding to the the state $$$(n, m)$$$ divided by the total number of ways to go from $$$(0, 0)$$$ to $$$(n, m)$$$, which is just $$$\binom{n + m}{n}$$$.

»
22 месяца назад, скрыть # |
 
Проголосовать: нравится +6 Проголосовать: не нравится
meme on C
»
22 месяца назад, скрыть # |
 
Проголосовать: нравится +68 Проголосовать: не нравится

I liked F. However E is bad.

(1) I believe it made the contest unfair that one sample testcase was silently added. What you should have done is to make a clarification as an annoucement instead.

(2) The essential part had appeared multiple times — IMO 2009 Shortlist C2 and UTPC2023 and possibly many others. The "distinct" part does not add fun (perhaps personal opinion).

»
22 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

who can tell me why runtime error pleaseYour text to link here...

»
22 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

294071265 this gives runtime error on pretest 8 for problem C . Can anyone tell what is the reason . I have not seen similar verdicts in any other solutions , so I am curious what caused this error ?

»
22 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

How to solve D ?

  • »
    »
    22 месяца назад, скрыть # ^ |
    ← Rev. 3  
    Проголосовать: нравится +1 Проголосовать: не нравится

    What I did was iterate until the columns are sorted. On each iteration I:

    1. Swap the 1 that is furthest to the left with the 0 that it furthest to the right until all 0s are to the left of every 1.

    2. Swap the 2 that is furthest to the left with the 1 that is furthest to the right until all 1s are to the left of every 2.

    I did have to use a set to store the indexes otherwise it would TLE.

»
22 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I can't imagine how many people were blocked by $$$n=m=1$$$ in $$$C$$$ and $$$n=k=1$$$ in $$$E$$$...

»
22 месяца назад, скрыть # |
 
Проголосовать: нравится +16 Проголосовать: не нравится

A regular request to increase the memory limit to allow solutions in python. Going from https://codeforces.me/contest/2034/submission/294035798 to https://codeforces.me/contest/2034/submission/294041682

was neither insightful nor fun.

»
22 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

BRO I passed A with 999ms whats on about the tight TL

»
22 месяца назад, скрыть # |
← Rev. 2  
Проголосовать: нравится -10 Проголосовать: не нравится

GreedyForces

»
22 месяца назад, скрыть # |
 
Проголосовать: нравится +37 Проголосовать: не нравится

idk how many CF rounds I have to do to stop wasting half an hour on finding N = K = 1 testcases on E and similar :v

»
22 месяца назад, скрыть # |
← Rev. 2  
Проголосовать: нравится +26 Проголосовать: не нравится

I FST-ed on A :( Why half allow O(t*a*b) solution

»
22 месяца назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

loved the statements, especially the characters. look forward to seeing this competition continue in the coming years!

»
22 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

TLE on A system testing because of define int long long

»
22 месяца назад, скрыть # |
 
Проголосовать: нравится -19 Проголосовать: не нравится

Loved the images :)

»
22 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I still do not understand why I got TLE on A and B in the system testing while the other similar answers were getting accepted...

A: https://codeforces.me/contest/2034/submission/294007119 B: https://codeforces.me/contest/2034/submission/294033976

»
22 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

https://codeforces.me/contest/2034/submission/294091655

please someone help me in figuring out whats wrong in my code?

please!

»
22 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Hoping to get my first t-shirt(among Randomly choosen 50 participants)

»
22 месяца назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

This is my code for question A but it has not been accepted and showing TLE . How is this possible. I have reviewed my code thoroughly and believe it is correct .The code should definitely work as the constraints are — (1≤a,b≤1000) and (1≤t≤100). Many with same logic have their solutions accepted. I kindly request re-evaluation of my submission.

Submission Id — 294008048

#include <bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#include "Debugtemplate/template.hpp"
#else
#define debug(...)
#define debugArr(...)
#endif
#define int long long
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define mp make_pair
#define F first 
#define unmp unordered_map<int,int>
#define S second 
#define all(x) x.begin(),x.end()
#define sortasc(x) sort(all(x))
#define sortdes(x) sort(x.rbegin(),x.rend())
#define f(i,ind,n) for(int i=ind;i<n;i++)
#define PI 3.1415926535897932384626
const int mod = 1000000007;

void solve(){
    int a,b;
    cin >> a >> b;
    for(int i=min(a,b);i<=a*b;i++){
        if(i>=a || i>=b){
            if(i%a==i%b){
                cout << i << endl;
                return;
            }
        }
    }
}
#undef int
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
// freopen('input.txt','r',stdin);
// freopen('output.txt','w',stdout);
    int t;
    cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

  • »
    »
    22 месяца назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    Your solution works in $$$O(tab)$$$, with the constraint the worst case is $$$10^3\times 10^3\times 10^2=10^8$$$.

    However, the % operator has a large constant factor, which might case TLE in this case.

    #define int long long also slow down your code a little bit.

    PS: your code runs for about 2700ms on AtCoder (usually faster than codeforces) in about a $$$8\times 10^7$$$ total product, which is within the constraint. It would definitely TLE in the worst case here.

»
22 месяца назад, скрыть # |
 
Проголосовать: нравится +27 Проголосовать: не нравится

The fact that the glorious history of Iran and amazing myths were mentioned in the text of the questions made me proud that I was born in Iran. I hope this beautiful work will be repeated later.

»
22 месяца назад, скрыть # |
 
Проголосовать: нравится +9 Проголосовать: не нравится

unable to view the editorial

»
22 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

hello everyone do you know how to get job because i was recently graduated i don't know what to do

»
22 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

can anybody give me the id of this contest

»
22 месяца назад, скрыть # |
 
Проголосовать: нравится +9 Проголосовать: не нравится
»
22 месяца назад, скрыть # |
 
Проголосовать: нравится +18 Проголосовать: не нравится

Nice problems! F2 and H are nice, even though I wasn't able to debug the latter in contest time :(

On a side note: Why insert the image in the middle? It randomly divides the statement into two parts, which can be really annoying when checking to see if you have missed something.

»
22 месяца назад, скрыть # |
← Rev. 3  
Проголосовать: нравится 0 Проголосовать: не нравится

Today I received this message:

Spoiler

This is unfair decision. The only similar parts of this submissions: mine, studboy — is parts with sets, which is not the main logical part. Main ideas looks quite similar, but ways of solving are different. Hope this misunderstanding will be fixed.

  • »
    »
    22 месяца назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    Hello, Timophey!

    Detecting similarities between codes and marking them as potential cheating cases is not something handled by the problem authors. In fact, we aren’t informed when these checks are performed or who ends up being flagged as a result.

    This process is part of the system’s automated operations. I believe reaching out to KAN or contacting the appropriate individuals in charge might help resolve this situation for you.

    I’m sorry that I’m unable to assist directly with this matter.

»
22 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

best problems

»
20 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I received a form to promote the final round from system, but my rank is 160 (about 20 of Japanese). Is this message correct?

  • »
    »
    20 месяцев назад, скрыть # ^ |
     
    Проголосовать: нравится +10 Проголосовать: не нравится

    Yeah, that's correct!

    You could be one of the qualified participants if those ahead of you in the queue decline to attend the in-person contest, making you the next candidate for an invitation.

    This form is sent to potential invitees rather than the final list of confirmed qualifiers. After you complete it, an official invitation letter will be sent separately.

    • »
      »
      »
      20 месяцев назад, скрыть # ^ |
       
      Проголосовать: нравится 0 Проголосовать: не нравится

      If I answer "yes", am I required to accept the formal invitation? How much will the trip cost?

      • »
        »
        »
        »
        20 месяцев назад, скрыть # ^ |
         
        Проголосовать: нравится 0 Проголосовать: не нравится

        The official invitation letter will provide more detailed information about the event, including trip costs, the exact date, and other relevant details. You will also have the opportunity to ask any questions you may have during this process.

        As far as I remember (not entirely sure), the only cost you need to cover is your flight tickets; we will cover everything else!

»
14 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Why does like have of the Codeforces population have an anime character as their PFP?

Sure, there's nothing wrong with that until you see it's all females/waifus.

Hey, I'm not judging(Just curious), but it can't just be that everyone just wants to have their PFP as a female/waifu.

And maybe it's just me but I have no idea who most of them are(including the male anime characters)