Table of Contents
回复讨论(解决方案)
Home Backend Development PHP Tutorial $value = ax + s(x-1); $value=ax+by;

$value = ax + s(x-1); $value=ax+by;

Jun 23, 2016 pm 01:30 PM

1.输入$value,
2.选择公式
3.输出所有可能正整数值。
$value = ax + s(x-1);     页面排版浮动计算公式:总像素 =  每个li的像素宽度*个数 + 间隔像素。 
如何实现?


回复讨论(解决方案)

a 和 s是多少呢?

$value = 179;$x = 0;$response = -1;while(1){	$result = get($x);	if($result>$value){		break;	}elseif($result==$value){		$response = $x;		break;	}	$x++;}if($response!=-1){	echo $response;}else{	echo 'No solution';}function get($x){	$a = 1;	$s = 1;	return $a*$x + $s*($x-1);}
Copy after login

这3个值都是不确定的,自动计算,给solution.

$value = $a*$x +$s*($x-1);

给出$value,自动给出$a $s $x 让我参考。

function foo($value) {  for($a=1;$a<$value; $a++)    for($x=1;$x<$value; $x++)      for($s=1;$s<$value; $s++) {        if($value == $a*$x +$s*($x-1)) printf("a:%d x:%d s:%d\n", $x, $x, $s);      }}foo(200);
Copy after login
a:1 x:2 s:198a:2 x:2 s:196a:2 x:3 s:97a:2 x:4 s:64a:2 x:7 s:31a:2 x:10 s:20a:2 x:12 s:16a:2 x:19 s:9a:2 x:23 s:7a:2 x:34 s:4a:2 x:67 s:1a:3 x:2 s:194a:4 x:2 s:192a:4 x:3 s:94a:4 x:5 s:45a:4 x:8 s:24a:4 x:15 s:10a:4 x:29 s:3a:5 x:2 s:190a:5 x:4 s:60a:5 x:6 s:34a:5 x:14 s:10a:5 x:16 s:8a:6 x:2 s:188a:6 x:3 s:91a:7 x:2 s:186a:8 x:2 s:184a:8 x:3 s:88a:8 x:4 s:56a:8 x:5 s:40a:8 x:7 s:24a:8 x:9 s:16a:8 x:13 s:8a:8 x:17 s:4a:9 x:2 s:182a:10 x:2 s:180a:10 x:3 s:85a:10 x:6 s:28a:10 x:11 s:9a:11 x:2 s:178a:11 x:4 s:52a:11 x:8 s:16a:11 x:10 s:10a:12 x:2 s:176a:12 x:3 s:82a:12 x:5 s:35a:13 x:2 s:174a:13 x:12 s:4a:14 x:2 s:172a:14 x:3 s:79a:14 x:4 s:48a:14 x:7 s:17a:15 x:2 s:170a:15 x:6 s:22a:16 x:2 s:168a:16 x:3 s:76a:16 x:5 s:30a:16 x:9 s:7a:17 x:2 s:166a:17 x:4 s:44a:18 x:2 s:164a:18 x:3 s:73a:18 x:8 s:8a:19 x:2 s:162a:20 x:2 s:160a:20 x:3 s:70a:20 x:4 s:40a:20 x:5 s:25a:20 x:6 s:16a:20 x:7 s:10a:21 x:2 s:158a:22 x:2 s:156a:22 x:3 s:67a:23 x:2 s:154a:23 x:4 s:36a:24 x:2 s:152a:24 x:3 s:64a:24 x:5 s:20a:25 x:2 s:150a:25 x:6 s:10a:26 x:2 s:148a:26 x:3 s:61a:26 x:4 s:32a:26 x:7 s:3a:27 x:2 s:146a:28 x:2 s:144a:28 x:3 s:58a:28 x:5 s:15a:29 x:2 s:142a:29 x:4 s:28a:30 x:2 s:140a:30 x:3 s:55a:30 x:6 s:4a:31 x:2 s:138a:32 x:2 s:136a:32 x:3 s:52a:32 x:4 s:24a:32 x:5 s:10a:33 x:2 s:134a:34 x:2 s:132a:34 x:3 s:49a:35 x:2 s:130a:35 x:4 s:20a:36 x:2 s:128a:36 x:3 s:46a:36 x:5 s:5a:37 x:2 s:126a:38 x:2 s:124a:38 x:3 s:43a:38 x:4 s:16a:39 x:2 s:122a:40 x:2 s:120a:40 x:3 s:40a:41 x:2 s:118a:41 x:4 s:12a:42 x:2 s:116a:42 x:3 s:37a:43 x:2 s:114a:44 x:2 s:112a:44 x:3 s:34a:44 x:4 s:8a:45 x:2 s:110a:46 x:2 s:108a:46 x:3 s:31a:47 x:2 s:106a:47 x:4 s:4a:48 x:2 s:104a:48 x:3 s:28a:49 x:2 s:102a:50 x:2 s:100a:50 x:3 s:25a:51 x:2 s:98a:52 x:2 s:96a:52 x:3 s:22a:53 x:2 s:94a:54 x:2 s:92a:54 x:3 s:19a:55 x:2 s:90a:56 x:2 s:88a:56 x:3 s:16a:57 x:2 s:86a:58 x:2 s:84a:58 x:3 s:13a:59 x:2 s:82a:60 x:2 s:80a:60 x:3 s:10a:61 x:2 s:78a:62 x:2 s:76a:62 x:3 s:7a:63 x:2 s:74a:64 x:2 s:72a:64 x:3 s:4a:65 x:2 s:70a:66 x:2 s:68a:66 x:3 s:1a:67 x:2 s:66a:68 x:2 s:64a:69 x:2 s:62a:70 x:2 s:60a:71 x:2 s:58a:72 x:2 s:56a:73 x:2 s:54a:74 x:2 s:52a:75 x:2 s:50a:76 x:2 s:48a:77 x:2 s:46a:78 x:2 s:44a:79 x:2 s:42a:80 x:2 s:40a:81 x:2 s:38a:82 x:2 s:36a:83 x:2 s:34a:84 x:2 s:32a:85 x:2 s:30a:86 x:2 s:28a:87 x:2 s:26a:88 x:2 s:24a:89 x:2 s:22a:90 x:2 s:20a:91 x:2 s:18a:92 x:2 s:16a:93 x:2 s:14a:94 x:2 s:12a:95 x:2 s:10a:96 x:2 s:8a:97 x:2 s:6a:98 x:2 s:4a:99 x:2 s:2
Copy after login

