您的位置:首页 > 其它

sdut3260——Single Round Math(大数模)

2017-04-29 19:24 239 查看


Single Round Math

Time Limit: 1000MS Memory Limit: 65536KB

Submit Statistic Discuss


Problem Description

Association for Couples Math (ACM) is a non-profit organization which is engaged in helping single people to find his/her other half. As November 11th is “Single Day”, on this day, ACM invites a large group of singles
to the party. People round together, chatting with others, and matching partners.
There are N gentlemen and M ladies in the party, each gentleman should only match with a lady and vice versa. To memorize the Singles Day, ACM decides to divides to divide people into 11 groups, each group should
have the same amount of couples and no people are left without the groups.
Can ACM achieve the goal?


Input

The first line of the input is a positive integer T. T is the number of test cases followed. Each test case contains two integer N and M (0 ≤ N, M ≤ 10^1000), which are the amount of gentlemen and ladies.


Output

For each test case, output “YES” if it is possible to find a way, output “NO” if not.


Example Input

3
1 1
11 11
22 11



Example Output

NO
YES
NO

给定n个绅士和m个美女,要求能把他们分成11对,每对一男一女。

a!=b  显然不行。 a%11!=0 显然不行

#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <stack>
using namespace std;
typedef long long ll;
#define PI 3.1415926535897932
#define E 2.718281828459045
#define INF 0xffffffff//0x3f3f3f3f
#define mod 997

const int M=1005;
int n,m;
int cnt;
int sx,sy,sz;
int mp[1000][1000];
int pa[M*10],rankk[M];
int head[M*6],vis[M*100];
int dis[M*100];
ll prime[M*1000];
bool isprime[M*1000];
int lowcost[M],closet[M];
char st1[5050],st2[5050];
int len[M*6];
typedef pair<int ,int> ac;
//vector<int> g[M*10];
ll dp[50][1<<10][50];
int has[10500];
int month[13]= {0,31,59,90,120,151,181,212,243,273,304,334,0};
int dir[8][2]= {{0,1},{0,-1},{-1,0},{1,0},{1,1},{1,-1},{-1,1},{-1,-1}};

void getpri()
{
    ll i;
    int j;
    cnt=0;
    memset(isprime,false,sizeof(isprime));
    for(i=2; i<1000000LL; i++)
    {
        if(!isprime[i])prime[cnt++]=i;
        for(j=0; j<cnt&&prime[j]*i<1000000LL; j++)
        {
            isprime[i*prime[j]]=1;
            if(i%prime[j]==0)break;
        }
    }
}
struct node
{
    int v,w;
    node(int vv,int ww)
    {
        v=vv;
        w=ww;
    }
};
vector<int> g[M*100];
char str[100005];
int ind[2550];
int bit[50];
int K;
bool judge(string a){//大数取摸
    int len=a.length();
    int i=0,ans=0;
    while(i<len){
        ans=ans*10+(a[i]-'0');
        i++;
        ans%=11;
    }
    return ans==0;
}
int main()
{
    int i,j,k,t;
    ll l,r;
    int cas=0;
    string a,b;
    //memset(dp,-1,sizeof(dp));
    scanf("%d",&t);
    while(t--)
    {
        cin>>a>>b;
        if(a!=b){cout<<"NO\n";continue;}
        if(judge(a))cout<<"YES\n";
        else cout<<"NO\n";
    }
    return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: