题目连接:

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

根据规律得到代码:

#include <iostream>
#include <cstdio> using namespace std; int main()
{
int n;
scanf("%d", &n);
int ans = n/+;
printf("%d\n", ans);
}

如有不懂欢迎评论~

一道有意思的找规律题目 --- 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 路由模型绑定

    我们在使用路由的时候一个很常见的使用场景就是根据资源 ID 查询资源信息: Route::get('task/{id}', function ($id) { $task = \App\Models\T ...

  2. PDF文件如何标注,怎么使用PDF标注工具

    我们在使用文件的时候需要给文件的部分添加标注,能够更加直观的了解文件,但是有很多小伙伴们对于PDF文件怎么添加标注都不知道,也不知道PDF标注工具要怎么使用,那么下面就跟大家分享一下怎么使用PDF标注 ...

  3. node.js 框架express关于报错页面的配置

    1.声明报错的方法,以及相对应的页面 //把数据库的调用方法配置到请求中 server.use((req, res, next) => { //把数据库存入req中 req.db = db; / ...

  4. linux下搭建SVN

      官网下载: http://subversion.apache.org/packages.html SVN客户端:TortoiseSVN :https://tortoisesvn.net/downl ...

  5. PHP中self和this的用法区别

    PHP支持类和面向对象结构,PHP的类的静态函数和变量不与任何特定类的实例相关联(换句话说,一个对象).请看:类与对象的区别. 相反,静态函数和变量与类定义本身相关联.换言之,一个类的所有实例都共享相 ...

  6. XAML绑定到资源文件字符串时失败

    参考:https://stackoverflow.com/questions/19586401/error-in-binding-resource-string-with-a-view-in-wpf ...

  7. java解析html的table

    import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import org. ...

  8. Git和Github入门教程

    一.常用命令 所有命令前都要加 git,如表中的init是指 git init.点击命令可直接跳转至本文第一次使用的地方.以下命令都在命令行里执行. 1.本地命令 行为 命令 备注 初始化 init ...

  9. nginx 正则及rewrite常用规则实例

    一.正则表达式匹配,其中:* ~ 为区分大小写匹配* ~* 为不区分大小写匹配* !~和!~*分别为区分大小写不匹配及不区分大小写不匹配二.文件及目录匹配,其中:* -f和!-f用来判断是否存在文件* ...

  10. 精简版自定义 jquery

    function $(id) { var el = 'string' == typeof id ? document.getElementById(id) : id; el.on = function ...