前三个题超水 29分钟一遍AC  仔细看最后的题

Little C loves number «3» very much. He loves all things about it.

Now he has a positive integer n. He wants to split n into 3 positive integers a,b,c, such that a+b+c=n and none of the 3 integers is a multiple of 3. Help him to find a solution.

Input

A single line containing one integer n(3≤n≤109) — the integer Little C has.

Output

Print 3

positive integers a,b,c in a single line, such that a+b+c=n and none of them is a multiple of 3.

It ca Little C loves number «3» very much. He loves all things about it.

Now he has a positive integer n. He wants to split n into 3 positive integers a,b,c, such that a+b+c=n and none of the 3 integers is a multiple of 3. Help him to find a solution.

Input

A single line containing one integer n(3≤n≤109) — the integer Little C has.

Output

Print 3 positive integers a,b,c in a single line, such that a+b+c=n and none of them is a multiple of 3.

It can be proved that there is at least one solution. If there are multiple solutions, print any of them.

Sample Input

Input

3

Output

1 1 1

Input

233

Output

77 77 79

n be proved that there is at least one solution. If there are multiple solutions, print any of them.

Sample Input

Input

3

Output

1 1 1

Input

233

Output

77 77 79
#include <iostream>
#include <algorithm>
#include<cstdio>
#include<stack>
#include <deque>
#include <cstdlib>
#include <cstring>
#include <string>
#include <map>
#include <deque>
#include <vector>
using namespace std;
typedef long long ll;
map<char,ll> M;
int main()
{
    ll n,i,a,b,c,x,y,z;
    cin>>n;
    a=1;
    b=1;
    x=n-a-b;
    if(x%3!=0)
        cout<<a<<" "<<b<<" "<<x<<endl;
    else
    if((x-1)%3!=0)
      cout<<a<<" "<<b+1<<" "<<x-1<<endl;
    else
        if((x-2)%3!=0)
          cout<<a+1<<" "<<b+1<<" "<<x-2<<endl;
}

 There are n points on the plane, (x1,y1),(x2,y2),…,(xn,yn).

You need to place an isosceles triangle with two sides on the coordinate axis to cover all points (a point is covered if it lies inside the triangle or on the side of the triangle). Calculate the minimum length of the shorter side of the triangle.

Input

First line contains one integer n(1≤n≤105).

Each of the next n lines contains two integers xi and yi (1≤xi,yi≤109).

Output

Print the minimum length of the shorter side of the triangle. It can be proved that it's always an integer.

Sample Input

Input

3
1 1
1 2
2 1

Output

3

Input

4
1 1
1 2
2 1
2 2

Output

4

Hint

Illustration for the first example: 2018国庆第四场个人赛

Illustration for the second example: 2018国庆第四场个人赛

#include <iostream>
#include <algorithm>
#include<cstdio>
#include<stack>
#include <deque>
#include <cstdlib>
#include <cstring>
#include <string>
#include <map>
#include <deque>
#include <vector>
using namespace std;
typedef long long ll;
map<char,ll> M;
int main()
{
    ll i,j,n,a,b,maxx=0;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>a>>b;
        if(a+b>=maxx)
            maxx=a+b;
    }
    cout<<maxx<<endl;
}

Karen is getting ready for a new school day!

2018国庆第四场个人赛

It is currently hh:mm, given in a 24-hour format. As you know, Karen loves palindromes, and she believes that it is good luck to wake up when the time is a palindrome.

What is the minimum number of minutes she should sleep, such that, when she wakes up, the time is a palindrome?

Remember that a palindrome is a string that reads the same forwards and backwards. For instance, 05:39 is not a palindrome, because 05:39 backwards is 93:50. On the other hand, 05:50 is a palindrome, because 05:50 backwards is 05:50.

Input

The first and only line of input contains a single string in the format hh:mm (00 ≤ hh ≤ 23, 00 ≤ mm ≤ 59).

Output

Output a single integer on a line by itself, the minimum number of minutes she should sleep, such that, when she wakes up, the time is a palindrome.

Sample Input

Input

05:39

Output

11

Input

13:31

Output

0

Input

23:59

Output

1

Hint

In the first test case, the minimum number of minutes Karen should sleep for is 11. She can wake up at 05:50, when the time is a palindrome.

In the second test case, Karen can wake up immediately, as the current time, 13:31, is already a palindrome.

In the third test case, the minimum number of minutes Karen should sleep for is 1 minute. She can wake up at 00:00, when the time is a palindrome.

