题目出处:http://codeforces.com/problemset/problem/903/A

题目大意就是:一个数能否用正整数个另外两个数合成

#include<iostream>
using namespace std;
//双重枚举
int main(){
int n;cin>>n;
while(n--){
int temp; cin>>temp; int flag = ;
for(int i=; i</; i++){
for(int j=; j</; j++){
if(i*+j* == temp){ flag = ; break; }//本来想使用连续break发现不行;
}
}
if(flag) cout<<"NO"<<endl;
else cout<<"YES"<<endl;
}
return ;
}

题目数据比较小,可以考虑直接双层循环,暴力求解。

在做本题的时候有失误,也让自己对break的认识在熟悉了一下,本来天真的认为可双break跳到最外层结束;

但是break第一个执行后,后面的break就会被跳开了。使用break的时候注意其作用空间。(低级错误)

本题优化可以一层枚举中使用取余的方法解决。

903A. Hungry Student Problem#饥饿的学生(暴力&双层枚举)的更多相关文章

  1. Educational Codeforces Round 34 A. Hungry Student Problem【枚举】

    A. Hungry Student Problem time limit per test 1 second memory limit per test 256 megabytes input sta ...

  2. Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) Problem C (Codeforces 831C) - 暴力 - 二分法

    Polycarp watched TV-show where k jury members one by one rated a participant by adding him a certain ...

  3. uva 10837 - A Research Problem(欧拉功能+暴力)

    题目链接:uva 10837 - A Research Problem 题目大意:给定一个phin.要求一个最小的n.欧拉函数n等于phin 解题思路:欧拉函数性质有,p为素数的话有phip=p−1; ...

  4. [LeetCode] Student Attendance Record I 学生出勤记录之一

    You are given a string representing an attendance record for a student. The record only contains the ...

  5. Codeforces Round #439 (Div. 2) Problem E (Codeforces 869E) - 暴力 - 随机化 - 二维树状数组 - 差分

    Adieu l'ami. Koyomi is helping Oshino, an acquaintance of his, to take care of an open space around ...

  6. Codeforces Round #439 (Div. 2) Problem A (Codeforces 869A) - 暴力

    Rock... Paper! After Karen have found the deterministic winning (losing?) strategy for rock-paper-sc ...

  7. [示例]创建Student类,输入学生信息并存入字典,将3个存有学生信息的字典存入数组,并计算

    代码: main: #import <Foundation/Foundation.h> #import "Student.h" int main(int argc, c ...

  8. Problem 1014 xxx游戏 暴力+拓扑排序

    题目链接: 题目 Problem 1014 xxx游戏 Time Limit: 1000 mSec Memory Limit : 32768 KB 问题描述 小M最近很喜欢玩XXX游戏.这个游戏很简单 ...

  9. Codeforces Gym 100342C Problem C. Painting Cottages 暴力

    Problem C. Painting CottagesTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/1 ...

随机推荐

  1. Floyd--P1119 灾后重建

    题目背景 B地区在地震过后,所有村庄都造成了一定的损毁,而这场地震却没对公路造成什么影响.但是在村庄重建好之前,所有与未重建完成的村庄的公路均无法通车.换句话说,只有连接着两个重建完成的村庄的公路才能 ...

  2. [题解] Luogu P4721 【模板】分治 FFT

    分治FFT的板子为什么要求逆呢 传送门 这个想法有点\(cdq\)啊,就是考虑分治,在算一段区间的时候,我们把他分成两个一样的区间,然后先做左区间的,算完过后把左区间和\(g\)卷积一下,这样就可以算 ...

  3. 实现VR直播的关键技术

    VR是多媒体技术发展的必然趋势,人们所使用的信息载体从最早的文字.图像,到音视频,再到用VR,将事物的描述表达推向了极致,充分满足了沉浸性.互动性和构想性三大要素的需求.随着5G的商业化运营,VR有望 ...

  4. PAT 2018 春

    A 1140 Look-and-say Sequence 简单模拟.可能要注意字符串第一个字符和最后一个字符的处理. #include <cstdio> #include <iost ...

  5. bestphp's revenge

    0x00 知识点 1利用PHP原生类来构造POP链 本题没有可以利用的类,没有可以利用的类就找不到POP链所以只能考虑PHP原生类 我们先来解释一下什么是POP链 POP:面向属性编程 在二进制利用时 ...

  6. POJ 1094:Sorting It All Out拓扑排序之我在这里挖了一个大大的坑

    Sorting It All Out Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 29984   Accepted: 10 ...

  7. Spring的配置文件说明

    <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...

  8. UVM实战[二]

    本期将讲解UVM环境构成和启动方式.主要参考资料为 http://bbs.eetop.cn/thread-320165-1-1.html http://rockeric.com/ 环境构成 进行仿真验 ...

  9. MySQL--数据导入

    参考:http://blog.csdn.net/jyb2014/article/details/39294879?locationNum=13 可导入大文件. source 导入总是失败.

  10. gitee上传下载代码命令

    在想要下载的文件夹下,鼠标右键,git bash 1.输入git init 进行初始化 2.git remote add origin https://gitee.com/XXXXXXXXXXXXXX ...