HBC24083ASCII码,C++工程师,牛客[USACO 2017 Dec P]Greedy Gift Takers题解

初见你 算法基础篇 57 0
题库丰富多样,涵盖各个领域,全网最全C++题库,让您在练习中不断成长!
N. They have unexpectedly turned up at Farmer John's farm, so the unfailingly polite Farmer John is attempting to give them gifts. To this end, Farmer John has brought out his infinite supply of gifts, and Nhoj's cows have queued up in front of him, with cow1 at the head of the queue and cowNat the tail. Farmer John was expecting that at every timestep, the cow at the head of the queue would take a gift from Farmer John and go to the tail of the queue. However, he has just realized that Nhoj's cows are not that polite!After receiving her gift, each cow may not go to the tail of the queue, but rather may cut some number of cows at the tail, and insert herself in front of them. Specifically, cowiiwill always cut exactly cic_icicows . Farmer John knows that some cows might receive multiple gifts; as he has an infinite supply, this does not worry him. But he is worried that some cows might become unhappy if they do not get any gifts. Help Farmer John find the number of cows who never receive any gifts, no matter how many gifts are handed out.

Farmer John's nemesis, Farmer Nhoj, has N cows (1≤N≤1051≤N≤10^51≤N≤105), conveniently numbered 1…N. They have unexpectedly turned up at Farmer John's farm, so the unfailingly polite Farmer John is attempting to give them gifts. To this end, Farmer John has brought out his infinite supply of gifts, and Nhoj's cows have queued up in front of him, with cow 1 at the head of the queue and cow N at the tail. Farmer John was expecting that at every timestep, the cow at the head of the queue would take a gift from Farmer John and go to the tail of the queue. However, he has just realized that Nhoj's cows are not that polite! After receiving her gift, each cow may not go to the tail of the queue, but rather may cut some number of cows at the tail, and insert herself in front of them. Specifically, cow ii will always cut exactly cic_ici​ cows (0≤ci≤N−10≤c_i≤N−10≤ci​≤N−1). Farmer John knows that some cows might receive multiple gifts; as he has an infinite supply, this does not worry him. But he is worried that some cows might become unhappy if they do not get any gifts. Help Farmer John find the number of cows who never receive any gifts, no matter how many gifts are handed out.

HBC24083ASCII码,C++工程师,牛客[USACO 2017 Dec P]Greedy Gift Takers题解
-第1张图片-东莞河马信息技术
(图片来源网络,侵删)
不断学习,不断挑战,才能在编程领域中脱颖而出!全网最全C++题库,助您成为编程高手!

标签: HBC24083ASCII码 C++工程师 牛客[USACO 2017 Dec P]Greedy Gift Takers题解