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"
int main(){
	int n;
	scanf("%d",&n);
	switch(n%3){
		case 0:printf("%d",2*(n/3));break;
		case 1:printf("%d",2*(n/3));break;
		case 2:printf("%d",2*(n/3)+1);break;
		default:break;
	}
    return 0;
}

SGU 105

时间: 2024-11-06 09:34:39

SGU 105的相关文章

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 numb

(数论) 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

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个元素.你需要判断其中一共有多少个元素

SGU 438 The Glorious Karlutka River =) 拆点+动态流+最大流

The Glorious Karlutka River =) Time Limit:500MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice SGU 438 Appoint description: Description A group of Mtourists are walking along the Karlutka river. They want to cross

sgu Kalevich Strikes Back

这道题就是求一个大矩形被n个矩形划分成n+1个部分的面积,这些矩形之间不会相交,可能包含.. 1 #include <cstdio> 2 #include <cstring> 3 #include <vector> 4 #include <algorithm> 5 #define maxn 120100 6 using namespace std; 7 8 long long s[maxn]; 9 vector<int>g[maxn]; 10 i

数学计数原理(P&#243;lya,高精度):SGU 294 He&#39;s Circles

He's Circles He wrote n letters "X" and "E" in a circle. He thought that there were 2n possibilities to do it, because each letter may be either "X" or "E". But Qc noticed that some different sequences of letters ca

sgu Ice-cream Tycoon

题意:供应商提供n块价格为c的冰淇淋,一个学生想买n块冰淇淋,手中的钱数总共有t元,为了不让买n块冰淇淋所花费的钱数不超过t元,先尽可能卖给这个学生便宜的冰淇淋. 如果这个学生不能买到所需要的冰淇淋则输出“UNHAPPY”,能则输出“HAPPY”. 1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 #define maxn 200000 5 using namespace std; 6 7

sgu 463 - Walking around Berhattan

K - Walking around Berhattan Time Limit:250MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Practice SGU 463 Description As you probably know, Berhattan is a district of Berland's largest city and it consists of equal squar

SGU 403 404 405 406 407 408 409 410 411 413

SGU 403 #include<stdio.h> int x; int main(){ while(~scanf("%d",&x)) printf("%d\n", 2*x+1); return 0; } SGU 404 #include<iostream> #include<cstdio> #include<vector> #include<string.h> using namespace st