Educational Codeforces Round 34 A. Hungry Student Problem【枚举】
1 second
256 megabytes
standard input
standard output
Ivan's classes at the university have just finished, and now he wants to go to the local CFK cafe and eat some fried chicken.
CFK sells chicken chunks in small and large portions. A small portion contains 3 chunks; a large one — 7 chunks. Ivan wants to eat exactly x chunks. Now he wonders whether he can buy exactly this amount of chicken.
Formally, Ivan wants to know if he can choose two non-negative integers a and b in such a way that a small portions and b large ones contain exactly x chunks.
Help Ivan to answer this question for several values of x!
The first line contains one integer n (1 ≤ n ≤ 100) — the number of testcases.
The i-th of the following n lines contains one integer xi (1 ≤ xi ≤ 100) — the number of chicken chunks Ivan wants to eat.
Print n lines, in i-th line output YES if Ivan can buy exactly xi chunks. Otherwise, print NO.
2
6
5
YES
NO
In the first example Ivan can buy two small portions.
In the second example Ivan cannot buy exactly 5 chunks, since one small portion is not enough, but two small portions or one large is too much.
【分析】:刚开始以为是拓展欧几里得解不定方程(被骚操作冲昏头脑的我)···后来才发现两个for枚举就行。
【代码】:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define oo 10000000
const int mod = 1e6;
int l,n,m;
int ans;
int main()
{
int t,f;
scanf("%d",&t);
while(t--)
{
f=;
scanf("%d",&n);
for(int i=;i<;i++)
{
for(int j=;j<;j++)
{
if(*i+*j==n)
{
f=;
break;
}
}
if(f) break;
}
//printf("%d\n",f);
if(f) puts("YES");
else puts("NO");
}
return ;
}
双重枚举
Educational Codeforces Round 34 A. Hungry Student Problem【枚举】的更多相关文章
- Educational Codeforces Round 34 (Rated for Div. 2) A B C D
Educational Codeforces Round 34 (Rated for Div. 2) A Hungry Student Problem 题目链接: http://codeforces. ...
- Educational Codeforces Round 40 F. Runner's Problem
Educational Codeforces Round 40 F. Runner's Problem 题意: 给一个$ 3 * m \(的矩阵,问从\)(2,1)$ 出发 走到 \((2,m)\) ...
- Educational Codeforces Round 34 (Rated for Div. 2)
A. Hungry Student Problem time limit per test 1 second memory limit per test 256 megabytes input sta ...
- Educational Codeforces Round 34
F - Clear The Matrix 分析 题目问将所有星变成点的花费,限制了行数(只有4行),就可以往状压DP上去靠了. \(dp[i][j]\) 表示到第 \(i\) 列时状态为 \(j\) ...
- Educational Codeforces Round 34 (Rated for Div. 2) D - Almost Difference(高精度)
D. Almost Difference Let's denote a function You are given an array a consisting of n integers. You ...
- Educational Codeforces Round 34 (Rated for Div. 2) C. Boxes Packing
C. Boxes Packing time limit per test 1 second memory limit per test 256 megabytes input standard inp ...
- Educational Codeforces Round 34 D. Almost Difference【模拟/stl-map/ long double】
D. Almost Difference time limit per test 2 seconds memory limit per test 256 megabytes input standar ...
- Educational Codeforces Round 34 C. Boxes Packing【模拟/STL-map/俄罗斯套娃】
C. Boxes Packing time limit per test 1 second memory limit per test 256 megabytes input standard inp ...
- Educational Codeforces Round 34 B. The Modcrab【模拟/STL】
B. The Modcrab time limit per test 1 second memory limit per test 256 megabytes input standard input ...
随机推荐
- getsupportfragmentmanager 没有这个方法
让activity继承自fragmentactivity就行了.
- datagrid的修改和删除功能的实现
1.修改 双击,进入一行的编辑状态的功能的实现 2.删除 3.扩展easyui的datagrid,添加动态增加或删除Editor的方法 (1)背景要求: 对于某一列,比如密码,动态增加时候,是可以编辑 ...
- rest_framework序列化
1.序列化 1)拿到queryset 2)将queryset 给序列化类 serializer = IdcSerializer(idc) #单个对象 serializer = IdcSerial ...
- Django补充知识点——用户管理
内容概要 1.Form表单2.Ajax3.布局,Django母板4.序列化5.Ajax相关6.分页7.XSS攻击8.CSRF9.CBV.FBV 10.类中用装饰器的两种方法 11.上传文件 12.数据 ...
- Session超时和莫名丢失的原因与处理办法
原因: 改动global.asax,Web.config,bin目录里的东西,导致Web Applicatioin重启. 有些杀毒软件会去扫描你的Web.config文件,也会导致Session丢失. ...
- Python框架之Django学习笔记(十五)
表单 从Google的简朴的单个搜索框,到常见的Blog评论提交表单,再到复杂的自定义数据输入接口,HTML表单一直是交互性网站的支柱.本次内容将介绍如何用Django对用户通过表单提交的数据进行访问 ...
- 用html5文件api实现移动端图片上传&预览效果
想要用h5在移动端实现图片上传&预览效果,首先要了解html5的文件api相关知识(所有api只列举本功能所需): 1.Blob对象 Blob表示原始二进制数据,Html5的file对象就继 ...
- SEO相关
前端需要注意哪些SEO 合理的title.description.keywords: -- 搜索对着三项的权重逐个减小,title值强调重点即可,重要关键词出现不要超过2次,而且要靠前,不同页面tit ...
- css盒模型与bfc与布局与垂直水平居中与css设计模式等
一.css盒子与布局相关 盒子内部的布局 盒子之间的布局visual formatting 脱离正常流normal flow的盒子的布局 absolute布局上下文下的布局 float布局上下文下的布 ...
- 【bzoj1041】[HAOI2008]圆上的整点 数论
题目描述 求一个给定的圆(x^2+y^2=r^2),在圆周上有多少个点的坐标是整数. 输入 只有一个正整数n,n<=2000 000 000 输出 整点个数 样例输入 4 样例输出 4 题解 数 ...