Skip to content

Instantly share code, notes, and snippets.

@KT-Yeh
Last active January 4, 2016 08:59
Show Gist options
  • Save KT-Yeh/8599150 to your computer and use it in GitHub Desktop.
Save KT-Yeh/8599150 to your computer and use it in GitHub Desktop.
#include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
int a,b;
while (scanf("%d%d",&a,&b)!=EOF){ // 43,19
printf("[%d;",a/b); // [2;
a %= b; // 5,19
while(a!=1){
printf("%d,",b/a); // [2;3, / [2;3,1,
b %= a; // 5,4 / 4,1
swap (a,b); // 4,5 / 1,4
}
printf("%d]\n",b); // [2;3,4,1]
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment