一道有意思的找规律题目 --- CodeForces - 964A
题目连接:
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的更多相关文章
- 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 ...
- 找规律/贪心 Codeforces Round #310 (Div. 2) A. Case of the Zeros and Ones
题目传送门 /* 找规律/贪心:ans = n - 01匹配的总数,水 */ #include <cstdio> #include <iostream> #include &l ...
- 数学/找规律/暴力 Codeforces Round #306 (Div. 2) C. Divisibility by Eight
题目传送门 /* 数学/暴力:只要一个数的最后三位能被8整除,那么它就是答案:用到sprintf把数字转移成字符读入 */ #include <cstdio> #include <a ...
- 【找规律】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 ...
- Gym - 101775L SOS 博弈 找规律
题目:https://cn.vjudge.net/problem/Gym-101775L PS:训练赛中被这道题折磨的不轻,和队友反复推必胜态与必败态试图推导出公式或者规律,然后推的心态逐渐失控,,, ...
- codeforces D. Queue 找规律+递推
题目链接: http://codeforces.com/problemset/problem/353/D?mobile=true H. Queue time limit per test 1 seco ...
- Codeforces Gym 100114 A. Hanoi tower 找规律
A. Hanoi tower Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100114 Descript ...
- Tetrahedron(Codeforces Round #113 (Div. 2) + 打表找规律 + dp计数)
题目链接: https://codeforces.com/contest/166/problem/E 题目: 题意: 给你一个三菱锥,初始时你在D点,然后你每次可以往相邻的顶点移动,问你第n步回到D点 ...
- 找规律 Codeforces Round #309 (Div. 2) A. Kyoya and Photobooks
题目传送门 /* 找规律,水 */ #include <cstdio> #include <iostream> #include <algorithm> #incl ...
随机推荐
- Linux 系统根目录下各个文件夹的作用
原文: https://blog.csdn.net/qq_26941173/article/details/78376760 /bin 系统由很多放置可执行文件的目录,但是bin目录比较特殊.因为bi ...
- python发送邮件(在邮件中显示HTMLTestRunner生成的报告)
import smtplib from email.mime.text import MIMEText from email.mime.multipart import MIMEMultipart f ...
- 解决bootstrap多模态框跳转时页面左移问题
衍生问题暂未发现.... 忽略左右跳动视觉差 解决方法: 在bootstrap的js搜索padding-right,然后找到“+this.scrollbarWidth”,删掉即可.
- Django_Admin操作
Django_Admin 创建Django_Admin 管理账户 D:\github\Django_Aadmin>python manage.py createsuperuser Usernam ...
- python requests 正则爬虫
代码: import requests from multiprocessing import Pool from requests.exceptions import RequestExceptio ...
- Django中model层详解
#!/usr/bin/env python# _*_ coding:utf-8 _*_ from django.db import models class UserType(models.Model ...
- [POI2007]堆积木Klo
题解: dp定义方程的时候 好像也不能都用前一个来递推..这样就不能优化了 这题看了题解才想出来... 还是很简单的啊.... 我们定义f[i]表示前i个最大收益 那么j要能从i转移就得满足a[i]- ...
- python全栈开发day74-普通验证码和滑块验证码
一.昨日内容回顾 django认证系统 1. 默认auth_user ``` # 创建用户 from django.contrib.auth.models import User User.objec ...
- Centos创建定时任务和开机启动运行脚本
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAArYAAADlCAIAAAAp5CPLAAAgAElEQVR4nNS8d3cj15nuW/wq91vc8d ...
- Codeforces 746F Music in Car
Music in Car 用两个Set维护一下尺取的过程. #include<bits/stdc++.h> #define LL long long #define fi first #d ...