SWUSTOJ #480 Locker doors

  • 题目
    • 输入
    • 输出
    • 样例输入
    • 样例输出
  • 源代码

题目

There are n lockers in a hallway numbered sequentially from 1 to n. Initially, all the locker doors are closed. You make n passes by the lockers, each time starting with locker #1. On the ith pass, i = 1, 2, …, n, you toggle the door of every ith locker: if the door is closed, you open it, if it is open, you close it. For example, after the first pass every door is open; on the second pass you only toggle the even-numbered lockers (#2, #4, …) so that after the second pass the even doors are closed and the odd ones are opened; the third time through you close the door of locker #3 (opened from the first pass), open the door of locker #6 (closed from the second pass), and so on. After the last pass, which locker doors are open and which are closed? How many of them are open? Your task is write a program to output How many doors are open after the last pass? Assumptions all doors are closed at first.

输入

a positive numbers n, total doors. n<=100000

输出

a positive numbers ,the total of doors opened after the last pass.

样例输入

10

样例输出

3

源代码

#include <iostream>
#include <cmath>int main() {int n(0), count(0);std::cin >> n;for (int i = 1; pow(i, 2) <= n; ++i)count++;std::cout << count << std::endl;return 0;
}

SWUSTOJ #480 Locker doors相关推荐

  1. 【算法----->Locker Doors】

    LockerDoors 题目 输入 输出 代码实现(Java) 例子 题目 There are n lockers in a hallway numbered sequentially from 1 ...

  2. There are n lockers in a hallway numbered sequentially from 1 to n. Initially, all the locker doors

    package xuexi; /*  * n把锁问题  */ import java.util.ArrayList; import java.util.Arrays; import java.util ...

  3. 仅用 480 块 GPU 跑出万亿参数!全球首个“低碳版”巨模型 M6 来了

    继今年 3 月阿里达摩院发布国内首个千亿参数多模态大模型 M6(MultiModality-to-MultiModality MultitaskMega-transformer,以下简称 M6) 之后 ...

  4. IBM Rational DOORS通过DXL进行二次开发初试(2)

    2019独角兽企业重金招聘Python工程师标准>>> 1.如果是在Module模块菜单添加功能只需要在:C:\Program Files(x86)\IBM\Rational\DOO ...

  5. 仅480块GPU搞出万亿参数大模型!达摩院3个月打造,出手即商用

    金磊 发自 凹非寺 量子位 报道 | 公众号 QbitAI 不要6000张GPU!不要2000张TPU! 只要480,万亿参数大模型"抱回家"! 还没完,更惊艳的在后边. 同为万亿 ...

  6. 剑桥少儿英语预备级教案(上) unit8 How many doors?

    1使学生进一步熟悉1`5的数字 2 使学生学会6~10的数字 3 使学生加深对单`复数的概念 4 使学生能模仿发出字母及所给单词的读音 5 使学生能读出第7部分所给出的句子 交际句型: How man ...

  7. 北京2019高考分数线:本科理423文480

    北京2019高考分数线已公布,详情如下: 本科普通批录取控制分数线:文480,理423 自主招生等特殊类型录取控制分数线:文559,理527 艺术类本科录取控制分数线:文335,理295 体育教育.社 ...

  8. 分辨率设置640*480

    在桌面空白处点右键,然后选属性--设置--高级--适配器---列出所有模式,里面应该就有640*480选中,然 后再点应用就OK了 转载于:https://blog.51cto.com/sdzian/ ...

  9. 【多线程】多线程锁住的是什么、std::lock_guard<std::mutex> locker(mutex_)

    通常不直接使用 mutex,lock_guard更加安全, 更加方便. lock_guard简化了 lock/unlock 的写法, lock_guard在构造时自动锁定互斥量, 而在退出作用域时会析 ...

最新文章

  1. 设计模式5-抽象工厂模式
  2. 为什么我害怕数据结构学得好的程序员?
  3. 4 个 MySQL 优化工具 AWR,帮你准确定位数据库瓶颈!
  4. python调用hive与java调用区别_Python操作Hive的两种方法总结
  5. 伺服系统控制网络的重要性! 现场总线的重要性! SSCNET运动控制系统与发展趋势
  6. C#函数(构造函数)的重载
  7. Atitit 自然语言处理原理与实现 attilax总结
  8. 手机组态软件 APP监控台达PLC C#全套源代码,C#开发上位机手机APP
  9. ListView优化
  10. 强制删除“无法删除文件/文件夹”方法全集合
  11. python写网络爬虫的环境搭建(windows完整版)
  12. MT6627处理器芯片资料介绍
  13. Single Yuanz(单一原则)
  14. 【教程】jadx反编译工具的安装
  15. 侯捷C++->参数传递与返回值
  16. 美国总统拜登下令降半旗悼念枪击案遇难者
  17. CodeBlocks+wxWidgets
  18. 【解决方案】A session ended very soon after starting. Check that the command in profile “XXX” is correct.
  19. 【从零开始玩量化9】jqktrader:同花顺客户端自动化交易
  20. 全球最厉害的 14 位程序员!传说代码没过编译的时候,编译器就会道歉...

热门文章

  1. idea安装proto插件后不能识别.proto文件解决方案
  2. Flink X Hologres构建企业级Streaming Warehouse
  3. pre标签手机端问题
  4. Java 封装基础知识
  5. vite + vue3 + 封装axios + 封装loading + 封装返回顶部
  6. 数据库管理-第七十九期 儿童节惊魂(20230601)
  7. Routinebot - 一款小巧的GUI自动化测试工具
  8. C | 进程和线程的区别
  9. 开箱即用:100个Linux Shell脚本经典案例解析
  10. 用matlab卷积神经网络遇到的问题——gpu和cpu的结果不一样,最后的预测结果也有问题