前往
大廳
主題

[OJ練習] 113、10110

テリ君(桃夫模式) | 2022-12-02 15:04:33 | 巴幣 10 | 人氣 162

113(1/5)

#include <stdio.h>
#include <math.h>

int main(){
    float n, p;
    float result;
    
    while(scanf("%f", &n) != EOF){
        if(n > 200) break;
        scanf("%f", &p);
        
        result = pow(p, 1.0 / n);
        
        printf("%.0f\n", result);
    }
    
    return 0;
}

10110(1/5)

#include <stdio.h>
#include <math.h>

// for any integers, when n can be sqrt(n), then it will have odd number of factors, else not.

int main(){
    int n;
    int i;
    while(scanf("%d", &n) != EOF){
        if(n == 0) break;
        i = sqrt(n);
        if(i * i == n) printf("yes\n");
        else printf("no\n");
    }
    
    return 0;
}


題目開始導入一些math.h內函式的應用了,好耶。
而且我發現我的英文理解也要再加強,明明看BBC或是CNN新聞都還能懂,但OJ的題目怎麼卻像是在看文言文。

創作回應

更多創作