#P5834. [USACO19DEC] MooBuzz S

[USACO19DEC] MooBuzz S

Description

Farmer John’s cows have recently become enthusiastic players of a simple number game called “FizzBuzz.” The rules of this game are simple: the cows stand in a circle and count in order starting from 11, and each cow says one item when it is her turn. If the number a cow is about to say is a multiple of 33, she should say Fizz instead of the number. If it is a multiple of 55, she should say Buzz instead of the number. If it is a multiple of 1515, she should say FizzBuzz instead of the number. Therefore, the beginning of the record of the game is:

1, 2, Fizz, 4, Buzz, Fizz, 7, 8, Fizz, Buzz, 11, Fizz, 13, 14, FizzBuzz, 16

Due to a limited vocabulary, in the cows’ version of FizzBuzz they use Moo to replace Fizz, Buzz, and FizzBuzz. Therefore, the beginning of the record of the cows’ game is:

1, 2, Moo, 4, Moo, Moo, 7, 8, Moo, Moo, 11, Moo, 13, 14, Moo, 16

Given NN, find the NN-th number that is spoken in this game.

Input Format

The input contains one integer NN.

Output Format

Output the NN-th number spoken in the game.

4
7

Hint

About partial scoring:

Test point 11 is the sample.

Test points 252 \sim 5 satisfy N106N \le 10^6.

For 100%100\% of the testdata, 1N1091 \leq N \leq 10^9.

Problem by: Brian Dean.

Translated by ChatGPT 5