eclipse encoding inherited from container

本文分享了关于Eclipse IDE的编码配置调整方法,解决PHP中常见错误的策略,包括数据类型错误及语法解析错误,并提供了FlexBuilder警告抑制、光标定位及Flex与Servlet交互的解决方案。

1.encoding inherited from container

change the default setting of eclipse eclipse encoding inherited from container Window-->Preferences->General-->Workspace-->Text file encoding


2.php

Fatal error: Unsupported operand types

翻译成中文就是:

致命错误:不支持的操作数据类型

产生原因,将不符合数据类型的数据传送给了某些函数。比如我就不小心将一个数组传给了我的一个自定义函数,而这个函数接受的参数应该是数字


3.php

Parse error: parse error, expecting `T_PAAMAYIM_NEKUDOTAYIM' in D:\wamp\www\oss\html\sys_statisc\silverStatisc.html on line 19

分析:一般是因为在html中少写了$,T_PAAMAYIM_NEKUDOTAYIM其实就是::


4.flex builder 

如何在 Flex Builder 中不显示 warning

 

Open the Compiler Properties dialog box, select Project -> Properties -> Flex Compiler. In input fileld  "Additional compiler arguments:" you can type commands for disabling warnings.

To disable ActionScript warnings : -show-actionscript-warnings=false

To disable Binding warnings: -show-binding-warnings=false

To disable all warnings: -warnings=false

PS:因为在 Flex Builder 中 “Export Release Bui



5.flex 光标设置

 

在网页中嵌入flash(如登录界面)时,有时需要默认自动将光标移动到相应的输入框中,如果只在Application的
creationComplete事件中写textinput.setFocus(),会发现虽然输入框获得了焦点,但是并没有将光标移动到输入框,因此
无法直接在里面输入。此时,只需要在setFocus()方法调用前回调一个js方法,也可以写成如下形式: 
ExternalInterface.call('function 
browserFocus(){document.getElementById(\'Login\').focus();}'); 
其中Login为嵌入网页的flash的id,这时你会发现,光标已被默认至于你想要的那个输入框中了.如果你建的是一个flex工程,该id一般和工程名是一致的。

可以去查看bin-debug目录下,对应的html文件中attributes.id = "你要的id";

比如说你的应用是 test.mxml ,则去找bin-debug目录下test.html文件中attributes.id 的值。

 

6.FlexContext.getFlexSession()在servlet的doPost方法中不能用的问题解决

我的经验告诉我,FlexContext.getFlexSession()在servlet的doPost方法中得到的值是null,也就是说我们在servlet中无法通过FlexContext.getFlexSession()来获得session中的attribute值。

比如说在用户登录的时候记录下用户的信息FlexContext.getFlexSession().setAttribute("user", vo);,在flex调用的servlet需要用到session值应该怎么办呢?可以这样获得:

public void doPost(HttpServletRequest req, HttpServletResponse res)
   throws ServletException, IOException {
  String basePath = super.getServletContext().getRealPath("");
  res.setContentType("text/html; charset=UTF-8");
  String currentTimeMillis = String.valueOf(System.currentTimeMillis());
  // 获得当前用户id
  UsersVO uservo =(UsersVO) req.getSession().getAttribute("user");
  String userId=uservo.getUserid();

。。。。。。

}

 

7.创建Flex4SDK的Project为什么不生成html-template

创建Flex工程时,设置默认的SDK版本为3.5.创建完成生成html后,再将工程的SDK编译版本改成4.

 

 

[INFO] Downloading from : http://10.250.127.11:13620/org/apache/maven/plugins/maven-install-plugin/2.5.2/maven-install-plugin-2.5.2.pom [INFO] Downloading from : http://10.250.127.11:13620/org/apache/maven/plugins/maven-plugins/25/maven-plugins-25.pom这个地址能正常下载文件<?xml version='1.0' encoding='UTF-8'?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.apache.maven</groupId> <artifactId>maven-parent</artifactId> <version>24</version> <relativePath>../../pom/maven/pom.xml</relativePath> </parent> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-plugins</artifactId> <version>25</version> <packaging>pom</packaging> <name>Apache Maven Plugins</name> <description>Maven Plugins</description> <url>http://maven.apache.org/plugins/</url> <scm> <connection>scm:svn:http://svn.apache.org/repos/asf/maven/plugins/tags/maven-plugins-25</connection> <developerConnection>scm:svn:https://svn.apache.org/repos/asf/maven/plugins/tags/maven-plugins-25</developerConnection> <url>http://svn.apache.org/viewvc/maven/plugins/tags/maven-plugins-25</url> </scm> <ciManagement> <system>Jenkins</system> <url>https://builds.apache.org/job/maven-plugins/</url> </ciManagement> <distributionManagement> <site><!-- to be copied in every plugin pom, since inheritance adds unwanted artifactId --> <id>apache.website</id> <url>scm:svn:https://svn.apache.org/repos/infra/websites/production/maven/content/${maven.site.path}</url> </site> </distributionManagement> <properties> <maven.site.path>plugins-archives/${project.artifactId}-LATEST</maven.site.path> </properties> <repositories> <repository> <id>apache.snapshots</id> <name>Apache Snapshot Repository</name> <url>http://repository.apache.org/snapshots</url> <releases> <enabled>false</enabled> </releases> </repository> </repositories> <build> <pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-changes-plugin</artifactId> <version>2.9</version> <configuration> <issueManagementSystems> <issueManagementSystem>JIRA</issueManagementSystem> </issueManagementSystems> <maxEntries>1000</maxEntries> <runOnlyAtExecutionRoot>true</runOnlyAtExecutionRoot> <!-- Used by announcement-generate goal --> <templateDirectory>org/apache/maven/plugins</templateDirectory> <!-- Used by announcement-mail goal --> <subject>[ANN] ${project.name} ${project.version} Released</subject> <toAddresses> <toAddress implementation="java.lang.String">announce@maven.apache.org</toAddress> <toAddress implementation="java.lang.String">users@maven.apache.org</toAddress> </toAddresses> <ccAddresses> <ccAddress implementation="java.lang.String">dev@maven.apache.org</ccAddress> </ccAddresses> <!-- These values need to be specified as properties in the profile apache-release in your settings.xml --> <fromDeveloperId>${apache.availid}</fromDeveloperId> <smtpHost>${smtp.host}</smtpHost> </configuration> <dependencies> <!-- Used by announcement-generate goal --> <dependency> <groupId>org.apache.maven.shared</groupId> <artifactId>maven-shared-resources</artifactId> <version>1</version> </dependency> </dependencies> </plugin> <plugin> <artifactId>maven-release-plugin</artifactId> <configuration> <tagBase>https://svn.apache.org/repos/asf/maven/plugins/tags</tagBase> <releaseProfiles>apache-release,rat,run-its</releaseProfiles> </configuration> </plugin> </plugins> </pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-scm-publish-plugin</artifactId> <configuration> <content>${project.reporting.outputDirectory}</content><!-- plugins are mono-module, no real need for site:stage --> </configuration> </plugin> <plugin> <artifactId>maven-enforcer-plugin</artifactId> <executions> <execution> <goals> <goal>enforce</goal> </goals> <id>ensure-no-container-api</id> <configuration> <rules> <bannedDependencies> <excludes> <exclude>org.codehaus.plexus:plexus-component-api</exclude> </excludes> <message>The new containers are not supported. You probably added a dependency that is missing the exclusions.</message> </bannedDependencies> </rules> <fail>true</fail> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-plugin-plugin</artifactId> <executions> <execution> <id>generated-helpmojo</id> <goals> <goal>helpmojo</goal> </goals> </execution> </executions> </plugin> </plugins> </build> <reporting> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-plugin-plugin</artifactId> <version>3.2</version> </plugin> </plugins> </reporting> <profiles> <profile> <id>quality-checks</id> <activation> <property> <name>quality-checks</name> <value>true</value> </property> </activation> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-docck-plugin</artifactId> <executions> <execution> <id>docck-check</id> <phase>verify</phase> <goals> <goal>check</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </profile> <profile> <id>run-its</id> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-invoker-plugin</artifactId> <configuration> <debug>true</debug> <projectsDirectory>src/it</projectsDirectory> <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo> <preBuildHookScript>setup</preBuildHookScript> <postBuildHookScript>verify</postBuildHookScript> <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath> <settingsFile>src/it/settings.xml</settingsFile> <pomIncludes> <pomInclude>*/pom.xml</pomInclude> </pomIncludes> </configuration> <executions> <execution> <id>integration-test</id> <goals> <goal>install</goal> <goal>integration-test</goal> <goal>verify</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </profile> <profile> <id>reporting</id> <reporting> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-invoker-plugin</artifactId> <version>1.8</version> </plugin> </plugins> </reporting> </profile> <profile> <id>maven-3</id> <activation> <file> <!-- This employs that the basedir expression is only recognized by Maven 3.x (see MNG-2363) --> <exists>${basedir}</exists> </file> </activation> <build> <plugins> <!-- if releasing current pom with Maven 3, site descriptor must be attached --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-site-plugin</artifactId> <inherited>false</inherited> <executions> <execution> <id>attach-descriptor</id> <goals> <goal>attach-descriptor</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </profile> </profiles> </project>
08-13
“**Carry-Inherited State Encoding**”(进位继承状态编码)并不是一个标准术语,而是对一类**在动态规划中处理进位传播问题时所采用的状态压缩技巧的概括性描述**。它常见于涉及**二进制位运算、多重选择与组合计数**的问题中,比如: > 给定数组 `nums`,从其中重复选取元素构成长度为 `M` 的序列,要求所有 $2^{\text{index}}$ 的和的二进制表示恰好有 `K` 个 1,求所有合法序列对应的乘积之和。 这类问题如果直接枚举所有可能的“选择次数”组合会爆炸,因此需要一种巧妙的状态设计来**隐式模拟进位过程**,而不需要显式存储巨大的整数和。 --- ## 🧠 核心思想:用状态变量“折叠”进位链 ### 传统做法的问题 假设我们选择索引 `i` 共 `r_i` 次,则总和为: $$ S = \sum_{i=0}^{n-1} r_i \cdot 2^i $$ 这个 `S` 可能非常大(指数级),无法作为 DP 状态存储。 但我们只关心 `popcount(S)` —— 即 `S` 的二进制中 1 的个数。 关键洞察是: > ✅ **我们可以在逐位处理的过程中,一边累加选择数量,一边模拟进位,并记录当前已确定的低位中 1 的个数。** 这就是 carry-inherited state encoding 的本质。 --- ## 🔍 状态定义解析 设: > `dp[i][j][p][q] =` 处理完前 `i` 个索引(0 ~ i−1),共选择了 `j` 个元素,当前进位状态为 `p`,低 `i` 位中已有 `q` 个 1 的所有方案的加权和(通常是 $\prod \frac{nums[t]^{r_t}}{r_t!}$) 这里的 `p` 就是所谓的“carry-inherited state”——它不是一个真实的数值,而是一个**携带了进位信息的中间状态变量**。 --- ## 🔄 状态转移详解 当我们处理第 `i` 个索引时,决定选它 `r` 次: - 它贡献了 `r` 个 $2^i$ - 加上来自低位的进位输入 `p` - 当前位的实际值 = `(p + r) % 2` → 是否为 1? - 向高位进位 = `(p + r) // 2` - 所以下一状态的进位输入变为:`new_p = (p + r) // 2` - 如果 `(p + r)` 是奇数,则当前位是 1,计入 `q` 但注意!官方题解使用了一种更精巧的形式: > $ f(i+1, j+r, \left\lfloor \frac{p}{2} \right\rfloor + r, q + (p \bmod 2)) $ 这看起来不一样?其实它是等价变换的一种**折叠表示法(folded representation)**。 --- ## 💡 折叠表示法(Folded Representation)详解 这种编码方式的核心在于: > 不是在处理到第 `i` 位时才加上 `r_i`,而是把 `r_i` 视为对“当前进位流”的扰动。 让我们重新理解状态 `f(i, j, p, q)` 中的 `p`: > `p` 表示的是:如果我们把前面所有的选择都“压入”一个虚拟的二进制数中,那么当前这个数右移 `i` 位后的结果(即尚未结算的高位部分)。 换句话说,`p` 是一个“延迟展开”的进位累积器。 ### 举个例子 假设我们已经选择了: - index 0: 3 次 → 贡献 `3 * 2^0 = 3` - index 1: 1 次 → 贡献 `1 * 2^1 = 2` - 总和 = 5 = `101₂` 现在处理 `i = 2`,此时: - 我们已经知道低 2 位的情况 - `p` 应该是 `(当前总和) >> 2 = 5 >> 2 = 1` - `q` 是低 2 位中有多少个 1:`01` → 1 个 → `q = 1` 所以状态是 `f(2, 4, 1, 1)` 当我们继续选择 `r` 次 index 2: - 新增 `r * 2^2` - 实际影响的是更高位,但我们可以更新 `p` 为:`p_new = (p >> 1) + r`?不对! 等等 —— 回到原转移式: > $ f(i,j,p,q) \to f(i+1, j+r, \left\lfloor \frac{p}{2} \right\rfloor + r, q + (p \bmod 2)) $ 这意味着: - `p mod 2` 决定了第 `i` 位是否为 1 → 计入 `q` - `floor(p / 2)` 是剩余的进位,传递给下一位 - 加上本次新增的 `r` 个 $2^{i+1}$?不完全是。 实际上,这里的 `p` 并不是“当前总和右移 i”,而是一种**逆向构造的生成函数状态**。 --- ## ✅ 正确理解:基于生成函数与进位分解 考虑如下构造: 令 `F[i][j][p]` 表示前 `i` 项选了 `j` 次,且当前未结算的“权重和”为 `p` 的状态。 每当我们加入 `r` 次 index `i`,相当于往生成函数中添加 `r` 个 $2^i$。 但由于我们是从低到高处理,每一位的最终值取决于: - 本位的选择数 - 来自低位的进位 于是我们采用如下策略: ```text 当前状态:p(表示当前累积的“待处理数值”) → 取 p 的最低位:bit = p & 1 → 若为1,则计入 popcount(q) → 进位输出:carry_out = p >> 1 → 加上当前选择 r → 新输入为:carry_out + r → 下一状态 p' = carry_out + r ``` 但这仍然不是原始公式。 --- ## ✅ 最合理的解释:状态 `p` 是“未来进位输入” 参考 [OI Wiki - 数位DP](https://oi-wiki.org/dp/number/) 和类似题目(如 “魔法序列”),我们可以这样理解: > `f(i, j, p, q)` 中的 `p` 表示:**从第 `i` 位开始,将要进入第 `i` 位及更高位的“净进位量”**。 当你处理第 `i` 位时: - 你收到进位 `p` - 你选择 `r` 次 index `i` → 相当于你在第 `i` 位增加了 `r` - 所以第 `i` 位的总输入是:`total = p + r` - 第 `i` 位的输出是:`total % 2`(决定是否计入 `q`) - 向第 `i+1` 位进位:`total // 2` - 所以下一状态的进位输入为:`p' = total // 2` 但原式是: > $ f(i+1, j+r, \left\lfloor \frac{p}{2} \right\rfloor + r, q + (p \bmod 2)) $ 这说明: - 它没有把 `r` 加到 `p` 上,而是单独加到了高位 - 它认为当前 `p` 的奇偶性决定了当前位是否为 1 - 它把 `p//2` 作为进位输出,再加上 `r` 作为新的输入 这只有在一个前提下成立: > ❗ `p` 已经包含了之前所有选择的完整进位信息,而 `r` 是额外注入的新选择。 也就是说,**`p` 是一个“延迟生效”的进位池**,它的每一位代表不同层级的进位需求。 --- ## ✅ 推荐替代视角:递归进位模拟 我们写一个清晰版本的 DP 来说明正确逻辑: ```python MOD = 10**9 + 7 def solve(M, K, nums): n = len(nums) # 预计算阶乘和逆元 fact = [1] * (M + 1) for i in range(1, M + 1): fact[i] = fact[i-1] * i % MOD def inv(x): return pow(x, MOD-2, MOD) # dp[i][used][carry][ones] from collections import defaultdict dp = defaultdict(int) dp[(0, 0, 0, 0)] = 1 # i, used, carry_in, ones_count for i in range(n): new_dp = defaultdict(int) for (idx, used, carry, ones), coef in dp.items(): max_r = M - used base = 1 # nums[i]^r for r in range(max_r + 1): # 选 r 次 index i total = carry + r bit = total & 1 new_carry = total >> 1 new_ones = ones + bit new_used = used + r if new_used <= M and new_ones <= K: frac = base * inv(fact[r]) % MOD new_coef = coef * frac % MOD key = (i+1, new_used, new_carry, new_ones) new_dp[key] = (new_dp[key] + new_coef) % MOD base = base * nums[i] % MOD dp = new_dp result = 0 for (i, used, carry, ones), val in dp.items(): if used == M: final_popcount = ones + bin(carry).count('1') if final_popcount == K: result = (result + val * fact[M]) % MOD return result ``` 在这个实现中: - `carry` 是真实进位输入 - `total = carry + r` 是第 `i` 位的总输入 - `bit = total & 1` 是当前位是否为 1 - `new_carry = total >> 1` 是向高位进位 这才是直观且正确的 carry propagation。 --- ## 🔚 总结:“Carry-Inherited State Encoding” 到底是什么? | 特性 | 说明 | |------|------| | 🎯 目标 | 避免直接存储巨大整数,仅通过状态模拟进位 | | 🧩 核心思想 | 将“选择次数”转化为“位级贡献”,逐位结算 popcount | | 📦 状态设计 | `dp[i][used][carry][ones]`,其中 `carry` 是进位输入 | | 🔁 转移逻辑 | `total = carry + r`, `new_carry = total // 2`, `ones += total % 2` | | ✅ 优势 | 时间复杂度可控(通常 O(n*M*C*K),C 是 carry 上界) | > ⚠️ 注意:`carry` 的增长受 `M` 限制(最多 M 次选择),所以 `carry ≤ M`,可以作为状态。 --- ###
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值