1. 程式人生 > >國慶第四場訓練賽

國慶第四場訓練賽

A - A

Description

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

Now he has a positive integer $ n n $. He wants to split $ n

n $ into $ 3 3 $ positive integers $ a , b
, c a,b,c
$, such that $ a + b + c
= n a+b+c=n
$ and none of the $ 3 3 $ integers is a multiple of $ 3 3 $. Help him to find a solution.

Input

A single line containing one integer $ n n $ ($ 3 n 1 0 9 3 \leq n \leq 10^9 $) — the integer Little C has.

Output

Print $ 3 3 $ positive integers $ a , b , c a,b,c $ in a single line, such that $ a + b + c = n a+b+c=n $ and none of them is a multiple of $ 3 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

題意:找出不包含3的倍數,並且滿足n=a+b+c;
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
typedef long long LL;
using namespace std;
const int INF = 0x3f3f3f;
int main()
{
    LL n,a=1,b=1,c;
    cin>>n;
    for(LL i=1;i<=n;i++)
    {
        if(i%3!=0)
        {
            a=i;
            b=i;
            c=n-a-b;
            if(c%3!=0)
            {
                break;
            }
            else
                continue;
        }
    }
    cout<<a<<" "<<b<<" "<<c<<endl;
    return 0;
}

B

Codeforces——1047B

There are nn points on the plane, (x1,y1),(x2,y2),…,(xn,yn)(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 nn (1≤n≤1051≤n≤105).

Each of the next nn lines contains two integers xixi and yiyi (1≤xi,yi≤1091≤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
Note
Illustration for the first example:
在這裡插入圖片描述
Illustration for the second example:

在這裡插入圖片描述
題意:

平面上有n個點,用一個頂點在原點,兩直角邊分別在x軸和y軸的 等腰直角三角形 覆蓋這些點,求將這些點全部覆蓋的三角形的直角邊最短是多長

思路:

已知是等腰直角三角形,那麼它的斜邊肯定是在 y=-x+b 上,b就是與x軸y軸的交點,也就是我們要求的值

那麼 b=x+y,直接去求 x+y的最大值即可

#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
typedef long long LL;
using namespace std;
const int INF = 0x3f3f3f;
int main()
{
    int n,x,y,maxx=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
         cin>>x>>y;
         maxx=max(maxx,x+y);
    }
    cout<<maxx<<endl;
    return 0;
}

Description

Karen is getting ready for a new school day!

在這裡插入圖片描述
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 <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
typedef long long LL;
using namespace std;
const int INF = 0x3f3f3f;
int main()
{
    int n,m,x;
    scanf("%d:%d",&n,&m);
    int ans=0;
    while(1)
    {
        x=n%10*10+n/10;
        if(x==m)
            break;
        else
        {
            ans++;
            m++;
            if(m==60)
            {
                n+=1;
                m=0;
            }
            if(n==24)
                n=0;
        }

    }
    printf("%d\n",ans);
    return 0;
}