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. 高斯消元&&luogu3389

    高斯消元(Gauss) 高斯消元和我们做二元一次方程组差不多 流程: 1.把系数和右边的值就是用二维数组存下来->转化成矩阵 我们的目标是把这个矩阵装换成 上三角的形式 对角线系数全部为1,1下 ...

  2. SQL Over

    与over函数结合的几个函数 create table #tab(A varchar(), B varchar()) insert into #tab select 'A1', 'B1' union ...

  3. 乘积最大|2018年蓝桥杯B组题解析第十题-fishers

    标题:乘积最大 给定N个整数A1, A2, ... AN.请你从中选出K个数,使其乘积最大. 请你求出最大的乘积,由于乘积可能超出整型范围,你只需输出乘积除以1000000009的余数. 注意,如果X ...

  4. Chromosome coordinate systems: 0-based, 1-based

    From: https://arnaudceol.wordpress.com/2014/09/18/chromosome-coordinate-systems-0-based-1-based/ I’v ...

  5. redis nginx session tomcat

    Redis解决session共享 http://lyl-zsu.iteye.com/blog/2408292 http://zx10103326.iteye.com/blog/2244195 http ...

  6. Quartz.NET教程:(01) 使用Quartz

    使用调度器 (scheduler) 之前要先用 ISchedulerFactory 的一个实现来实例化调度器(scheduler).一旦调度器实例化完成,则它可以被启动.置于备用模式或者关闭.需要注意 ...

  7. 指数循环节 求A的B次方模C

    phi(c)为欧拉函数, 欧拉定理 : 对于互质的正整数 a 和 n ,有 aφ(n)  ≡ 1 mod n  . A^x = A^(x % Phi(C) + Phi(C)) (mod C) (x & ...

  8. poj 3468 A Simple Problem with Integers 线段树加延迟标记

    A Simple Problem with Integers   Description You have N integers, A1, A2, ... , AN. You need to deal ...

  9. 如何理解并正确使用MySql索引

    原文链接:https://my.oschina.net/feinik/blog/1305784 1.概述 索引是存储引擎用于快速查找记录的一种数据结构,通过合理的使用数据库索引可以大大提高系统的访问性 ...

  10. 深度学习框架Keras安装

    环境:Windows 10 64位 版本!版本!版本!不要下载最新版本的! 一点要按照这个来!安装顺序也最好不要错! 首先安装DirectX SDK工具包 ,这是链接:https://www.micr ...