codeforces 903A.Hungry Student Problem

来源:互联网 发布:外星人源码论坛eenot 编辑:程序博客网 时间:2024/06/05 20:32

题意:T次询问,每次问有没有两个非负整数x,y使得3*x + 7*y = n。

思路:因为数据范围很小直接暴力就可以。

#include<bits/stdc++.h>using namespace std;int main(){int T,n;    scanf("%d",&T);while(T--)    {        scanf("%d",&n);bool flag = false;        for (int i = 0; i <= 100; i++)        {        for (int j = 0; j <= 100; j++)        {        if (i * 3 + j * 7 == n) flag = true;}}        if (flag) puts("YES"); else puts("NO");    }    return 0;}/*265*/


原创粉丝点击