通過 : 22 人 /24 次 | 送出 : 23 人 /63 次 | 通過比率 : 96%
公開 測資點 1 (100%): 1.0s, 512 MB | 評分方式: Tolerant
最近更新 : 2013-02-26 06:33
公開 測資點 1 (100%): 1.0s, 512 MB | 評分方式: Tolerant
最近更新 : 2013-02-26 06:33
內容 :
伺服器用一些技術來增加磁碟效能,也複製資料到額外的硬碟以防止其中一個故障時導致資料的遺失。這些技術我們稱為 RAID (Redudant Array of Inexpensive Disks)。常用的 RAID 層級有三種:
- RAID 0: 把兩個或更多的硬碟結合為一個硬碟,它們的資料「帶狀」交叉。這方法增加了硬碟的效能,但不提供任何資料的保護。例如:三個 250GB 的硬碟組成一個 RAID 陣列,在使用者看來,就像一個 750 GB 的硬碟。
- RAID 1: 每一個硬碟都有一個重複的硬碟,彼此「鏡射」對方的資料。儘管這方式並不會增加容量,但當其中一個故障時,資料不會遺失。鏡射的硬碟必須是完全相同的一對。例如:把一個 500GB 硬碟鏡射到另一個 500GB 的硬碟。使用者雖然只看到一個 500GB 的硬碟,但是得知就算有硬碟故障資料也不會遺失,會讓你睡得更安穩。
- RAID 5: 這個方式將 2 個或更多 (最多 7 個) 硬碟帶狀交叉,並在另一個完全相同的硬碟上產生同位元資料。這好比使用 RAID 0,並加一個由整個群組共用的鏡射硬碟。例如:以 RAID 5 的方式安排四個 400GB 的硬碟——其中三個硬碟透過帶狀交叉產生一個 1200GB 的硬碟,而第四個硬碟只是用來容錯。
輸入說明 :
每筆測資一行,含有所需的陣列容量 (不含鏡射) 及 RAID 層級。根據硬碟的容量,產生的陣列容量可以大於所需的容量。
輸出說明 :
你的程式要輸出能提供所需容量的最便宜的陣列組合,包括所需的硬碟容量及數量,陣列總容量及陣列的成本。
範例輸入 :
450 1 1200 0 600 5 1300 1 3000 5 4500 5
範例輸出 :
Qty: 2 Disk: 500GB Price: $140 Total price of this 500GB array: $280 Qty: 3 Disk: 400GB Price: $110 Total price of this 1200GB array: $330 Qty: 4 Disk: 250GB Price: $75 Total price of this 750GB array: $300 Qty: 6 Disk: 500GB Price: $140 Total price of this 1500GB array: $840 Qty: 7 Disk: 500GB Price: $140 Total price of this 3000GB array: $980 Qty: 7 Disk: 750GB Price: $250 Total price of this 4500GB array: $1750
提示 :
出處 :
(管理:snail)
----------------------------------------------------------------------------------------------------#include<stdio.h>
int d[10][2]={{250,75},{400,110},{500,140},{750,250}};
int main(){
int ans,cnt,type,n,m,k,p,i,j;
while(scanf("%d%d",&n,&m)!=EOF){
ans=99999999;
if(m==0){
for(i=0;i<4;i++){
p=(n+d[i][0]-1)/d[i][0];
k=p*d[i][1];
if(p<=8 && k<ans)
ans=k,cnt=p,type=i;
}
printf("Qty: %d Disk: %dGB Price: $%d\n",cnt,d[type][0],d[type][1]);
printf("Total price of this %dGB array: $%d\n",cnt*d[type][0],ans);
}
if(m==1){
for(i=0;i<4;i++){
p=(n+n+d[i][0]-1)/d[i][0];
k=p*d[i][1];
if(p%2==0 && p<=8 && k<ans)
ans=k,cnt=p,type=i;
}
printf("Qty: %d Disk: %dGB Price: $%d\n",cnt,d[type][0],d[type][1]);
printf("Total price of this %dGB array: $%d\n",cnt*d[type][0]/2,ans);
}
if(m==5){
for(i=0;i<4;i++){
p=(n+d[i][0]-1)/d[i][0];
k=(p+1)*d[i][1];
if(p<=7 && k<ans)
ans=k,cnt=p,type=i;
}
printf("Qty: %d Disk: %dGB Price: $%d\n",cnt+1,d[type][0],d[type][1]);
printf("Total price of this %dGB array: $%d\n",cnt*d[type][0],ans);
}
puts("");
}
}
沒有留言:
張貼留言