Poj 3370 Halloween Treats

Source: Internet
Author: User

Poj 3370 Halloween Treats

 

Description

Every year there is the same problem at Halloween: Each neighbor is only willing to give a certain total number of sweets on that day, no matter how many children call on him, so it may happen that a child will get nothing if it is too late. to avoid conflicts, the children have decided they will put all sweets together and then divide them evenly among themselves. from last year's experience of Halloween they know how many sweets they get from each neighbor. since they care more about justice than about the number of sweets they get, they want to select a subset of the neighbors to visit, so that in sharing every child would es the same number of sweets. they will not be satisfied if they have any sweets left which cannot be divided.

Your job is to help the children and present a solution.

Input

The input contains several test cases.
The first line of each test case contains two integers c and n (1 ≤ c ≤ n ≤ 100000), the number of children and the number of neighbors, respectively. the next line contains n space separated integers a1 ,... , An (1 ≤ ai ≤ 100000), where ai represents the number of sweets the children get if they visit neighbor I.

The last test case is followed by two zeros.

Output

For each test case output one line with the indices of the neighbors the children shocould select (here, index I corresponds to neighbor I who gives a total number of ai sweets ). if there is no solution where each child gets at least one sweet print "no sweets" instead. note that if there are several solutions where each child gets at least one sweet, you may print any of them.

Sample Input

4 5
1 2 3 7 5
3 6
7 11 2 5 13 17
0 0
Sample Output

3 5
2 3 4

Give you a number m and n, then there are n numbers a [I], find out a few numbers that are multiples of m, and write down the number of a [I, if there are multiple, write one,
Solution: Drawer principle, pay attention to some details, use long and scanf,
Code:

# Include
  
   
# Include
   
    
# Include
    
     
Using namespace std; const int maxn = 100000 + 5; typedef long LL; LL a [maxn]; LL mod [maxn]; int main () {int m, n; while (~ Scanf (% d, & m, & n) {if (m = 0 & n = 0) break; memset (a, 0, sizeof (a); int k; for (int I = 1; I <= n; I ++) // method 1 // scanf (% d, & a [I]); //, mod [I] =-2; // memset (mod,-1, sizeof (mod )); // mod [0] =-1;/* LL sum = 0; for (int I = 0; I
     
    
   
  

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.