SGU 105
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 找规律易知会出现011 011 ..... 011 的情况(0代表不可div,1代表可div) 推公式直接输出即可。
#include <iostream>
#include <cstdio> using namespace std; long long n;
int a[] = {,,};
int main()
{
scanf("%I64d",&n); printf("%d\n",n / * + a[n % ] );
return ;
}
SGU 105的更多相关文章
- (水题) Div 3 -- SGU -- 105
链接: http://vj.acmclub.cn/contest/view.action?cid=168#problem/E 时限:250MS 内存:4096KB 64位IO格式:%I ...
- 数论 - SGU 105 DIV3
SGU 105-DIV 3 Problem's Link Mean: 定义这样一种数列:1,12,123.. 给出一个n,求这个数列中能被3整除的数的个数. analyse: 这道题可以用分析的方法解 ...
- SGU 105 div.3 找规律
There is sequence 1, 12, 123, 1234, ..., 12345678910, ... . Given first N elements of that sequence. ...
- sgu 105 Div 3
一个数能整除3当且仅当各位数之和能整除3. 有了这个规律就好办了, 但是呢,仔细一看, n太大了, 都到 2^31 了.所以简单的模拟肯定不行. 这种貌似像数论的题,一时找不到好办法,就打表! 打表出 ...
- Div 3 - SGU 105(找规律)
分析:很容易知道序列1,2,3, 4,5, 6......与3的关系就是1,2, 0,1, 2,0,......如果是在一个数后面添加一个数就变成了这种序列1, 0, 0, 1, 0, 0, 1, 0 ...
- SGU 105 数学找规律
观察一下序列,每3个数一组,第一个数余1,不能,加第二个数后整除(第二个数本身余2),第三数恰整除.一行代码的事.011011011.... #include<iostream> usin ...
- SGU刷题之路开启
VJ小组:SGU---48h/题 每道做出的题目写成题解,将传送门更新在这里. SGU:101 - 200 SGU - 107 水题 解题报告 SGU - 105 找规律水题 解题报告 SGU - 1 ...
- SGU 乱搞日志
SGU 100 A+B :太神不会 SGU 101 Domino: 题目大意:有N张骨牌,两张骨牌有两面有0到6的数字,能相连当且仅当前后数字相同,问能否有将N张骨牌连接的方案?思路:裸的欧拉回路,注 ...
- sgu 104 Little shop of flowers 解题报告及测试数据
104. Little shop of flowers time limit per test: 0.25 sec. memory limit per test: 4096 KB 问题: 你想要将你的 ...
随机推荐
- Ruby Code Style
这篇博文逐渐写一点关于Ruby的编码风格,主要参考ruby-stytle-guide. 一些命名准则 函数与变量 使用蛇形小写比较好:some_var, some_function 目录和文件也使用s ...
- Red Gate Software 软件推荐
这家公司的Wiki http://en.wikipedia.org/wiki/Redgate http://www.red-gate.com/products/ 好吧 就介绍点免费的 Find SQL ...
- linux C socket
socket套接字和管道同样可以提供进程内通信.但套接字更胜一筹,不同的进程可以跨越不同的主机(说白了,支持网络通信).使用套接字的知名程序:telnet.rlogin.ftp等. 你需要知道的一些基 ...
- 转 在SQL Server中创建用户角色及授权(使用SQL语句)
目录 要想成功访问 SQL Server 数据库中的数据 我们需要两个方面的授权 完整的代码示例 使用存储过程来完成用户创建 实例 要想成功访问 SQL Server 数据库中的数据, 我们需要两个 ...
- Mybatis typeAliases别名
<typeAliases> <typeAlias type="com.green.phonemanage.model.CellPhone" alias=" ...
- chkconfig 命令详解
chkconfig命令主要用来更新(启动或停止)和查询系统服务的运行级信息.谨记chkconfig不是立即自动禁止或激活一个服务,它只是简单的改变了符号连接. 使用语法: chkconfig [--a ...
- 如何用nodejs写入mysql 的blob格式的数据
So, if the array length equals 4, then the size of blob data in mysql DB must be 4 bytes. And it wor ...
- func_num_args(),func_get_arg(),func_get_args()
<?php function testFunction1(){ return func_num_args(); } function testFunction2(){ return func_g ...
- Qt---- 点击按钮调用另一个窗口Ui
-------------------------------------------------- #include "subdialog.h" SubDialog::SubDi ...
- Python实现NN(神经网络)
Python实现NN(神经网络) 参考自Github开源代码:https://github.com/dennybritz/nn-from-scratch 运行环境 Pyhton3 numpy(科学计算 ...