看到数据范围第一时间反应就是这道题应该是规律题 应该不可能是其他的吧 即使是其他的我可能也不会-.-
后面发现其实就是gcd(a,b)就是答案。
import java.util.*; import java.math.*; import java.io.IOException; import java.io.InputStreamReader; import java.io.StreamTokenizer; import java.io.OutputStreamWriter; import java.io.BufferedReader; import java.io.PrintWriter; public class Main { public static HashMap<Integer,Long>map = new HashMap<>(); public static void main(String args[])throws IOException { StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)); Scanner input = new Scanner(System.in); long a = input.nextLong(); long b = input.nextLong(); String n = input.nextLine(); System.out.print(gcd(a,b)); } public static long gcd(long a,long b) { return b==0?a:gcd(b,a%b); } }