编程介的小学生 2017-01-24 09:59 采纳率: 20.5%
浏览 908
已采纳

Happy 2006

Description

Two positive integers are said to be relatively prime to each other if the Great Common Divisor (GCD) is 1. For instance, 1, 3, 5, 7, 9...are all relatively prime to 2006.

Now your job is easy: for the given integer m, find the K-th element which is relatively prime to m when these elements are sorted in ascending order.
Input

The input contains multiple test cases. For each test case, it contains two integers m (1 <= m <= 1000000), K (1 <= K <= 100000000).
Output

Output the K-th element in a single line.
Sample Input

2006 1
2006 2
2006 3
Sample Output

1
3
5

  • 写回答

1条回答 默认 最新

  • coolComputer 2017-01-24 11:06
    关注

    自己写了段Java代码 但不能完全解决您的问题 希望给您提供下思路:

     package lottery;
    
    import java.util.Scanner;
    
    public class example {
    
        public static void main(String[] args) {
            // TODO Auto-generated method stub
            Scanner scan = new Scanner(System.in);
            System.out.print("Please Enter the group:");
            int group = scan.nextInt();
            int[][] Array = new int[group][2];
            System.out.println("Now,Please input the numbers:");
            for (int i = 0; i < group; i++) {
                Array[i][0] = scan.nextInt();
                Array[i][1] = scan.nextInt();
            }
            System.out.println("The Results:");
            for (int i = 0; i < group; i++) {
                System.out.println(Array[i][1] * 2 - 1);
            }
        }
    }
    
    
    ![图片说明](https://img-ask.csdn.net/upload/201701/24/1485255989_828045.png)
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 MATLAB中streamslice问题
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 51单片机中C语言怎么做到下面类似的功能的函数(相关搜索:c语言)
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序