谢谢,事情一下子有趣多了,我去前端那边忽悠忽悠。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

Explain the concept of late static binding in PHP. Explain the concept of late static binding in PHP. Mar 21, 2025 pm 01:33 PM

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

How does session hijacking work and how can you mitigate it in PHP? How does session hijacking work and how can you mitigate it in PHP? Apr 06, 2025 am 12:02 AM

Session hijacking can be achieved through the following steps: 1. Obtain the session ID, 2. Use the session ID, 3. Keep the session active. The methods to prevent session hijacking in PHP include: 1. Use the session_regenerate_id() function to regenerate the session ID, 2. Store session data through the database, 3. Ensure that all session data is transmitted through HTTPS.

Describe the SOLID principles and how they apply to PHP development. Describe the SOLID principles and how they apply to PHP development. Apr 03, 2025 am 12:04 AM

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

How to automatically set permissions of unixsocket after system restart? How to automatically set permissions of unixsocket after system restart? Mar 31, 2025 pm 11:54 PM

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

How to debug CLI mode in PHPStorm? How to debug CLI mode in PHPStorm? Apr 01, 2025 pm 02:57 PM

How to debug CLI mode in PHPStorm? When developing with PHPStorm, sometimes we need to debug PHP in command line interface (CLI) mode...

See all articles