#include <iostream>
#include <algorithm>
#include<cstdio>
#include<stack>
#include <deque>
#include <cstdlib>
#include <cstring>
#include <string>
#include <map>
#include <deque>
#include <vector>
using namespace std;
typedef long long ll;
map<char,ll> M;
int main()
{
    char s[6];
    int ans=0,a=0,b=0,c=0,d=0;
    cin>>s;
    a=s[0]-48;
    b=s[1]-48;
    c=s[3]-48;
    d=s[4]-48;
    while(1)
    {
        if(a==d&&b==c)
            break;
        d++;
        ans++;
        //cout<<"*"<<endl;
        if(d>=10)
        {
            d-=10;
            c+=1;
        }
        if(c*10+d>=60)
        {
            c=0;
            d=0;
            b+=1;
        }
        if(b>=10)
        {
            b-=10;
            a+=1;
        }
        else
        if(a*10+b>=24)
        {
            a=0;
            b=0;
        }
        //cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
    }
    cout<<ans<<endl;
    return 0;
}

 

To stay woke and attentive during classes, Karen needs some coffee!

2018国庆第四场个人赛

Karen, a coffee aficionado, wants to know the optimal temperature for brewing the perfect cup of coffee. Indeed, she has spent some time reading several recipe books, including the universally acclaimed "The Art of the Covfefe".

She knows n coffee recipes. The i-th recipe suggests that coffee should be brewed between li and ri degrees, inclusive, to achieve the optimal taste.

Karen thinks that a temperature is admissible if at least k recipes recommend it.

Karen has a rather fickle mind, and so she asks q questions. In each question, given that she only wants to prepare coffee with a temperature between a and b, inclusive, can you tell her how many admissible integer temperatures fall within the range?

Input

The first line of input contains three integers, n, k (1 ≤ k ≤ n ≤ 200000), and q (1 ≤ q ≤ 200000), the number of recipes, the minimum number of recipes a certain temperature must be recommended by to be admissible, and the number of questions Karen has, respectively.

The next n lines describe the recipes. Specifically, the i-th line among these contains two integers li and ri (1 ≤ li ≤ ri ≤ 200000), describing that the i-th recipe suggests that the coffee be brewed between li and ri degrees, inclusive.

The next q lines describe the questions. Each of these lines contains a and b, (1 ≤ a ≤ b ≤ 200000), describing that she wants to know the number of admissible integer temperatures between a and b degrees, inclusive.

Output

For each question, output a single integer on a line by itself, the number of admissible integer temperatures between a and b degrees, inclusive.

Sample Input

Input

 2 4
91 94
92 97
97 99
92 94
93 97
95 96
90 100

Output

3
3
0
4

Input

2 1 1
1 1
200000 200000
90 100

Output

0

Hint

In the first test case, Karen knows 3 recipes.

  1. The first one recommends brewing the coffee between 91 and 94 degrees, inclusive.
  2. The second one recommends brewing the coffee between 92 and 97 degrees, inclusive.
  3. The third one recommends brewing the coffee between 97 and 99 degrees, inclusive.

A temperature is admissible if at least 2 recipes recommend it.

She asks 4 questions.

In her first question, she wants to know the number of admissible integer temperatures between 92 and 94 degrees, inclusive. There are 3: 92, 93 and 94 degrees are all admissible.

In her second question, she wants to know the number of admissible integer temperatures between 93 and 97 degrees, inclusive. There are 3: 93, 94 and 97 degrees are all admissible.

In her third question, she wants to know the number of admissible integer temperatures between 95 and 96 degrees, inclusive. There are none.

In her final question, she wants to know the number of admissible integer temperatures between 90 and 100 degrees, inclusive. There are 4: 92, 93, 94 and 97 degrees are all admissible.

In the second test case, Karen knows 2 recipes.

  1. The first one, "wikiHow to make Cold Brew Coffee", recommends brewing the coffee at exactly 1 degree.
  2. The second one, "What good is coffee that isn't brewed at at least 36.3306 times the temperature of the surface of the sun?", recommends brewing the coffee at exactly 200000 degrees.

A temperature is admissible if at least 1 recipe recommends it.

In her first and only question, she wants to know the number of admissible integer temperatures that are actually reasonable. There are none.

 煮咖啡 有n本书说时间适合在哪里  k是要求有几本书  q个问题 求问题中lr中有几个适合的时间

 

#include <iostream>
#include <algorithm>
#include<cstdio>
#include<stack>
#include <deque>
#include <cstdlib>
#include <cstring>
#include <string>
#include <map>
#include <deque>
#include <vector>
using namespace std;
typedef long long ll;
map<ll,ll> M;
ll vis[201000]={0};
int main()
{
    ll n,k,q,a,b,i;
    cin>>n>>k>>q;
    while(n--)
    {
        cin>>a>>b;
        M[a]++;
        M[b+1]--;//便于合起来
    }
    memset(vis,0,sizeof(vis));
    //VIS里面存的是满足条件的数
    ll num=0;
    for(i=0;i<200010;i++)
    {
        num+=M[i];
        if(num>=k)
            vis[i]=vis[i-1]+1;
        else
            vis[i]=vis[i-1];
    }
    while(q--)
    {
        cin>>a>>b;
        cout<<vis[b]-vis[a-1]<<endl;
    }
    return 0;
}

 

相关文章: