105. Div 3

time limit per test: 0.25 sec. 
memory limit per test: 4096 KB

There is sequence 1, 12, 123, 1234, ..., 12345678910, ... . Given first N elements of that sequence. You must determine amount of numbers in it that are divisible by 3.

Input

Input contains N (1<=N<=231 - 1).

Output

Write answer to the output.

Sample Input

4

Sample Output

2

实际用时:4h58min
应用时:3min
思路:小学奥赛应该有被3整除需各位之和为3倍数这一点,又被9余数同数位和的9余数,所以可证被3余同数位和的3余数,然后就是,余数遵循1,0,0,1,0,0,....
#include <cstdio>
#include <cstring>
using namespace std;
long long n;
int main(){
while(scanf("%I64d",&n)==1){
long long l=(n+2)/3;
printf("%I64d\n",n-l);
}
return 0;
}

  

快速切题 sgu105. Div 3 数学归纳 数位+整除 难度:0的更多相关文章

  1. 快速切题 sgu104. Little shop of flowers DP 难度:0

    104. Little shop of flowers time limit per test: 0.25 sec. memory limit per test: 4096 KB PROBLEM Yo ...

  2. 快速切题sgu127. Telephone directory

    127. Telephone directory time limit per test: 0.25 sec. memory limit per test: 4096 KB CIA has decid ...

  3. 快速切题sgu126. Boxes

    126. Boxes time limit per test: 0.25 sec. memory limit per test: 4096 KB There are two boxes. There ...

  4. 快速切题 sgu123. The sum

    123. The sum time limit per test: 0.25 sec. memory limit per test: 4096 KB The Fibonacci sequence of ...

  5. 快速切题 sgu120. Archipelago 计算几何

    120. Archipelago time limit per test: 0.25 sec. memory limit per test: 4096 KB Archipelago Ber-Islan ...

  6. 快速切题 sgu119. Magic Pairs

    119. Magic Pairs time limit per test: 0.5 sec. memory limit per test: 4096 KB “Prove that for any in ...

  7. 快速切题 sgu118. Digital Root 秦九韶公式

    118. Digital Root time limit per test: 0.25 sec. memory limit per test: 4096 KB Let f(n) be a sum of ...

  8. 快速切题 sgu117. Counting 分解质因数

    117. Counting time limit per test: 0.25 sec. memory limit per test: 4096 KB Find amount of numbers f ...

  9. 快速切题 sgu116. Index of super-prime bfs+树思想

    116. Index of super-prime time limit per test: 0.25 sec. memory limit per test: 4096 KB Let P1, P2, ...

随机推荐

  1. Python3基础 list 元组转成列表

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  2. uboot启动提示Error, wrong i2c adapter 0 max 0 possible后卡住了怎么办

    答:这个与i2c驱动有关,应该使能i2c驱动相关的配置项

  3. fastjson 简单使用 及其JSONObject使用

    阿里巴巴FastJson是一个Json处理工具包,包括“序列化”和“反序列化”两部分,它具备如下特征:速度最快,测试表明,fastjson具有极快的性能,超越任其他的Java Json parser. ...

  4. CSS3 动画的一些属性

    定义式 @keyframes 动画名称{ from{ } to{ } } 调用式 动画类似函数,只定义不调用是没效果的,所以要配合调用式使用. animation: 动画名称 动画时间 延时 时间曲线 ...

  5. json库的编译方法和vs2010中导入第三方库的方法

    json库的编译方法和vs2010中导入第三方库的方法 一.去相应官网下载json.cpp文件 Jsoncpp下载:https://sourceforge.net/projects/jsoncpp/  ...

  6. The way to Go(3): 安装Go环境

    Reference: Github: Go Github: The way to Go 在mac上安装Go语言初体验 安装Go环境 Go 语言开发团队开发了适用于以下操作系统的编译器: Linux F ...

  7. flask报错No module named 'flask.ext'

    解决: from flask.ext.httpauth import HTTPBasicAuth 改为 from flask_httpauth import HTTPBasicAuth 提示Modul ...

  8. django多对多中间表详解

    我们都知道对于ManyToMany字段,Django采用的是第三张中间表的方式.通过这第三张表,来关联ManyToMany的双方.下面我们根据一个具体的例子,详细解说中间表的使用. 一.默认中间表 首 ...

  9. Java JDK5新特性-可变参数

    2017-10-31 00:19:07 可变参数:定义方法的时候不知道该定义多少个参数 格式:修饰符 返回值类型 方法名(数据类型... 变量名){} 注意:这里的变量其实是一个数组          ...

  10. php新手第一次安装mongo

    以下是我走位php新手第一次安装mongo模块的步骤: 1.首先从在网上选取适当版本的mongoDB扩展包下载; 2.解压扩展包,并且进入解压目录; tar -zxf mongo-1.4.1.tgz ...