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. Educational Codeforces Round 21 Problem D(Codeforces 808D)

    Vasya has an array a consisting of positive integer numbers. Vasya wants to divide this array into t ...

  2. VC++实现获取文件占用空间大小的两种方法(非文件大小)

    // GetFileSpaceSize.cpp : Defines the entry point for the console application. // /***************** ...

  3. 【转】linux之cp/scp命令+scp命令详解

    linux之cp/scp命令+scp命令详解   名称:cp 使用权限:所有使用者 使用方式: cp [options] source dest cp [options] source... dire ...

  4. Python3基础 dict keys+values 循环打印字典中的所有键和值

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

  5. POJ1144 Network(割点)题解

    Description A Telephone Line Company (TLC) is establishing a new telephone cable network. They are c ...

  6. OSError: [WinError 193] %1 不是有效的 Win32 应用程序。

    经过搜索查找,发现错误原因是我在win7 x64的机器上装了64位的python IDLE,不能有效load32位的dll,换成32位的python就好了.

  7. python 二进制数相加

    def add_binary_nums(x,y): max_len = max(len(x), len(y)) x = x.zfill(max_len) y = y.zfill(max_len) re ...

  8. Springboot 学习笔记 之 Day 4 笔记部分

    spring-boot-starter 核心Spring Boot starter,包括自动配置支持,日志和YAMLspring-boot-starter-actuator 生产准备的特性,用于帮你监 ...

  9. 团队作业Beta冲刺-第三天

    2018.06.26 各个成员完成任务 成员 今日完成任务 贡献小时数 龙正圆 后台程序完善 5h 杨环宇 后台程序完善 4h 马军.龚继恒 界面美化 2h 候燕.纪亚星 Beta冲刺博客的撰写 3h ...

  10. Python 爬虫-获得大学排名

    2017-07-29 23:20:24 主要技术路线:requests+bs4+格式化输出 import requests from bs4 import BeautifulSoup url = 'h ...