We have a group of N items (represented by integers from 1 to N), and we know that there is some total order defined for these items. You may assume that no two elements will be equal (for all a, b: a<b or b<a). However, it is expensive to compare two items. Your task is to make a number of comparisons, and then output the sorted order. The cost of determining if a < b is given by the bth integer of element a of costs (space delimited), which is the same as the ath integer of element b. Naturally, you will be judged on the total cost of the comparisons you make before outputting the sorted order. If your order is incorrect, you will receive a 0. Otherwise, your score will be opt/cost, where opt is the best cost anyone has achieved and cost is the total cost of the comparisons you make (so your score for a test case will be between 0 and 1). Your score for the problem will simply be the sum of your scores for the individual test cases.
標簽:
represented
integers
group
items
上傳時間:
2016-01-17
上傳用戶:jeffery
I=imread('fig1.jpg');%從D盤名為myimages的文件夾中讀取。格式為jpg的圖像文件chost
J=imnoise(I,'salt & pepper',0.02);%給圖像加入均值為0,方差為0.02的淑鹽噪聲
subplot(2,4,1);
imshow(I);
title('原始圖像');
subplot(2,4,2);
imshow(J);
title('加入椒鹽噪聲之后的圖像');
%h=ones(3,3)/9; %產生3 × 3的全1數組
%B=conv2(J,h); %卷積運算
%采用MATLAB中的函數對噪聲干擾的圖像進行濾波
Q=wiener2(J,[3 3]); %對加噪圖像進行二維自適應維納濾波
P=filter2(fspecial('average',3),J)/255; %均值濾波模板尺寸為3
K1=medfilt2(J,[3 3]); %進行3 × 3模板的中值濾波
K2= medfilt2(J,[5 5]); %進行5 × 5模板的中值濾波
K3= medfilt2(J,[7 7]); %進行7 × 7模板的中值濾波
K4= medfilt2(J,[9 9]); %進行9 × 9模板的中值濾波
%顯示濾波后的圖像及標題
subplot(2,4,3);
imshow(Q);
title('3 × 3模板維納濾波后的圖像');
subplot(2,4,4);
imshow(P);
title('3 × 3模板均值濾波后的圖像');
subplot(2,4,5);
imshow(K1);
title('3 × 3模板的中值濾波的圖像');
subplot(2,4,6);
imshow(K2);
title('5 × 5模板的中值濾波的圖像');
subplot(2,4, 7);
imshow(K3);
title('7 × 7模板的中值濾波的圖像');
subplot(2,4,8);
imshow(K4);
title('9 × 9模板的中值濾波的圖像');
標簽:
matlab
均值濾波
中值濾波
上傳時間:
2016-06-02
上傳用戶:wxcr_1
實驗源代碼
//Warshall.cpp #include<stdio.h> void warshall(int k,int n) { int i , j, t; int temp[20][20]; for(int a=0;a<k;a++) { printf("請輸入矩陣第%d 行元素:",a); for(int b=0;b<n;b++) { scanf ("%d",&temp[a][b]); } } for(i=0;i<k;i++){ for( j=0;j<k;j++){ if(temp[ j][i]==1) { for(t=0;t<n;t++) { temp[ j][t]=temp[i][t]||temp[ j][t]; } } } } printf("可傳遞閉包關系矩陣是:\n"); for(i=0;i<k;i++) { for( j=0;j<n;j++) { printf("%d", temp[i][ j]); } printf("\n"); } } void main() { printf("利用 Warshall 算法求二元關系的可傳遞閉包\n"); void warshall(int,int); int k , n; printf("請輸入矩陣的行數 i: "); scanf("%d",&k);
四川大學實驗報告 printf("請輸入矩陣的列數 j: "); scanf("%d",&n); warshall(k,n); }
標簽:
warshall
離散
實驗
上傳時間:
2016-06-27
上傳用戶:梁雪文以