题目出处: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. Standard Aras Dialogs

    In a another blog post, we covered how to open dialogs within Aras Innovator using custom forms and ...

  2. SQL COOKBOOK SQL经典实例代码 笔记第一章代码

    -- SQL COOKBOOK CHAPTER1 -- 查看所有内容 select * from emp; -- 可以单列 select empno,ename,job,sal,mgr,hiredat ...

  3. Linux 下 OpenCV3 安装

    编译安装OpenCV3 从官网下载:http://opencv.org/releases.html 选择一个较新版本的opencv3.X,下载source源代码 下载之后解压,并cd到该文件夹进行编译 ...

  4. VMWare WorkStation15--Win10下开机启动虚拟机

    参考 https://www.cnblogs.com/qmfsun/p/6284236.html http://www.cnblogs.com/eliteboy/p/7838091.html VMWa ...

  5. Python说文解字_Python之多任务_05

    问:在Py3.5之前yield表现非常好,在Py3.5之后为了将予以变得更加明确,就引入了async和await关键词用于定义原生的协议. 答:async和await原生协程: async def d ...

  6. RK3399开发板Android镜像烧写之Windows系统映像烧写

    4.1.1 l RKTool  驱动安装(基于迅为iTOP-3399开发板)DriverAssitant_v4.5.zip 文件,打开 驱动安装成功,如下图: 注意事项:1.目前支持的操作系统包括:X ...

  7. 2019.3.11 JavaScript课上笔记

    ---恢复内容开始--- 字面值写到左边 var  x= "1"; ++x .x++ // 都有隐式类型转换 x += 1; // 是字符串的拼接 === 判断引用的对象是不是同一 ...

  8. maxima安装&使用

    环境: mint 19 或者 > ubuntu 18 源代码安装的好处, 可以使用最新版. mint 19.1 下面, 利用apt 直接安装的maxima版本太老,不支持 draw 函数. lo ...

  9. 吴裕雄--天生自然 JAVASCRIPT开发学习:Window - 浏览器对象模型

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  10. Unix网络编程学习 < 一 >

    #include "unp.h" int main(int argc , char**argv) { int sockfd , n; //sockfd套接字描述符 ]; struc ...