我試圖解決一個編程問題,爲明天的比賽練習,我想也許這將是一個問好如何接近它的好地方。問題是這個網站上的第一個問題:http://www.cs.rit.edu/~icpc/questions/2010/Oswego_2010.pdfACM編程問題
本網站上的FAQ提及算法和數據結構的概念,以及設計模式,所以我想問如何解決這個問題並不是主題。這是我到目前爲止(不多)。我不明白如何解決這個問題。
public class Ape
{
public void computeOutput(int weight, int[] capacities, int[] snackLosses)
{
//not sure what to do
}
public static void main(String [] args) throws FileNotFoundException
{
Ape ape = new Ape();
File file = new File(args[0]);
Scanner in = new Scanner(file);
int totalWeight = in.nextInt();
int n = in.nextInt();
int[] capacities = new int[n];
int[] snackLosses = new int[n];
for (int i = 0; i < n; i++)
{
capacities[i] = in.nextInt();
snackLosses[i] = in.nextInt();
}
ape.computeOutput(totalWeight, capacities, snackLosses);
}
}
一個極壞的問題描述:我沒有找到最佳的香蕉帶回家量的話。所以,當你逐字解釋時,你只需要一個「包裝」的猿,可以攜帶確切數量的可用香蕉。還有一個非常典型的ACM問題,因爲它們沒有指示數字的大小(例如N爲數十,數千,數百萬或甚至更大的數量級)。 – flolo