sgu105: Div 3
2015-06-12 08:43
537 查看
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.
1 <= N <= 2147483647
打表找规律就出来了
You must determine amount of numbers in it that are divisible by 3.
1 <= N <= 2147483647
打表找规律就出来了
#include <cstdio> int main() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int n, ans; scanf("%d", &n); switch(n % 3) { case 0: ans = 2; break; case 1: ans = 0; break; case 2: ans = 1; break; } ans += (n-1) / 3 * 2; printf("%d\n", ans); #ifndef ONLINE_JUDGE fclose(stdin); fclose(stdout); #endif return 0; }
相关文章推荐
- Java面向对象的三大特征
- 你真得懂Javascript中的==等于运算符吗?
- ubuntu 中文字体安装
- json解析使用第三方类库JSONKit
- sgu104: Little Shop of Flowers
- WOT简介
- 关于 PHP 7 你必须知道的五件事
- ASP.NET 5系列教程 (六): 在 MVC6 中创建 Web API
- Oracle数据库入门——常用的数据字典
- sgu103: Traffic Lights
- Java第四次实验报告
- 深入解析direct path read (转)
- 代码审查的艺术:Dropbox 的故事
- 搞测量的要时刻保护自己哦!
- Program1
- sgu101: Domino
- apache tomcat负载均衡实验记录
- 手机APP UI设计尺寸基础知识
- Oracle数据库入门——物化视图日志结构
- Android Proguard 详解(转)