Fork me on GitHub

NYOJ题目1047欧几里得

---------------------------------------

相邻的两个自然数互质,所以与n互质并且不大于n的最大数就是n-1了,还有就是稍微注意一下数据范围。

 

AC代码:

 1 import java.math.BigInteger;
 2 import java.util.Scanner;
 3 
 4 public class Main {
 5 
 6     public static void main(String[] args) {
 7         
 8         Scanner sc=new Scanner(System.in);
 9         int times=sc.nextInt();
10         while(times-->0) System.out.println(sc.nextBigInteger().subtract(BigInteger.ONE));
11         
12     }
13     
14 }

 

题目来源: http://acm.nyist.net/JudgeOnline/problem.php?pid=1047

posted @ 2016-09-14 03:54  CC11001100  阅读(142)  评论(0编辑  收藏  举报