903A. Hungry Student Problem#饥饿的学生(暴力&双层枚举)
题目出处: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#饥饿的学生(暴力&双层枚举)的更多相关文章
- 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 ...
- 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 ...
- uva 10837 - A Research Problem(欧拉功能+暴力)
题目链接:uva 10837 - A Research Problem 题目大意:给定一个phin.要求一个最小的n.欧拉函数n等于phin 解题思路:欧拉函数性质有,p为素数的话有phip=p−1; ...
- [LeetCode] Student Attendance Record I 学生出勤记录之一
You are given a string representing an attendance record for a student. The record only contains the ...
- 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 ...
- Codeforces Round #439 (Div. 2) Problem A (Codeforces 869A) - 暴力
Rock... Paper! After Karen have found the deterministic winning (losing?) strategy for rock-paper-sc ...
- [示例]创建Student类,输入学生信息并存入字典,将3个存有学生信息的字典存入数组,并计算
代码: main: #import <Foundation/Foundation.h> #import "Student.h" int main(int argc, c ...
- Problem 1014 xxx游戏 暴力+拓扑排序
题目链接: 题目 Problem 1014 xxx游戏 Time Limit: 1000 mSec Memory Limit : 32768 KB 问题描述 小M最近很喜欢玩XXX游戏.这个游戏很简单 ...
- Codeforces Gym 100342C Problem C. Painting Cottages 暴力
Problem C. Painting CottagesTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/1 ...
随机推荐
- 实验吧Web-难-头有点大(http头伪造:浏览器、国家、.Net framework版本)
进去网站显示: 此处告诉我们要干三件事: (1).net framework 版本为9.9 (2)告诉服务器我们的地址为英国 (3)我们访问站点用的是IE 下面我们就抓的包中伪造. 1:.net fr ...
- tf.summary可视化参数
1.tf.summary.scalar('accuracy', accuracy) 损失值.准确率随着迭代次数的进行,其指标变化情况:一般在画loss,accuary时会用到这个函数. 2.tenso ...
- python *args 和 ** kwargs
可变长度的参数 *args的使用方法 *args 用来将参数打包成tuple给函数体调用 可见,1这个参数,被打包成了一个元组 def func(*args): print(args,type(arg ...
- 常用sql语句(mysql测试)
DB数据库,DatabaseDBMS数据库管理系统,DatabaMemanagmentSystemSQL结构化查询语言,structure Query Language 开启服务net start m ...
- SAP HANA学习笔记
SAP HANA:High-Performance Analytic ApplianceSAP HANA XSC:Extended Application Services Classic(SAP推出 ...
- AT2000 Leftmost Ball 解题报告
题面 给你n种颜色的球,每个球有k个,把这n*k个球排成一排,把每一种颜色的最左边出现的球涂成白色(初始球不包含白色),求有多少种不同的颜色序列,答案对1e9+7取模 解法 设\(f(i,\;j)\) ...
- vscode-wechat 小程序开发提示工具 vscode 安装
vscode 安装 vscode-wechat vscode-wechat 小程序开发提示工具 ---- 有了小程序开发提示,开发很方便 https://segmentfault.com/a/1190 ...
- 牛客小白月赛18——Forsaken的三维数点
这个是一个简单题,不过因为想到比标程时间复杂度更低的方法就尝试了一下. 思路:虽然加点是三维数点,但是我们要求的是半径的大小,这样的话,就可以转变为一维的问题. 标程的解法是,用树状数组维护,然后二分 ...
- .NET CORE 热更新,否则提示DLL文件在使用中
1.创建空目录,取名updatesite,里面放置app_ffline.htm文件,网站更新中访问使用,内容随意 2.updatesite目录下面创建Release目录,用于放置更新的dll文件 3. ...
- winform 集成 log4net
1.引入库log4net.dll 2.展开项目文件下的Properties文件夹,打开AssemblyInfo.cs并在AssemblyInfo.cs中添加一行:在AssemblyInfo.cs中添加 ...