NierPod042 发布于四月 11, 2020 分享 发布于四月 11, 2020 于 2020/4/9 于 AM12点35分, 摸鱼奇才咖啡喵 说道: 辛苦了www 咱再给自己揽活,咱就变成了加非苗了www 三次元同好會快比現實還要可怕了ww NierPod042目睹该饮使用黑魔法和萌懒签订契约使其成为了妹妹,得到3节操并碎了一地 链接到点评
NierPod042 发布于四月 11, 2020 分享 发布于四月 11, 2020 初級題: 18+21+22=61 #include <stdio.h> #include <ctype.h> void min(const int arr[]); int answer[7]; int main(){ int sumof3numbers,ans,ans1,ans2,ans3; sumof3numbers = 0; ans = ans1 = ans2 = ans3 = 1; int arr[7] = {0}; for (arr[0] = 153;arr[0]>=1;arr[0]--){ for (arr[1] = arr[0]-1;arr[1]>=1;arr[1]--){ printf("Finish 1 arr[%d][%d] round.\n", arr[0], arr[1]); if(arr[0]+arr[1]>159)continue; for (arr[2] = 1;arr[2]<159-arr[0]-arr[1];arr[2]++){ if(arr[2]==arr[0]||arr[2]==arr[1])continue; for (arr[3] = 1;arr[3]<159-arr[0]-arr[1]-arr[2];arr[3]++){ if(arr[3]==arr[0]||arr[3]==arr[1]||arr[3]==arr[2])continue; for (arr[4] = 1;arr[4]<159-arr[0]-arr[1]-arr[2]-arr[3];arr[4]++){ if(arr[4]==arr[0]||arr[4]==arr[1]||arr[4]==arr[2]||arr[4]==arr[3])continue; for (arr[5] = 1;arr[5]<159-arr[0]-arr[1]-arr[2]-arr[3]-arr[4];arr[5]++){ if(arr[5]==arr[0]||arr[5]==arr[1]||arr[5]==arr[2]||arr[5]==arr[3]||arr[5]==arr[4])continue; arr[6] = 159 - arr[0] - arr[1] - arr[2] - arr[3] - arr[4] - arr[5]; if(arr[6]==arr[0]||arr[6]==arr[1]||arr[6]==arr[2]||arr[6]==arr[3]||arr[6]==arr[4]||arr[6]==arr[5])continue; if (arr[0]==0||arr[1]==0||arr[2]==0||arr[3]==0||arr[4]==0||arr[5]==0||arr[6]==0)printf("Warning! =0!\n"); if (arr[6]>0){ min(arr); sumof3numbers = answer[0]+answer[1]+answer[2]; if (sumof3numbers > ans){ ans = sumof3numbers; ans1 = answer[0];ans2 = answer[1];ans3 = answer[2];printf("Find a solution: %d + %d + %d + %d + %d + %d + %d = %d\n", arr[0],arr[1],arr[2],arr[3],arr[4],arr[5],arr[6], sumof3numbers);} } } } } } } } printf("%d + %d + %d = %d ", ans1, ans2, ans3, ans); return 0; } void min(const int arr[]){ int i, j, pass; int flag = 1; for (i = 0;i<=6;i++){ answer[i]= arr[i];} for (pass = 1;pass<=7;pass++){ if (flag==0) break; flag = 0; for(j = 0;j<=5;j++){ if (answer[j]> answer[j+1]){ int hold = answer[j+1]; answer[j+1] = answer[j]; answer[j] = hold;flag = 1;} } } } 算得好慢w NierPod042在前往新手村的路上遇见了劫道的风神烈破,收取过路费-4节操 链接到点评
推荐贴