AtCoder Beginner Contest 067 A

来源:互联网 发布:售票软件 编辑:程序博客网 时间:2024/06/06 01:34

A - Sharing Cookies


Time limit : 2sec / Memory limit : 256MB

Score : 100 points

Problem Statement

Snuke is giving cookies to his three goats.

He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins).

Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies.

Constraints

  • 1A,B100
  • Both A and B are integers.

Input

Input is given from Standard Input in the following format:

A B

Output

If it is possible to give cookies so that each of the three goats can have the same number of cookies, print Possible; otherwise, print Impossible.


Sample Input 1

Copy
4 5

Sample Output 1

Copy
Possible

If Snuke gives nine cookies, each of the three goats can have three cookies.


Sample Input 2

Copy
1 1

Sample Output 2

Copy
Impossible

Since there are only two cookies, the three goats cannot have the same number of cookies no matter what Snuke gives to them.


题解:判断n,m,n+m,是否能被整除

#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string.h>
#include<string>
#include<vector>
#include<map>
#include<set>
using namespace std;
map<int,int> mp;
int a[100001];
int main()
{
    int n,m;
    while(cin>>n>>m){
        if(n%3==0||m%3==0||(m+n)%3==0)
            cout<<"Possible"<<endl;
        else cout<<"Impossible"<<endl;
    }
    return 0;
}

原创粉丝点击