#46038: 求助,沒有測資怎麼知道錯哪阿


Cytus47 (Cytus47)


#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main(){
int a,b,x,y,n;
cin>>n;
cout<<endl;
cin>>a>>b;
x=1;
y=1;
if(n>=0 && n<=50){
    if (n == 0) {
            x = 1;
            y = 1;
        } else {
            for (int i = 0; i < n; ++i) {
                x *= a;
                y *= b;
            }
        }
    if(n%2==1){
        cout<<"能"<<endl;
        cout<<(x+y)<<endl;
    }
    else {
        cout<<"不能"<<endl;
    }
}
return 0;
}

#46039: Re: 求助,沒有測資怎麼知道錯哪阿


Cytus47 (Cytus47)


#include
#include
#include
using namespace std;

int main(){
int a,b,x,y,n;
cin>>n;
cout<cin>>a>>b;
x=1;
y=1;
if(n>=0 && n<=50){
    if (n == 0) {
            x = 1;
            y = 1;
        } else {
            for (int i = 0; i < n; ++i) {
                x *= a;
                y *= b;
            }
        }
    if(n%2==1){
        cout<<"能"<        cout<<(x+y)<    }
    else {
        cout<<"不能"<    }
}
return 0;
}

有想到GMP,但沒辦法用

#46040: Re: 求助,沒有測資怎麼知道錯哪阿


asnewchien@gmail.com (david)


可能要處理大數吧.