nginx 禁止ip访问
2012-03-09 20:22
465 查看
Problem Statement | ||||||||||||
A decomposition of a non-negative integer n is a list of non-negative integers that sum to exactly n. The product of a decomposition is the product of all its members. For example, if n = 4, the following decompositions are possible: 4 = 1+1+1+1, product is 1*1*1*1 = 1. 4 = 1+1+2, product is 1*1*2 = 2. 4 = 1+3, product is 1*3 = 3. 4 = 2+2, product is 2*2 = 4. 4 = 4, product is 4. Given an int n, determine the decomposition of n with the maximal product, and return that product modulo 10007. In the example above, the maximal product is 4 (the product of the decomposition 2 + 2). | ||||||||||||
Definition | ||||||||||||
| ||||||||||||
Constraints | ||||||||||||
- | n will be between 0 and 10000, inclusive. | |||||||||||
Examples | ||||||||||||
0) | ||||||||||||
| ||||||||||||
1) | ||||||||||||
| ||||||||||||
2) | ||||||||||||
| ||||||||||||
3) | ||||||||||||
| ||||||||||||
4) | ||||||||||||
|
public class BestDecomposition { public int maxProduct(int n) { int p = n < 3 ? n : new int[]{3, 4, 6}[n%3]; for (int i = 1; i < n / 3; i++) p = p * 3 % 10007; return p; } }
相关文章推荐
- nginx禁止某个IP访问站点的设置方法
- nginx禁止ip直接访问
- Nginx 禁止IP访问
- Nginx 禁止IP访问
- nginx 禁止通过ip访问站点
- Nginx 禁止IP访问 (实践过)
- Nginx 禁止IP访问 只允许域名访问
- Nginx 禁止IP访问 只允许域名访问
- Nginx配置禁止通过IP访问
- nginx 禁止IP访问
- NGINX:nginx禁止IP直接访问web server
- nginx 禁止某个IP访问
- Nginx中禁止使用IP访问网站的配置实例
- Nginx禁止通过IP,未绑定域名访问服务器
- NGINX 禁止某个IP访问
- nginx禁止某个IP访问站点的设置方法
- Nginx 禁止IP访问
- nginx 禁止IP访问
- nginx配置禁止ip访问,只能域名访问
- Nginx 禁止IP访问及未绑定的域名跳转