SGU

WBOY
發布: 2016-06-24 11:52:29
原創
1144 人瀏覽過

SGU - 105

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

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整除!)


AC代码:


#include <cstdio>#include <cstring>#include <algorithm>#include <iostream>#include <cmath>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;} </cmath></iostream></algorithm></cstring></cstdio>
登入後複製






來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!