首页 > 其他 > 详细

(数论) SGU 105

时间:2015-01-20 13:40:00      阅读:251      评论:0      收藏:0      [点我收藏+]
D - Div 3
Time Limit:250MS     Memory Limit:4096KB     64bit IO Format:%I64d & %I64u
Appoint description: 

Description

 

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
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
      int n;
      while(scanf("%d",&n)!=EOF)
      {
            int ans=(n/3)*2+((n%3)==2?1:0);
            printf("%d\n",ans);
      }
      return 0;
}

  

(数论) SGU 105

原文:http://www.cnblogs.com/a972290869/p/4235805.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!