diff --git a/4062_dui/dui.cpp b/4062_dui/dui.cpp index 790561f..67193a9 100644 --- a/4062_dui/dui.cpp +++ b/4062_dui/dui.cpp @@ -1,5 +1,13 @@ #include using namespace std; +bool bi(int f[],int n,int j){ + for(int i=1;i<=j;i++){ + if(f[i]==n){ + return 0; + } + } + return 1; +} int main(){ int n,a[1001]={0},f[1001]={0}; int pan=0; @@ -10,8 +18,9 @@ int main(){ for(int i=a[1]-1;i>0;i--){ f[1]=i; for(int j=2;j<=n;j++){ - if(a[j-1]-f[j-1]>0){ - f[j]=a[j-1]-f[j-1]; + int we=a[j-1]-f[j-1]; + if(we>0&bi(f,we,j-1)==1){ + f[j]=we; pan=j; }else{ break; diff --git a/4062_dui/dui.exe b/4062_dui/dui.exe index 6f7aac7..38bd7ef 100644 Binary files a/4062_dui/dui.exe and b/4062_dui/dui.exe differ diff --git a/4062_dui/test/out.txt b/4062_dui/test/out.txt index 71f8eb2..c29fa38 100644 --- a/4062_dui/test/out.txt +++ b/4062_dui/test/out.txt @@ -1,24 +1,24 @@ ## z:\Chao\src\4062_dui\test\in.txt -2020/03/28 周六 9:35:42.10 +2020/03/28 周六 11:44:37.03 ----------------------------------------------- -Process exited after 140 ms with return value 0 +Process exited after 200 ms with return value 0 ## z:\Chao\src\4062_dui\test\In0 (6).txt -2020/03/28 周六 9:35:42.10 +2020/03/28 周六 11:44:37.03 3 1 5 2 4 ----------------------------------------------- -Process exited after 130 ms with return value 0 +Process exited after 90 ms with return value 0 ## z:\Chao\src\4062_dui\test\In1 (9).txt -2020/03/28 周六 9:35:42.10 +2020/03/28 周六 11:44:37.03 4 2 3 1 6 5 ----------------------------------------------- -Process exited after 100 ms with return value 0 +Process exited after 90 ms with return value 0 ## z:\Chao\src\4062_dui\test\In2 (1).txt -2020/03/28 周六 9:35:42.10 -6 5 2 2 5 1 8 +2020/03/28 周六 11:44:37.03 +5 6 1 3 4 2 7 ----------------------------------------------- -Process exited after 80 ms with return value 0 +Process exited after 150 ms with return value 0