#include

2257: 找数字

2257: 找数字

时间限制: 1 Sec  内存限制: 128 MB
提交: 88  解决: 62
[提交][状态][讨论版][命题人:zhd]

题目描述

输入两个整数a,b,从n个整数找出能够被a整除,或被b整除,但不能同时被a,b整除数

输入

第1行输入两个整数a,b
第2行输入1个n(0<n<10000)
第3行是n个整数.

输出

输出能够被a整除,或被b整除,但不能同时被a,b整除的数,用空格隔开

样例输入

2 3
3
15 16 24

样例输出

15 16
#include<cstdio>
#include<iostream>
#include<algorithm>

using namespace std ; 

int a, b ; 
int n ; 
int num ; 

int main(){

    cin>>a>>b ; 
    cin>>n ; 

    while(n--){
        cin>>num ; 

        if(!(num%a==0&&num%b==0) && (num%a==0||num%b==0)){
            cout<<num <<" " ; 
        }
    }


    return 0 ; 
}

 

 
posted @ 2018-04-21 15:59  0一叶0知秋0  阅读(686)  评论(0编辑  收藏  举报