#P16630. [GKS 2017 #F] Cake

    ID: 16897 Type: RemoteJudge 1000ms 1024MiB Tried: 0 Accepted: 0 Difficulty: 5 Uploaded By: Tags>动态规划 DP数学2017线性 DPGoogle Kick Start

[GKS 2017 #F] Cake

题目描述

Wheatley is at the best party in the world: it has infinitely many cakes! Each cake is a square with an integer side length (in cm). The party has infinitely many cakes of every possible integer side length. The cakes all have the same depth, so we will only consider their areas.

Wheatley is determined to eat one or more cakes that have a total combined area of exactly N cm2\text{cm}^2. But, since he is health-conscious, he wants to eat as few cakes as possible. Can you help him calculate the minimum number of cakes he can eat?

输入格式

The input starts with one line containing one integer TT, which is the number of test cases. TT test cases follow. Each case consists of one line with one integer NN, which is the exact total cake area that Wheatley wants to eat.

输出格式

For each test case, output one line containing Case #x: y, where x is the test case number (starting from 1) and y is the minimum number of cakes that Wheatley can eat while eating the exact total area N.

3
3
4
5
Case #1: 3
Case #2: 1
Case #3: 2

提示

In Sample Case #1, the only possible strategy is for Wheatley to eat three cakes of side length 11.

In Sample Case #2, Wheatley can eat one cake of side length 22, which requires fewer cakes than eating four cakes of side length 11.

In Sample Case #3, the best strategy is for Wheatley to eat one cake of side length 22 and one cake of side length 11.

Limits

Small dataset (Test set 1 - Visible)

1≤T≤501 \le T \le 50.

1≤N≤501 \le N \le 50.

Large dataset (Test set 2 - Hidden)

1≤T≤1001 \le T \le 100.

1≤N≤100001 \le N \le 10000.