luyencode / comments

Server lưu trữ bình luận trên Luyện Code
https://luyencode.net
6 stars 3 forks source link

https://oj.luyencode.net/problem/MISSNUM #466

Open utterances-bot opened 3 years ago

utterances-bot commented 3 years ago

Chi tiết bài tập - Luyện Code Online

https://luyencode.net/problem/MISSNUM

tuankietcoderr commented 3 years ago

ủa ông Siro, output phải là 2 chứ nhỉ

tuankietcoderr commented 3 years ago

Cho thời gian 10ms hơi khó chịu nha :)))

Đây là lời giải của mình đã AC. Nếu bạn đã cố gắng mà chưa làm được thì có thể tham khảo lời giải của mình.

Xem code AC

``` #include #include int findMissingElement(int arr[], int n) { for (int i = 0; i < n; i++) { int absVal = abs(arr[i]); if (absVal - 1 < n) { arr[absVal - 1] = -arr[absVal - 1]; } } for (int i = 0; i < n; i++) { if (arr[i] > 0) { return i + 1; } } return n + 1; } int main() { int n; scanf("%d",&n); int a[n]; for(int i=0;i

vipgun98s2 commented 2 years ago

cùng 1 code, submit 2 lần 2 thời điểm 1 lần AC 1 lần PA :v

ghost commented 2 years ago

Muốn AC thì code đúng như mình nha (ko đc đổi thành int hay long long)

Xem code AC

``` #include int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(NULL); std::cout.tie(NULL); long n; std::cin >> n; long temp = (n + 1) * (n + 2) / 2; for(long i = 0; i < n; i++) { long x; std::cin >> x; temp -= x; } std::cout << temp; return 0; } ```