题目连接:

https://vjudge.net/problem/1502082/origin

这一题第一眼看过去貌似是模拟,但是根据其范围是1e9可以知道,如果暴力解基本上是不可能的(不排除大佬级优化)

于是对1---9进行计算可以得到如下结果:

  1 --- 1

  2 --- 2

  3 --- 2

  4 --- 3

  5 --- 3

  6 --- 4

  7 --- 4

  8 --- 5

  9 --- 5

故而有得到规律 n --- n/2+1

根据规律得到代码:

  1. #include <iostream>
  2. #include <cstdio>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. int n;
  9. scanf("%d", &n);
  10. int ans = n/+;
  11. printf("%d\n", ans);
  12. }

如有不懂欢迎评论~

一道有意思的找规律题目 --- CodeForces - 964A的更多相关文章

  1. Codeforces Round #493 (Div. 2)D. Roman Digits 第一道打表找规律题目

    D. Roman Digits time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...

  2. 找规律/贪心 Codeforces Round #310 (Div. 2) A. Case of the Zeros and Ones

    题目传送门 /* 找规律/贪心:ans = n - 01匹配的总数,水 */ #include <cstdio> #include <iostream> #include &l ...

  3. 数学/找规律/暴力 Codeforces Round #306 (Div. 2) C. Divisibility by Eight

    题目传送门 /* 数学/暴力:只要一个数的最后三位能被8整除,那么它就是答案:用到sprintf把数字转移成字符读入 */ #include <cstdio> #include <a ...

  4. 【找规律】Codeforces Round #392 (Div. 2) C. Unfair Poll

    C. Unfair Poll time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  5. Gym - 101775L SOS 博弈 找规律

    题目:https://cn.vjudge.net/problem/Gym-101775L PS:训练赛中被这道题折磨的不轻,和队友反复推必胜态与必败态试图推导出公式或者规律,然后推的心态逐渐失控,,, ...

  6. codeforces D. Queue 找规律+递推

    题目链接: http://codeforces.com/problemset/problem/353/D?mobile=true H. Queue time limit per test 1 seco ...

  7. Codeforces Gym 100114 A. Hanoi tower 找规律

    A. Hanoi tower Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100114 Descript ...

  8. Tetrahedron(Codeforces Round #113 (Div. 2) + 打表找规律 + dp计数)

    题目链接: https://codeforces.com/contest/166/problem/E 题目: 题意: 给你一个三菱锥,初始时你在D点,然后你每次可以往相邻的顶点移动,问你第n步回到D点 ...

  9. 找规律 Codeforces Round #309 (Div. 2) A. Kyoya and Photobooks

    题目传送门 /* 找规律,水 */ #include <cstdio> #include <iostream> #include <algorithm> #incl ...

随机推荐

  1. laravel 路由缓存

    使用路由缓存之前,需要知晓路由缓存只能用于控制器路由,不能用于闭包路由,如果路由定义中包含闭包路由将无法进行路由缓存,只有将所有路由定义转化为控制器路由或资源路由后才能执行路由缓存命令: php ar ...

  2. BrupSuite渗透测试笔记(十)

    一.Brup Repeater通常结合Proxy(历史记录),Scanner(扫描记录).Target(站点地图)等,通过其他工具上的右键执行[Send to Repeater],之后跳转到Repea ...

  3. ubuntu下直接可视化访问服务器文件夹方法

    任意打开一个文件夹在文件夹的左下角输入   sftp://list-2018@10.192.229.62/home/list-2018 list-2018:想登陆的服务器下的帐号 10.192.229 ...

  4. C# 读取sqlite文件

    class Program { static void Main(string[] args) { getsqliteData(); } public static void getsqliteDat ...

  5. SQL Server索引的执行计划

    如何知道索引有问题,最直接的方法就是查看执行计划.通过执行计划,可以回答表上的索引是否被使用的问题. (1)包含索引:避免书签查找 常见的索引方面的性能问题就是书签查找,书签查找分为RID查找和键值查 ...

  6. 字符转ASCII码

    char k = '成'; int str = (int)k; Console.WriteLine(str); 结果25104就是‘成’对应的ASCII值

  7. Git坑换行符自动转换 [转载]

    转自https://www.cnblogs.com/zjoch/p/5400251.html 源起 一直想在 GitHub 上发布项目.参与项目,但 Git 这货比较难学啊.买了一本<Git 权 ...

  8. Linux-GLIBCXX版本过低导致编译错误--version `GLIBCXX_3.4.20' not found

    最近在CentOS6.2上安装protobuf2.4.1,编译的时候出现如下错误: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not fo ...

  9. 借用nginx.vim工具进行语法高亮和格式化配置nginx.conf文件

    在生产环境中,我们肯定经常用到nginx.conf文件的编排工作,今天在阅读<决战nginx>的时候无意间看到nginx.vim这个辅助工具,于是百度搜索和实际部署检测了一下,其效果确实让 ...

  10. Python_迭代器

    迭代器:迭代器里的元素读一个丢一个,不能回退,不能用下标访问 x.__next__():迭代器里唯一的方法,只读下一个 d = iter(['Presly', 'is', 'lovely', ]) p ...