51Nod 1094 和为k的连续区间
2024-09-02 18:51:14
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;
const int maxn = + ;
int a[maxn];
LL sum[maxn]; int main(){
std::ios::sync_with_stdio(false);
int n, k;
cin >> n >> k;
memset(sum, , sizeof(sum));
for (int i = ; i <= n; i++){
cin >> a[i];
sum[i] = sum[i - ] + a[i];
}
bool ok = false;
for (int i = ; i <= n; i++){ //可能只是自己,所以从0开始
for (int j = i; j <= n; j++){
if (sum[j] - sum[i] == k){
cout << i+ << " " << j << endl; //因为从0开始,所以i需要加1
ok = true;
break;
}
}
if (ok)
break;
}
if (!ok)
cout << "No Solution" << endl;
//system("pause");
return ;
}
最新文章
- CSS手动改变DIV高宽
- 七牛整合PHP上传文件
- Lucky and Good Months by Gregorian Calendar - POJ3393模拟
- C# 获取本机指定类型指定网卡的Ip地址
- Quality Center配置邮箱服务
- CF339
- iOS 通过个推 推送原理
- Android 关于调用系统内已安装的相机问题
- Oracle Sql优化之Merge 改写优化Update
- 【视频编解码&#183;学习笔记】2. H.264简介
- C#学习之接口
- MySQL api
- 不正常退出vim产生swp文件的解决方法
- Dubbo与Zookeeper在Window上的安装与简单使用
- float 、double 加减乘除出现小数位多出的问题
- 2017/05/03 java 基础 随笔
- cf1061D 贪心+multiset 好题!
- 12月centos单词
- 微信小程序笔记<;七>;视图层 —— wxml
- 第十章&#160;优先级队列 (b4)完全二叉堆:批量建堆
热门文章
- 转移iOS App常见问题和回答
- eclipse配置android
- Please verify that your device’s clock is properly set, and that your signing certificate is not exp
- Spark学习笔记:(一)入门 glance
- filter、servlet、interceptor的执行顺序
- h5 getUserMedia error PermissionDeniedError
- [转]GPS经纬度的表示方法及换算
- IE8 下背景图标不显示
- redis02---对于key的操作命令
- SDUT OJ 1221 亲和数 (找出某个数n所有的因子数,只需要暴力:2->;sqrt(n) 即可 )