SGU 105 Div 3
|
105. Div 3 time limit per test: 0.5 sec. memory limit per test: 4096 KB
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 |
1 #pragma comment(linker, "/STACK:1024000000,1024000000") 2 #include <map> 3 #include <queue> 4 #include <vector> 5 #include <string> 6 #include <cmath> 7 #include <cstdio> 8 #include <cstring> 9 #include <cstdlib> 10 #include <iostream> 11 #include <algorithm> 12 using namespace std; 13 #define maxn 105 14 #define ll long long 15 #define INF 0x7fffffff 16 #define eps 1e-8 17 int m,ma=-INF; 18 ll n; 19 int main(){ 20 while(~scanf("%I64d", &n)){ 21 printf("%I64d", n * 2 / 3); 22 } 23 return 0; 24 }
浙公网安备 33010602011771号