Problem | Verdict | Lang | Time | Best | Rank | Submit Time |
---|---|---|---|---|---|---|
| discuss834 - | Accepted | C++11 | 0.000 | 0.000 | 2946 | 1 mins ago |
Suggest:
Example 43 19:
- Rule
43 div 19 = [2;
43 mod 19 = 5
19 div 5 = 3,
19 mod 5 = 4
5 div 4 = 1,
5 mod 4 = 1
4 div 1 = 4]
4 mod 1 = 0 (r < 1 break)
- First i code from this rule, then fix WA in uDebug => Accepted
#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false); cin.tie(nullptr);
int x, y;
while(cin >> x >> y){
cout<<"["<<x/y;
if (x%y) cout<<";";
do{
int r= x%y;
x= y;
y= r;
if (y) cout<<x/y;
if (r>1 && x%y) cout<<",";
else{
cout<<"]\n";
break;
}
}while(1);
}
}
No comments:
Post a Comment