Codeforces Round #382 (Div. 2)

来源:互联网 发布:人民日报网络舆情 编辑:程序博客网 时间:2024/05/04 13:09
C. Tennis Championship
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Famous Brazil city Rio de Janeiro holds a tennis tournament and Ostap Bender doesn't want to miss this event. There will ben players participating, and the tournament will follow knockout rules from the very first game. That means, that if someone loses a game he leaves the tournament immediately.

Organizers are still arranging tournament grid (i.e. the order games will happen and who is going to play with whom) but they have already fixed one rule: two players can play against each other only if the number of games one of them has already playeddiffers by no more than one from the number of games the other one has already played. Of course, both players had to win all their games in order to continue participating in the tournament.

Tournament hasn't started yet so the audience is a bit bored. Ostap decided to find out what is the maximum number of games the winner of the tournament can take part in (assuming the rule above is used). However, it is unlikely he can deal with this problem without your help.

Input

The only line of the input contains a single integer n (2 ≤ n ≤ 1018) — the number of players to participate in the tournament.

Output

Print the maximum number of games in which the winner of the tournament can take part.

Examples
Input
2
Output
1
Input
3
Output
2
Input
4
Output
2
Input
10
Output
4
Note

In all samples we consider that player number 1 is the winner.

In the first sample, there would be only one game so the answer is 1.

In the second sample, player 1 can consequently beat players2 and 3.

In the third sample, player 1 can't play with each other player as after he plays with players2 and 3 he can't play against player4, as he has 0 games played, while player1 already played 2. Thus, the answer is2 and to achieve we make pairs (1, 2) and (3, 4) and then clash the winners.

暂为想出原理....明天再写了....


D. Taxes
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Mr. Funt now lives in a country with a very specific tax laws. The total income of mr. Funt during this year is equal ton (n ≥ 2) burles and the amount of tax he has to pay is calculated as the maximum divisor ofn (not equal to n, of course). For example, ifn = 6 then Funt has to pay 3 burles, while for n = 25 he needs to pay5 and if n = 2 he pays only1 burle.

As mr. Funt is a very opportunistic person he wants to cheat a bit. In particular, he wants to split the initialn in several parts n1 + n2 + ... + nk = n (here k is arbitrary, even k = 1 is allowed) and pay the taxes for each part separately. He can't make some part equal to1 because it will reveal him. So, the condition ni ≥ 2 should hold for alli from 1 to k.

Ostap Bender wonders, how many money Funt has to pay (i.e. minimal) if he chooses and optimal way to splitn in parts.

Input

The first line of the input contains a single integer n (2 ≤ n ≤ 2·109) — the total year income of mr. Funt.

Output

Print one integer — minimum possible number of burles that mr. Funt has to pay as a tax.

Examples
Input
4
Output
2
Input
27
Output
3
很水的题。。。但是cf中并不会,基于哥德巴赫猜想去考虑,然后特判下2,即可。
ps:哥德巴赫猜想:对于任意偶数2*n(n>=1),可以分解成两个质数的和;对于任意奇数2*n+1(n>=1),若2*n+1不为质数,2*n-1为质数,则2*n+1能分解成两个质数的和;若2*n+1和2*n-1都不为质数,则2*n+1能分解成三个质数的和。
最终提醒大家...学术问题还是别百度了...
#include<cstdio>#include<cstdlib>#include<iostream>#include<stack>#include<queue>#include<algorithm>#include<string>#include<cstring>#include<cmath>#include<vector>#include<map>#include<set>#define eps 1e-8#define zero(x) (((x>0?(x):-(x))-eps)#define mem(a,b) memset(a,b,sizeof(a))#define memmax(a) memset(a,0x3f,sizeof(a))#define pfn printf("\n")#define ll __int64#define ull unsigned long long#define sf(a) scanf("%d",&a)#define sf64(a) scanf("%I64d",&a)#define sf264(a,b) scanf("%I64d%I64d",&a,&b)#define sf364(a,b,c) scanf("%I64d%I64d%I64d",&a,&b,&c)#define sf2(a,b) scanf("%d%d",&a,&b)#define sf3(a,b,c) scanf("%d%d%d",&a,&b,&c)#define sf4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)#define sff(a) scanf("%f",&a)#define sfs(a) scanf("%s",a)#define sfs2(a,b) scanf("%s%s",a,b)#define sfs3(a,b,c) scanf("%s%s%s",a,b,c)#define sfd(a) scanf("%lf",&a)#define sfd2(a,b) scanf("%lf%lf",&a,&b)#define sfd3(a,b,c) scanf("%lf%lf%lf",&a,&b,&c)#define sfd4(a,b,c,d) scanf("%lf%lf%lf%lf",&a,&b,&c,&d)#define sfc(a) scanf("%c",&a)#define ull unsigned long long#define pp pair<int,int>#define debug printf("***\n")const double PI = acos(-1.0);const double e = exp(1.0);const int INF = 0x7fffffff;;template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }template<class T> inline T Min(T a, T b) { return a < b ? a : b; }template<class T> inline T Max(T a, T b) { return a > b ? a : b; }bool cmpbig(int a, int b){ return a>b; }bool cmpsmall(int a, int b){ return a<b; }using namespace std;bool isprime(int num){    int i;    for(i=2;i*i<=num;i++)        if(num%i==0)        return false;    return true;}int main(){   // freopen("data.in","r",stdin);    int n,i;    while(~sf(n))    {        if(n==2||isprime(n))            printf("1\n");        else if(n%2==0)            printf("2\n");        else        {            if(isprime(n-2))                printf("2\n");            else if(!isprime(n-2))                printf("3\n");        }    }return 0;}

0 0
原创粉丝点击