SGU - 105 - Div 3 (简单数学题!)

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<=N<=231 - 1).

Output

Write answer to the output.

Sample Input

4

Sample Output

2

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;
} 
时间: 2024-11-06 09:33:36

SGU - 105 - Div 3 (简单数学题!)的相关文章

SGU[105] Div 3

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. 给定数列 1, 12, 123, 1234, ..., 12345678910, ...的前N个元素.你需要判断其中一共有多少个元素

Codeforces Round #262 (Div. 2)460A. Vasya and Socks(简单数学题)

题目链接:http://codeforces.com/contest/460/problem/A A. Vasya and Socks time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasya has n pairs of socks. In the morning of each day Vasya has to put o

(数论) SGU 105

D - Div 3 Time Limit:250MS     Memory Limit:4096KB     64bit IO Format:%I64d & %I64u Submit Status Practice SGU 105 Appoint description:  System Crawler  (2015-01-20) Description There is sequence 1, 12, 123, 1234, ..., 12345678910, ... . Given first

poj 3117 World Cup(简单数学题)

题目链接:http://poj.org/problem?id=3117 World Cup Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8634   Accepted: 4327 Description A World Cup of association football is being held with teams from around the world. The standing is based on

hdu 2368 Alfredo&#39;s Pizza Restaurant(简单数学题)

转载请注明出处:http://blog.csdn.net/u012860063 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2368 题目很简单,但是比较恶心,用sqrt WA到死也不过,不用秒过: 忍不住吐槽一下; Problem Description Traditionally after the Local Contest, judges and contestants go to their favourite restaurant,

hdu2374 A Game with Marbles(简单数学题)

转载请注明出处:http://blog.csdn.net/u012860063 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2374 Problem Description There are n bowls, numbered from 1 to n. Initially, bowl i contains mi marbles. One game step consists of removing one marble from a bowl.

UVA 12714 Two Points Revisited(简单数学题)

转载请注明出处:http://blog.csdn.net/u012860063 题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4452 题意: 给出两个点组成一条直线,要你任意输出两个点,要求这两点组成的直线和给出的直线垂直(注意输出的点不能有负数): 代码如下: #include <cstdio> int main(

SGU 105

//根据以下三个基本关系可以推出答案. //1.一个数对三取模的余数,是它各个数位之和对三取模的余数(对6,9也成立) //2.1234567891011……(n-1)(n)=1234567891011……(n-1)*10^(n的位数)+n //3.10 mod 3=1,所以10^n mod 3=1. //所以,当n模三余一时,1234567891011……(n-1)(n)模三余一:模三余零或余二,1234567891011…… //(n-1)(n)被三整除. #include "stdio.h

JZOJ5773 简单数学题

escription 话说, 小X是个数学大佬,他喜欢做数学题.有一天,小X想考一考小Y.他问了小Y一道数学题.题目如下: 对于一个正整数N,存在一个正整数T(0<T<N),使得的值是正整数. 小X给出N,让小Y给出所有可能的T.如果小Y不回答这个神奇的大佬的简单数学题,他学神的形象就会支离破碎.所以小Y求你帮他回答小X的问题. Input  一个整数N. Output 第一个数M,表示对于正整数N,存在M个不同的正整数T,使得是整数. 后面是M个数,每一个数代表可能的正整数T(按从小到大的顺