题解 | #更相减损术#
更相减损术
https://ac.nowcoder.com/acm/problem/22164
#include <stdio.h> #include <math.h> int main() { int m,n,i; int sum=0; scanf("%d %d",&m,&n); while (n!=m) { if (m>n) m=m-n; else n=n-m; } printf("%d",m); return 0; }
更相减损术
https://ac.nowcoder.com/acm/problem/22164
#include <stdio.h> #include <math.h> int main() { int m,n,i; int sum=0; scanf("%d %d",&m,&n); while (n!=m) { if (m>n) m=m-n; else n=n-m; } printf("%d",m); return 0; }
相关推荐