ITSA [C_MM058-中] 二項式求解

Problem

http://e-tutor.itsa.org.tw/e-Tutor/mod/programming/view.php?a=1005

Thinking

TODO

Solution

#include 
#include 
using namespace std;

int main(){
    
    int a,b,c;
    char str[256]="";

    char *temp;
    while(cin >> str){
        
        // 處理輸入
        temp = strtok(str,",");
        a = atoi(temp);
        for(int i = 0 ; i < 2 ; i++){
            temp = strtok(NULL,",");
            if(i==0){
                b = atoi(temp);
            }else if(i==1){
                c = atoi(temp);
            }
        }
        
        // 計算答案
        for(int i = 0 ; i <= c/a ; i++){
            if((c-a*i) % b == 0)
                cout << i << "," << (c-a*i) / b << endl;
        }
    }
}

你可能感兴趣的:(ITSA [C_MM058-中] 二項式求解)