SGU

WBOY
Release: 2016-06-24 11:52:29
Original
1186 people have browsed it

SGU - 105
SGU - 105

Div 3

Time Limit: 250MS   Memory Limit: 4096KB   64bit IO Format: %I64d & %I64u
Div 3

Time Limit:

 250MS

 

Memory Limit:

 4096KB

 

64bit IO Format:

 %I64d & %I64u

Submit Status

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

Sample Output

Source



数学题!找规律!


规律:0,1,1,0,1,1,0,1,1,0,1,1....      (0代表不能被3整除,1代表能被3整除!)

#include #include #include #include #include using namespace std;int main(){	int n;	scanf("%d", &n);	int ans = 0;	ans += (n/3)*2;	if(n%3==2) ans++;	printf("%d\n", ans);	return 0;}   


AC代码:




source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!