Beispiel #1
0
int main(){
    
    int test,n,number,i,j,max=0,maxNumber=0;
    
    scanf("%d", &test);
    
    for (i = 0; i < test; i++){
        
        scanf("%d", &n);
        for (j = 0; j < n; j++){
            
            scanf("%d", &number);
            if (getFirstDigit(number) > max){
               max = getFirstDigit(number);
               maxNumber = number;
               }
            }
        printf("%d\n" , maxNumber);
        maxNumber = 0;
        max = 0;
        
        
        
        }
        
    return 0;
}
Beispiel #2
0
    int countDigitOne(int n) {
        int result = 0;
        int firstDigit = getFirstDigit(n);
        int numDigits = getNumDigits(n);
        if (numDigits == 1) {
            if (firstDigit >= 1)
                result = 1;
        }
        else if (numDigits > 1) {
            int remainder = n - firstDigit*pow(10, numDigits-1);

            for (int k = 1; k < numDigits; k++)
                result += numOneInNDigitNumbers(k);
            
            if (firstDigit > 1) {
                int sum = 0;
                for (int k = 1; k < numDigits; k++)
                    sum += numOneInNDigitNumbers(k);
                result += pow(10, numDigits-1)+(firstDigit-1)*sum;
            }
            else
                result += remainder+1;

            result += countDigitOne(remainder);
        }
        return result;
    }