提交时间:2023-12-07 13:32:29
运行 ID: 114375
# include <bits/stdc++.h> using namespace std ; int stn [114514] ; int lsw ( int a [] , int sze ) { int i , j , t ; while ( sze > 1 ) { for ( i = 0 ; i < 2 ; i ++ ) { for ( j = 0 ; j < sze - i - 1 ; j ++ ) { if ( a [j] > a [j + 1] ) { swap ( a [j] , a [j + 1] ) ; } } } a [sze - 2] = a [sze - 1] - a [sze - 2] ; sze -- ; } return a [0] ; } int main ( ) { int n ; cin >> n ; for ( int i = 0 ; i < n ; i ++ ) { cin >> stn [i] ; } cout << lsw ( stn , n ) << endl ; return 0 ; }