题目连接:

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 分类的列表查询

    public function index(Request $request, ResponseFactoryContract $response, QuestionModel $questionMo ...

  2. node.js 的页面渲染方法ejs

    .安装依赖的组件 npm i consolidate -D npm i ejs -D 2.布局服务端 const express = require('express'); const consoli ...

  3. 原码、补码、反码的概念和java数的存储方式

    原码:用符号位和数值位表示一个带符号数,整数符号->0,负数符号->1,数值一般用二进制形式表示 [+10011]原=00010011    [-10011]原=10010011 反码:正 ...

  4. JAVA中的Token

    JAVA中的Token 基于Token的身份验证 来源:转载 最近在做项目开始,涉及到服务器与安卓之间的接口开发,在此开发过程中发现了安卓与一般浏览器不同,安卓在每次发送请求的时候并不会带上上一次请求 ...

  5. mysql+redis+memcached

    mysql+redis+memcached 数据库 数据库设计 a. 单表 b. FK(单表:一张表存储时,如果有重复出现的字段为了防止硬盘的浪费,所以做一个FK:去掉FK变成单表(这样子访问速度快了 ...

  6. linux上安装redis并使用

    1.下载:curl -O http://download.redis.io/releases/redis-4.0.6.tar.gz 2.在/usr/local/redis上解压:tar -zxvf r ...

  7. Tensorflow生成唐诗和歌词(下)

    整个工程使用的是Windows版pyCharm和tensorflow. 源码地址:https://github.com/Irvinglove/tensorflow_poems/tree/master ...

  8. Nginx 提示host not found in upstream 错误解决方法

      Nginx DNS resolver配置实例,本文讲解在proxy_pass 和 upstream server 通信的时候需要手动指定 resolver,本文就给出了配置实例. nginx 通过 ...

  9. KnockOut -- 快速入门

    简单示例 <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf- ...

  10. WPF多屏最大化

    如果计算机存在多个显示器,这时设置wpf窗口为最大化,窗口只能在主显示器中实现最大化,如果想要实现窗口拉伸至多屏,需要获取所有显示器分辨率之和.这时用到了System.Windows.SystemPa ...