SGU 105
2014-03-04 22:04
127 查看
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
Sample Output
View Code
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[3] = {0,0,1}; int main() { scanf("%I64d",&n); printf("%d\n",n / 3 * 2 + a[n % 3] ); return 0; }
View Code
相关文章推荐
- SGU 105 Div 3
- SGU105 水题 An easy problem
- SGU 105 Div 3
- SGU105—— Div 3
- SGU 105 div3
- 【sgu】105 解题报告
- sgu 105 Div 3
- SGU 105 数学找规律
- Sgu105
- sgu 105 Div 3
- SGU 105 数学找规律
- SGU105
- SGU 105 Div 3
- sgu 105 水
- sgu105-数学
- SGU105 Div 3
- Div 3 - SGU 105(找规律)
- SGU 105 Div 3 翻译 题解
- [SGU 105] Div 3 [数学]
- SGU - 105 - Div 3 (简单数学题!)