#42073: c++解法


yp11351280@yphs.tp.edu.tw (810-43韓睿哲)

學校 : 臺北市私立延平高級中學
編號 : 276272
來源 : [203.72.178.1]
最後登入時間 :
2025-10-07 16:36:49

 
if(a!=0) (a%c==0)?cout<<a/c<<endl:cout<<c-a%c<<endl;
else return 0;
 
 
#43125: Re: c++解法


yp11351280@yphs.tp.edu.tw (810-43韓睿哲)

學校 : 臺北市私立延平高級中學
編號 : 276272
來源 : [203.72.178.1]
最後登入時間 :
2025-10-07 16:36:49

 
if(a!=0) (a%c==0)?cout<
else return 0;
 
 


這樣也可以:

#include<iostream>
using namespace std;
int main(){
    int m,t;
    cin>>m;
    while(cin>>t, t!=0){
        if(t%m==0) cout<<t/m<<"\n";
        else cout<<m-(t%m)<<"\n";
    }
}