#include<iostream> using std::cin; using std::cout; using std::ios; #define MH "MHAHAHAHAHAHAHAHA!!!" #define HELP "HEEEEEEELP!!!!!!!!!!!" #define endl '\n' #define MAXN 1000001 // 并查集 int father[MAXN] = {0}; int size[MAXN] = {0};
Classmate L forgot to elect his course, so he had to take a strange PE course. On this strange course, students will play a weird game: each male student represent , and each female students represent . When a teacher says a non-zero positive integer number of , male students and female students need to gather together and keep .
Classmate L is bad at math, he wants to know how many people he will be gathering together with.
Lots of students forgot to elect courses too, so we can assume that there is an infinite number of male and female students.
输入数据
One line containing three non-zero positive integer , , . .
Meaning of and are described above. means there will be queries.
For the next line, each line contains a non-zero positive integer .
输出数据
For each query, output the number of male students and the number of
female students separated by a space.
If it’s not possible form , output ARE YOU KIDDING ME?.
If there are multiple answers, output the answer as the greatest
number of male students.
#include<iostream> usingnamespace std; intmain(){ int n,a,b,c; cin>>n>>a>>b; while(n--){ cin>>c; int x = 0; int y = 0; c -= a; for(x = c / a; x >= 0; x --){ if ((c - a * x) % b == 0){ y = (c - a * x) / b; break; } } if (x == -1) { cout<<"ARE YOU KIDDING ME?"<<endl; } else { cout<<x<<" "<<y<<endl; } } return0; }