题目连接:

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. Metasploit框架问题

    1.使用nmap 扫描SMB服务漏洞信息 nmap -P0 --script=smb-check-vulns 10.10.15.123 2.sql语句绕过后台 这部分我待会补充 只有尽可能的过滤,没有 ...

  2. HTML&javaSkcript&CSS&jQuery&ajax(五)

    一.Framset标签定义了每个框架中的HTML文档, 1. <framset cols="25%,75%"> <frame src="frame_a. ...

  3. Java 获取窗口的宽、高

    创建一个新窗口,通过getSize()获取这个窗口的宽.高. import javax.swing.JFrame; public class WindowInTheMiddle extends JFr ...

  4. easyui合并多个单元格

    $('#table-v2').datagrid({ url: './data/am/data1_table.json', pagination: true, //显示分页 fit: true, //d ...

  5. python unittest套件,修改为失败重新执行

    #套件,修改为失败重新执行 import time import unittest from unittest.suite import _isnotsuite class Suit(unittest ...

  6. Sqoop使用,mysql,hbase,hive等相互转换

    Sqoop 是一款用来在不同数据存储软件之间进行数据传输的开源软件,它支持多种类型的数据储存软件. 安装 Sqoop 1.下载sqoop并加mysql驱动包 http://mirror.bit.edu ...

  7. SQLServer锁的基础问题探究

    SqlServer需要在执行操作前对目标资源获取所有权,那么久发生锁定,是一个逻辑概念.为了保证事务的ACID特性设计的一种机制. 在多用户并发操作数据时,为了出现不一致的数据,锁定是必须的机制.使用 ...

  8. 【C++ Primer | 10】泛型算法

    #include<iostream> #include<algorithm> #include<vector> #include<string> #in ...

  9. 字符转ASCII码

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

  10. context日志

    class Program { static void Main(string[] args) { List<wolf_example> Listw; using (var ctx = n ...