/* Name: NYOJ--927--The partial sum problem Author: shen_渊 Date: 15/04/17 19:41 Description: DFS,和 NYOJ--1058--dfs--部分和问题 基本一致,递归的i+1注意了,其他没什么 */ #include<cstring> #include<iostream> using namespace std; void dfs(int); ],vis[]; int n,k,sum,flag; int main() { // freopen("in.txt","r",stdin); while(cin>>n){ memset(vis,,sizeof(vis)); memset(arr,,sizeof(arr)); flag = ; ; i<n; ++i)cin>>arr[i]; cin>>k; dfs(); if(flag)cout<<"Of course,I can!\n"; else cout<<"Sorry,I can't!\n"; } ; } void dfs(int ct) { if(sum == k){ flag = ; return ; } for(int i=ct; i<n; ++i){ if(sum+arr[i] <= k) { vis[i] = ; sum += arr[i]; dfs(i+); sum -= arr[i]; vis[i] = ; if(flag)return; } } }