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. bzoj1055 ||P4290 [HAOI2008]玩具取名

    目录 链接 思路 代码 链接 luogu bzoj 思路 区间dp 然后\(f[i][j][k]\) 区间\([i,j]\)能否变成\(k\)字符 (字符当然得转化一下) 字符的个数不多,直接暴力\( ...

  2. redhat7 防火墙设置

    查看防火墙的状态# firewall-cmd --staterunning # systemctl stop firewalld   //关闭防火墙服务# systemctl start firewa ...

  3. yarn虚拟cpu和虚拟内存

    虚拟cpu 虚拟的cpu代码并发数,如果一个container拥有2个vcpu,那么该container就可以真正的在同一时间运行两个线程,而不是靠切时间片而达到的逻辑并发.所以一般虚拟的cpu需要和 ...

  4. Network Simulator for P4(NSP4) src内容介绍

    Structure What's NSP4? src source code introduction What's NSP4? NSP4是一个用于P4的网络仿真工具,旨在简化P4的环境部署和运行,将 ...

  5. C指针 的一些练习

    注:此篇是我使用指针敲的一些题目的集成,有一些代码是重复的(挠头).这样做的目的是进行前后的一些比较和收获一些心得(?). 关于上一次我上台的题目: 题目:输入十个整数,进行排序. 做法1:(传递指针 ...

  6. stm32 pwm 电调 电机

    先上代码 python 树莓派版本,通俗表现原理.stm32 C语言版本在后面 import RPi.GPIO as GPIO import time mode=2 IN1=11 def setup( ...

  7. 机器学习-数据可视化神器matplotlib学习之路(二)

    之前学习了matplotlib的一些基本画图方法(查看上一节),这次主要是学习在图中加一些文字和其其它有趣的东西. 先来个最简单的图 from matplotlib import pyplot as ...

  8. 【Python】【环境搭建】

    [环境配置] Windows : http://blog.csdn.net/zhunianguo/article/details/53524792 [Pycharm] pyCharm最新2018激活码 ...

  9. hdu 5668 Circle 中国剩余定理

    Circle Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Problem D ...

  10. 02_DllZZ.def

    ZC: 在VC6里面,只要有这个文件就可以了.但是到了 VS2010,需要手动的指定使用这个文件才行:VS2010-->项目-->属性--> 来到窗口"??? 属性页&qu ...