这是一个简单的问题:我有一个长度为N的数组,给定2个边界(a,b)的函数返回a和b之间数组中所有元素的总和.
现在,这显然是O(N)时间复杂度......但是如果我想使它更有效(如log(N)),使用存储部分和的第二个数据结构,我该如何实现它?
我在考虑二叉树,但找不到算法.当然我可以创建一个NxN矩阵,但它太多了.我想要一些不需要太多空间的东西,让我有一个对数时间复杂度; 任何的想法?
更新:我没有明确说明..但是:
我是PHP的新手.
我有一个显示用户个人资料的页面.我需要将用户ID传递给此页面,以便显示正确的配置文件.
我只是不使用该<form>元素.我想要一个链接
<a href="/users/24378234298734">或<a href="/users/?id=24378234298734">
或任何
由于我没有使用表单,我不能在处理程序页面上使用_GET或_POST在处理程序页面上处理参数的最佳方法是什么?
在api level 4(android 1.6)上拍照后使用:
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
File photo = new File(Environment.getExternalStorageDirectory(), "NewPic.jpg");
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo));
imageUri = Uri.fromFile(photo);
startActivityForResult(intent, TAKE_PICTURE);
Run Code Online (Sandbox Code Playgroud)
我想查看我的所有照片缩略图,但没有我的最后一张照片缩略图.它在android 2.1上完美运行.
如果我通过USB将设备连接到PC,则扫描完成后会出现断开连接的文件.那么我应该如何开始索引呢?
我试过了
mScanner = new MediaScannerConnection(getApplicationContext(), this);
mScanner.connect();
mScanner.scanFile(imageUri.getEncodedPath(), "*/*");
Run Code Online (Sandbox Code Playgroud)
并以此结束:
02-24 17:13:54.678: DEBUG/MediaScannerService(1320): IMediaScannerService.scanFile: /sdcard/NewPic2222.jpg mimeType: */*
02-24 17:13:54.688: VERBOSE/MediaProvider(1320): /sdcard volume ID: 1149784819
02-24 17:13:54.688: VERBOSE/MediaProvider(1320): key exists
Run Code Online (Sandbox Code Playgroud)
稍后编辑
在其他活动中,我有这样的感觉
mCursorThumbnails = MediaStore.Images.Thumbnails.queryMiniThumbnails(mContentResolver, MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, MediaStore.Images.Thumbnails.MINI_KIND, projection);
mCursorImages = MediaStore.Images.Media.query(mContentResolver, MediaStore.Images.Media.EXTERNAL_CONTENT_URI, projection);
Run Code Online (Sandbox Code Playgroud)
当我检查第一个值的计数时,我有13个元素,而在第二个我有14个.所以图像已经添加到mediascanner,但是OS没有为它生成缩略图.那么我该如何要求操作系统创建一个呢?
我正在清理旧的构建定义,我想备份它们,以防有一些我缺少的东西,有没有办法使用Visual Studio 2010导出构建定义?
这是一种我可以在多次调用 addPage 后返回到上一页的方法,因为当我调用 write 时,它将它添加到当前页面,我需要它在第一页上写入。我已经浏览了它的文档,但似乎找不到任何东西?
顺便说一下,我正在 php 创建我的 pdf
谢谢
我正在构建我的VS2010解决方案,在输出窗口中,只有一个项目出错.
在错误选项卡中:
Error 161 Cannot register type library "D:\Sites\Website\MyPortal.Website.Controllers\bin\Debug\MyPortal.Website.Controllers.tlb". Error accessing the OLE registry. (Exception from HRESULT: 0x8002801C (TYPE_E_REGISTRYACCESS)) MyPortal.Website.Controllers
Run Code Online (Sandbox Code Playgroud)
在输出选项卡中:
Compile complete -- 0 errors, 153 warnings
MyPortal.Website.Controllers -> D:\Sites\Website\MyPortal.Website.Controllers\bin\Debug\MyPortal.Website.Controllers.dll
c:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(3341,9): warning MSB3214: "D:\Sites\Website\MyPortal.Website.Controllers\bin\Debug\MyPortal.Website.Controllers.dll" does not contain any types that can be registered for COM Interop.
c:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(3341,9): error MSB3213: Cannot register type library "D:\Sites\Website\MyPortal.Website.Controllers\bin\Debug\MyPortal.Website.Controllers.tlb". Error accessing the OLE registry. (Exception from HRESULT: 0x8002801C (TYPE_E_REGISTRYACCESS))
========== Rebuild All: 8 succeeded, 1 failed, 0 skipped ==========
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
我是Python的新手.我在Python 2.7上测试这个代码但是给了我一个错误.
import statsout
def output(data, format="text"):
output_function = getattr(statsout, "output_%s" % format, statsout.output_text)
return output_function(data)
Run Code Online (Sandbox Code Playgroud)
错误:
Traceback (most recent call last):
File "C:\Documents and Settings\anlopes\workspace\test\src\test.py", line 1, in <module>
import statsout
ImportError: No module named statsout
Run Code Online (Sandbox Code Playgroud)
有人能给我一个错误的线索吗?
最好的祝福,
Objective-C类中C++对象的对象生命周期是什么,以及如何将其保存在内存中?
我尝试了不透明的结构,创建实例,但总是导致null.
在ASP.NET MVC3中,当我使用EF Code First时,如何在SQL Server视图中显示数据?
如何让FixedDocument自动分页?我有以下代码可用于将美化面板放入DocViewer.当Panel扩展到单个页面时会发生此问题.现在,我们只是剪辑.基本上,我想创建一种相当通用的方式来打印用户正在查看的内容.我的方法合理吗?
public void CreateReport(Panel details)
{
FixedDocument fixedDoc = new FixedDocument();
PageContent pageContent = new PageContent();
FixedPage fixedPage = new FixedPage();
fixedPage.DataContext = this.DataContext;
fixedPage.Margin = new Thickness(10);
fixedPage.Children.Add(details);
((System.Windows.Markup.IAddChild)pageContent).AddChild(fixedPage);
fixedDoc.Pages.Add(pageContent);
// This makes the array of controls invisibile, then climbs the details structure
// and makes the controls within details appropriate for the DocumentViewwer (i.e. TextBoxes are
// non-editable, no borders, no scroll bars, etc).
prePrintPrepare(details, fixedPage, new FrameworkElement[] { controlToMakeInvisible });
_dv = new DocViewer();
_dv.documentViewer1.Document = fixedDoc; …Run Code Online (Sandbox Code Playgroud) php ×2
algorithm ×1
android ×1
asp.net-mvc ×1
c++ ×1
code-first ×1
definitions ×1
hyperlink ×1
ios ×1
objective-c ×1
optimization ×1
pagination ×1
python ×1
tcpdf ×1
tfs2010 ×1
tfsbuild ×1
typelib ×1
wpf ×1