编程介的小学生 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 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?