a035: Who is missing? 誰不見了?
標籤 : Array 陣列
通過比率 : 100% (30 人 / 30 人 ) (非即時)
評分方式 :
Tolerant

最近更新 : 2019-02-12 15:04

內容

Suppose there are n students and each student is numbered a different number in the range of [1, n]. For some class, the teacher realizes that there is a student missing. The teacher does not want to do a roll call and what the teacher has are the numbers of the students in class. Your job is to help the teacher finding out which student (number) is missing. (You can think that all the numbers are stored in an array of size n-1)

假設有n個學生,並且每個學生在[1, n]的範圍內給定不同的編號。對於某些課程,老師發現到有一個學生不見了。 老師不想點名,老師只有班上學生的數量。你的工作是幫助老師找出不見的學生(編號)。(您可以認為所有數字都存儲在大小為n-1的陣列中)

輸入說明

The input consists of two lines. The first line is the total number of students, n. The second line is the array containing all the numbers, representing the students in class, and each number is separated by a space.

1 ≤ n ≤ 70000.

輸入由兩行組成。第一行是學生總數,n。第二行是包含所有數字編號的陣列,代表課堂上的學生,每個數字編號用空格分隔。

1 ≤ n ≤ 70000.

輸出說明

The output contains the missing number (student).

輸出包含缺少的數字編號(學生)。

範例輸入
6 
1 3 4 5 6
範例輸出
2
測資資訊 :
記憶體限制 : 64 MB
隱藏 測資點#0 (50%): 1.0s , <1K
隱藏 測資點#1 (50%): 1.0s , <1K
提示 :
標籤:
Array 陣列
出處:
線上協同學習平臺 - ITSA 教育部資通訊軟體創新人才推升計畫 [編輯 :
zero_jason (zero_jason(MANAGER))
]


編號 身分 題目 主題 人氣 發表日期
沒有發現任何「解題報告」