/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 320.0 KiB
#2 Accepted 0ms 320.0 KiB
#3 Accepted 1ms 388.0 KiB

Code

#include <stdio.h>

// Function to count the number of odd numbers from 1 to N
int countOddNumbers(int N) {
    // Since every alternate number is odd, we can simply divide N by 2 to get the count of odd numbers
    // For example, if N = 5, there are (5+1)/2 = 3 odd numbers (1, 3, 5)
    return (N + 1) / 2;
}

int main() {
    int T;
    scanf("%d", &T);

    while (T--) {
        int N;
        scanf("%d", &N);
        printf("%d\n", countOddNumbers(N));
    }

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1041 Odd number
Contest
TLE_Headquarters - round #1
Language
C99 (GCC 13.2.0)
Submit At
2024-03-27 16:10:48
Judged At
2024-11-11 03:39:31
Judged By
Score
100
Total Time
1ms
Peak Memory
388.0 KiB