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


Cytus47 (Cytus47)

學校 : 不指定學校
編號 : 308138
來源 : [111.246.120.185]
最後登入時間 :
2025-10-05 11:02:16

#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)

學校 : 不指定學校
編號 : 308138
來源 : [111.246.120.185]
最後登入時間 :
2025-10-05 11:02:16

#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)

學校 : 南投縣立旭光高級中學
編號 : 68108
來源 : [114.42.176.221]
最後登入時間 :
2025-10-04 22:52:03

可能要處理大數吧.