Input示例
6 10 1 2 3 4 5 6
Output示例
1 4
#include "cstdio" #include "algorithm" #include "iostream" #include "set" using namespace std; #define LL long long #define N 10010 int arr[N]; int main() { int k,n; while(~scanf("%d%d",&n,&k)){ for(int i=0;i<n;i++){ scanf("%d",&arr[i]); } LL sum=0; int a=1,b=1; bool c=0; for(int i=0;i<n;i++){ sum=arr[i];a=i+1; for(int j=i+1;j<n;j++){ if(sum==k) { c=1; break; } sum+=arr[j];b=j+1; } if(c) break; } if(!c) printf("No Solution\n"); else printf("%d %d\n",a,b); } return 0; }
时间: 2024-10-20 13:44:25